aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTeddy Wing2017-11-29 17:40:32 +0100
committerTeddy Wing2017-11-29 17:40:32 +0100
commitdb6afd0a73c7196a1e2ca0fe62599443bc2a9dd1 (patch)
tree4e369c8c0cf52ac5d1f054cafa2cd13fc25c130d
parente06f5641a074eacce3218f277b42ef5f1eb696a6 (diff)
downloadchouette-core-db6afd0a73c7196a1e2ca0fe62599443bc2a9dd1.tar.bz2
referential_spec(duplicate referential): Check that lock gets released
Add an extra referential to the test and check that it gets saved to confirm that the table lock gets released at the end of the transaction. Not sure if this is actually necessary to verify, but wanted to make sure before I had gone and read the Postgres docs (https://www.postgresql.org/docs/9.4/static/explicit-locking.html#ADVISORY-LOCKS). Refs #5024
-rw-r--r--spec/models/referential_spec.rb8
1 files changed, 7 insertions, 1 deletions
diff --git a/spec/models/referential_spec.rb b/spec/models/referential_spec.rb
index e65f8f457..5a882b06e 100644
--- a/spec/models/referential_spec.rb
+++ b/spec/models/referential_spec.rb
@@ -171,6 +171,7 @@ describe Referential, :type => :model do
)
referential_2 = referential_1.dup
referential_2.slug = "#{referential_1.slug}_different"
+ referential_3 = nil
metadata_1 = build(
:referential_metadata,
@@ -193,6 +194,7 @@ describe Referential, :type => :model do
sleep 5
ActiveRecord::Base.transaction do
referential_2.save
+ referential_3 = create(:referential)
end
end
@@ -201,10 +203,14 @@ describe Referential, :type => :model do
expect(referential_1).to be_persisted
expect(referential_2).not_to be_persisted
-
+ expect(referential_3).to be_persisted
ensure
Apartment::Tenant.drop(referential_1.slug) if referential_1.persisted?
Apartment::Tenant.drop(referential_2.slug) if referential_2.persisted?
+
+ if referential_3.try(:persisted?)
+ Apartment::Tenant.drop(referential_3.slug)
+ end
end
end
end