Skip to content

Commit

Permalink
Put job in with_current_user block
Browse files Browse the repository at this point in the history
Effect of adding `samples.all?(&:can_edit?)` clause ini editing
constraints.
  • Loading branch information
kdp-cloud committed Oct 22, 2024
1 parent 675a39b commit 190cd76
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions test/unit/jobs/update_sample_metadata_job_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 190cd76

Please sign in to comment.