Fix failing api test because of randomness [SCI-9569] (#6549)

This commit is contained in:
ajugo 2023-10-30 09:42:49 +01:00 committed by GitHub
parent 9fbbb185e0
commit c1e3472d46
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 18 additions and 17 deletions

View file

@ -241,7 +241,7 @@ RSpec.describe "Api::V1::ExperimentsController", type: :request do
describe 'PATCH experiment, #update' do
before :all do
@valid_headers['Content-Type'] = 'application/json'
@experiment = @valid_project.experiments.first
@experiment = @valid_project.experiments.active.first
end
let(:action) do

View file

@ -238,7 +238,7 @@ RSpec.describe 'Api::V1::ProjectsController', type: :request do
describe 'PATCH project, #update' do
before :all do
@valid_headers['Content-Type'] = 'application/json'
@project = @user.teams.first.projects.first
@project = @user.teams.first.projects.active.first
end
let(:action) do

View file

@ -27,13 +27,14 @@ RSpec.describe 'Api::V1::ProtocolTemplateController', type: :request do
team_id: @team.id
), headers: @valid_headers
expect { hash_body = json }.not_to raise_exception
expect(hash_body[:data]).to match(
JSON.parse(
ActiveModelSerializers::SerializableResource
.new(Protocol.latest_available_versions(@team), each_serializer: Api::V1::ProtocolTemplateSerializer)
.to_json
)['data']
)
parsed_data = JSON.parse(
ActiveModelSerializers::SerializableResource
.new(Protocol.latest_available_versions(@team), each_serializer: Api::V1::ProtocolTemplateSerializer)
.to_json
)['data']
expect(hash_body[:data]).to match_array(parsed_data)
end
it 'When invalid request, user in not member of the team' do
@ -63,13 +64,13 @@ RSpec.describe 'Api::V1::ProtocolTemplateController', type: :request do
get api_v1_team_protocol_template_path(id: @protocol_published_original.id, team_id: @team.id), headers: @valid_headers
expect { hash_body = json }.not_to raise_exception
expect(hash_body[:data]).to match(
JSON.parse(
ActiveModelSerializers::SerializableResource
.new(@protocol_published_original, serializer: Api::V1::ProtocolTemplateSerializer)
.to_json
)['data']
)
parsed_data = JSON.parse(
ActiveModelSerializers::SerializableResource
.new(@protocol_published_original, serializer: Api::V1::ProtocolTemplateSerializer)
.to_json
)['data']
expect(hash_body[:data]).to match_array(parsed_data)
end
it 'When invalid request, user in not member of the team' do

View file

@ -285,7 +285,7 @@ RSpec.describe 'Api::V1::TasksController', type: :request do
@valid_headers['Content-Type'] = 'application/json'
end
let(:task) { @valid_experiment.my_modules.take }
let(:task) { @valid_experiment.my_modules.active.first }
let(:action) do
patch(