You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The spec Sipity::Role#destroy almost always fails in the context of the entire test suite, but will succeed when ran again individually. The failure is always the same:
./spec/models/sipity/role_spec.rb
Sipity::Role#destroy will not allow registered role names to be destroyed
PG::UniqueViolation: ERROR: duplicate key value violates unique constraint "index_sipity_roles_on_name" DETAIL: Key (name)=(managing) already exists.
Failure/Error: role = described_class.create!(name: Hyrax::RoleRegistry::MANAGING)
...
/app/bundle/ruby/3.3.0/gems/activerecord-7.2.2.1/lib/active_record/persistence.rb:55:in `create!'
./spec/models/sipity/role_spec.rb:32:in `block (3 levels) in <module:Sipity>'
There is likely a race condition where a previous database operation hasn't finished cleaning up before this test starts. Here are a couple of ideas from @dmolesUC :
In terms of just getting this spec to pass, it seems like the easiest fix would be to replace the create! with find_or_create_by
I notice we're using different DatabaseCleaner strategies for different tests :
The spec
Sipity::Role#destroy
almost always fails in the context of the entire test suite, but will succeed when ran again individually. The failure is always the same:There is likely a race condition where a previous database operation hasn't finished cleaning up before this test starts. Here are a couple of ideas from @dmolesUC :
In terms of just getting this spec to pass, it seems like the easiest fix would be to replace the
create!
withfind_or_create_by
I notice we're using different DatabaseCleaner strategies for different tests :
hyrax/spec/spec_helper.rb
Lines 199 to 205 in 5b03f59
It might be worth trying just using truncation for everything, I know it's supposed to be slower but IDK if it's enough slower that we need to care
The text was updated successfully, but these errors were encountered: