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,9 +29,11 @@ module ReportActions
# Delete existing template values
@report.report_template_values.destroy_all
formatted_template_values = @template_values.as_json.map { |k, v| v['name'] = k; v }
# Save new template values
@report.report_template_values.create!(formatted_template_values)
if @template_values.present?
formatted_template_values = @template_values.as_json.map { |k, v| v['name'] = k; v }
# Save new template values
@report.report_template_values.create!(formatted_template_values)
end
end
@report

View file

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