diff --git a/test/unit/jobs/update_sample_metadata_job_test.rb b/test/unit/jobs/update_sample_metadata_job_test.rb index e978fd2e22..d465b04e4f 100644 --- a/test/unit/jobs/update_sample_metadata_job_test.rb +++ b/test/unit/jobs/update_sample_metadata_job_test.rb @@ -23,16 +23,17 @@ def teardown end test 'Check sample metadata after updating the attribute title' do - assert_equal @sample_type.sample_attributes.first.title, 'the_title' - @sample_type.sample_attributes.first.update!(title: 'new title') - attribute_change_maps = [{id: @sample_type.sample_attributes.first.id, old_title: 'the_title', new_title: 'new title' }] - assert_equal @sample_type.sample_attributes.first.title, 'new title' - refute_equal @sample_type.sample_attributes.first.title, 'the_title' - UpdateSampleMetadataJob.new.perform(@sample_type, attribute_change_maps, @person.user) - @sample_type.samples.each do |sample| - json_metadata = JSON.parse sample.json_metadata - assert json_metadata.keys.include?('new title') - refute json_metadata.keys.include?('the_title') + User.with_current_user(@person.user) do + @sample_type.sample_attributes.first.update!(title: 'new title') + attribute_change_maps = [{id: @sample_type.sample_attributes.first.id, old_title: 'the_title', new_title: 'new title' }] + assert_equal @sample_type.sample_attributes.first.title, 'new title' + refute_equal @sample_type.sample_attributes.first.title, 'the_title' + UpdateSampleMetadataJob.new.perform(@sample_type, attribute_change_maps, @person.user) + @sample_type.samples.each do |sample| + json_metadata = JSON.parse sample.json_metadata + assert json_metadata.keys.include?('new title') + refute json_metadata.keys.include?('the_title') + end end end end