Skip to content

Commit

Permalink
fix authlookupqueue test, obs unit needs its own due to the study #1961
Browse files Browse the repository at this point in the history
  • Loading branch information
stuzart committed Jul 19, 2024
1 parent ca35a89 commit c5a8d4f
Showing 1 changed file with 26 additions and 1 deletion.
27 changes: 26 additions & 1 deletion test/unit/permissions/auth_lookup_update_queue_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,34 @@ def teardown
end
end

test 'updates to queue for observation unit' do
user = FactoryBot.create :user
observation_unit = nil
study = FactoryBot.create(:study, contributor: user.person)
assert_difference('AuthLookupUpdateQueue.count', 1) do
observation_unit = FactoryBot.create :observation_unit, contributor: user.person, policy: FactoryBot.create(:private_policy), study: study
end
assert_equal observation_unit, AuthLookupUpdateQueue.order(:id).last.item

AuthLookupUpdateQueue.destroy_all
observation_unit.policy.access_type = Policy::VISIBLE

assert_difference('AuthLookupUpdateQueue.count', 1) do
observation_unit.policy.save
end
assert_equal observation_unit, AuthLookupUpdateQueue.order(:id).last.item
AuthLookupUpdateQueue.destroy_all
observation_unit.title = Time.now.to_s
assert_no_difference('AuthLookupUpdateQueue.count') do
disable_authorization_checks do
observation_unit.save!
end
end
end

test 'updates for remaining authorized assets' do
user = FactoryBot.create :user
types = Seek::Util.authorized_types - [Sop, Assay, Study, Sample]
types = Seek::Util.authorized_types - [Sop, Assay, Study, Sample, ObservationUnit]
types.each do |type|
entity = nil
assert_difference('AuthLookupUpdateQueue.count', 1, "unexpected count for created type #{type.name}") do
Expand Down

0 comments on commit c5a8d4f

Please sign in to comment.