mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-10-06 20:05:55 +08:00
Fix failing api test because of randomness [SCI-9569] (#6549)
This commit is contained in:
parent
9fbbb185e0
commit
c1e3472d46
4 changed files with 18 additions and 17 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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(
|
||||
|
|
Loading…
Add table
Reference in a new issue