chore: Fix flaky permissions test (#10074)

- the permissions tests were failing when the random number turns out to
be 0, fixing this case and ensuring that its always between, 1-4.
This commit is contained in:
Sojan Jose
2024-09-04 16:13:29 -07:00
committed by GitHub
parent 8a2f652b94
commit d6fd3ce048
2 changed files with 3 additions and 2 deletions

View File

@@ -69,7 +69,8 @@ RSpec.describe 'Custom Roles API', type: :request do
describe 'POST #create' do
let(:valid_params) do
{ custom_role: { name: 'Support', description: 'Support role', permissions: CustomRole::PERMISSIONS.sample(SecureRandom.random_number(4)) } }
{ custom_role: { name: 'Support', description: 'Support role',
permissions: CustomRole::PERMISSIONS.sample(SecureRandom.random_number(1..4)) } }
end
context 'when it is an authenticated administrator' do

View File

@@ -3,6 +3,6 @@ FactoryBot.define do
account
name { Faker::Name.name }
description { Faker::Lorem.sentence }
permissions { CustomRole::PERMISSIONS.sample(SecureRandom.random_number(4)) }
permissions { CustomRole::PERMISSIONS.sample(SecureRandom.random_number(1..4)) }
end
end