mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-10-08 12:56:27 +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
|
describe 'PATCH experiment, #update' do
|
||||||
before :all do
|
before :all do
|
||||||
@valid_headers['Content-Type'] = 'application/json'
|
@valid_headers['Content-Type'] = 'application/json'
|
||||||
@experiment = @valid_project.experiments.first
|
@experiment = @valid_project.experiments.active.first
|
||||||
end
|
end
|
||||||
|
|
||||||
let(:action) do
|
let(:action) do
|
||||||
|
|
|
@ -238,7 +238,7 @@ RSpec.describe 'Api::V1::ProjectsController', type: :request do
|
||||||
describe 'PATCH project, #update' do
|
describe 'PATCH project, #update' do
|
||||||
before :all do
|
before :all do
|
||||||
@valid_headers['Content-Type'] = 'application/json'
|
@valid_headers['Content-Type'] = 'application/json'
|
||||||
@project = @user.teams.first.projects.first
|
@project = @user.teams.first.projects.active.first
|
||||||
end
|
end
|
||||||
|
|
||||||
let(:action) do
|
let(:action) do
|
||||||
|
|
|
@ -27,13 +27,14 @@ RSpec.describe 'Api::V1::ProtocolTemplateController', type: :request do
|
||||||
team_id: @team.id
|
team_id: @team.id
|
||||||
), headers: @valid_headers
|
), headers: @valid_headers
|
||||||
expect { hash_body = json }.not_to raise_exception
|
expect { hash_body = json }.not_to raise_exception
|
||||||
expect(hash_body[:data]).to match(
|
|
||||||
JSON.parse(
|
parsed_data = JSON.parse(
|
||||||
ActiveModelSerializers::SerializableResource
|
ActiveModelSerializers::SerializableResource
|
||||||
.new(Protocol.latest_available_versions(@team), each_serializer: Api::V1::ProtocolTemplateSerializer)
|
.new(Protocol.latest_available_versions(@team), each_serializer: Api::V1::ProtocolTemplateSerializer)
|
||||||
.to_json
|
.to_json
|
||||||
)['data']
|
)['data']
|
||||||
)
|
|
||||||
|
expect(hash_body[:data]).to match_array(parsed_data)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'When invalid request, user in not member of the team' do
|
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
|
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 = json }.not_to raise_exception
|
||||||
expect(hash_body[:data]).to match(
|
parsed_data = JSON.parse(
|
||||||
JSON.parse(
|
ActiveModelSerializers::SerializableResource
|
||||||
ActiveModelSerializers::SerializableResource
|
.new(@protocol_published_original, serializer: Api::V1::ProtocolTemplateSerializer)
|
||||||
.new(@protocol_published_original, serializer: Api::V1::ProtocolTemplateSerializer)
|
.to_json
|
||||||
.to_json
|
)['data']
|
||||||
)['data']
|
|
||||||
)
|
expect(hash_body[:data]).to match_array(parsed_data)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'When invalid request, user in not member of the team' do
|
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'
|
@valid_headers['Content-Type'] = 'application/json'
|
||||||
end
|
end
|
||||||
|
|
||||||
let(:task) { @valid_experiment.my_modules.take }
|
let(:task) { @valid_experiment.my_modules.active.first }
|
||||||
|
|
||||||
let(:action) do
|
let(:action) do
|
||||||
patch(
|
patch(
|
||||||
|
|
Loading…
Add table
Reference in a new issue