Fix tests [SCI-5636]

This commit is contained in:
Oleksii Kriuchykhin 2021-05-03 13:03:26 +02:00
parent 1b8265343e
commit 1abc0dc1eb
2 changed files with 15 additions and 11 deletions

View file

@ -29,10 +29,12 @@ module ReportActions
# Delete existing template values # Delete existing template values
@report.report_template_values.destroy_all @report.report_template_values.destroy_all
if @template_values.present?
formatted_template_values = @template_values.as_json.map { |k, v| v['name'] = k; v } formatted_template_values = @template_values.as_json.map { |k, v| v['name'] = k; v }
# Save new template values # Save new template values
@report.report_template_values.create!(formatted_template_values) @report.report_template_values.create!(formatted_template_values)
end end
end
@report @report
rescue ActiveRecord::ActiveRecordError, ArgumentError => e rescue ActiveRecord::ActiveRecordError, ArgumentError => e

View file

@ -9,9 +9,10 @@ describe ReportsController, type: :controller do
let!(:team) { create :team, created_by: user } let!(:team) { create :team, created_by: user }
let!(:user_team) { create :user_team, team: team, user: user } let!(:user_team) { create :user_team, team: team, user: user }
let(:user_project) { create :user_project, :owner, user: user } let(:user_project) { create :user_project, :owner, user: user }
let(:project) do let(:project) { create :project, team: team, user_projects: [user_project] }
create :project, team: team, user_projects: [user_project] let(:experiment) { create :experiment, project: project }
end let(:my_module1) { create :my_module, experiment: experiment }
let(:my_module2) { create :my_module, experiment: experiment }
let(:report) do let(:report) do
create :report, user: user, project: project, team: team, create :report, user: user, project: project, team: team,
name: 'test repot A1', description: 'test description A1' name: 'test repot A1', description: 'test description A1'
@ -23,9 +24,10 @@ describe ReportsController, type: :controller do
let(:params) do let(:params) do
{ project_id: project.id, { project_id: project.id,
report: { name: 'test report created', report: { name: 'test report created',
description: 'test description created' }, description: 'test description created',
report_contents: '[{"type_of":"project_header","id":{"project_id":' + settings: Report::DEFAULT_SETTINGS },
project.id.to_s + '},"sort_order":null,"children":[]}]' } project_content: { experiments: { experiment.id => [my_module1.id] } },
template_values: [] }
end end
it 'calls create activity service' do it 'calls create activity service' do
@ -49,8 +51,8 @@ describe ReportsController, type: :controller do
id: report.id, id: report.id,
report: { name: 'test report update', report: { name: 'test report update',
description: 'test description update' }, description: 'test description update' },
report_contents: '[{"type_of":"project_header","id":{"project_id":' + project_content: { experiments: { experiment.id => [my_module2.id] } },
project.id.to_s + '},"sort_order":null,"children":[]}]' } template_values: [] }
end end
it 'calls create activity service' do it 'calls create activity service' do
expect(Activities::CreateActivityService).to receive(:call) expect(Activities::CreateActivityService).to receive(:call)