diff options
| author | Teddy Wing | 2017-11-29 16:12:35 +0100 |
|---|---|---|
| committer | Teddy Wing | 2017-11-29 16:12:35 +0100 |
| commit | 03bc0004ade09b27b31c3f6d14c725a7ab99a303 (patch) | |
| tree | 8be0a27777de69b4ffc7df093291709a4a4cf58b | |
| parent | 7ebc710729081119da4a69472c7fd1dd3dfd58d8 (diff) | |
| download | chouette-core-03bc0004ade09b27b31c3f6d14c725a7ab99a303.tar.bz2 | |
referential_spec: Clean up duplicate referential spec
Remove old commented code that no longer relates. The thread code will
be moved to a new test. This test now validates the existing behaviour
synchronously. Update the test descriptions accordingly.
Refs #5024
| -rw-r--r-- | spec/models/referential_spec.rb | 28 |
1 files changed, 4 insertions, 24 deletions
diff --git a/spec/models/referential_spec.rb b/spec/models/referential_spec.rb index 3a0532c05..867ee4658 100644 --- a/spec/models/referential_spec.rb +++ b/spec/models/referential_spec.rb @@ -127,10 +127,9 @@ describe Referential, :type => :model do end end - # two referentials created at the same time should not be possible when both have the same data - context "when two identical Referentials are created at the same time" do + context "when two identical Referentials are created, only one is saved" do # TODO: Rename js: true to no transaction something - it "only creates one Referential", js: true do + it "works synchronously" do begin workbench = create(:workbench) referential_1 = build( @@ -145,36 +144,17 @@ describe Referential, :type => :model do :referential_metadata, referential: referential_1 ) - # referential_1.metadatas << metadata - # referential_2.metadatas << metadata metadata_2 = metadata_1.dup metadata_2.referential = referential_2 - # puts Referential.all.inspect - # puts referential_1.inspect referential_1.metadatas << metadata_1 referential_2.metadatas << metadata_2 - # thread_1 = Thread.new do - # ActiveRecord::Base.transaction do - referential_1.save - # sleep 10 - # end - # end - - # thread_2 = Thread.new do - # sleep 5 - # ActiveRecord::Base.transaction do - referential_2.save - # end - # end - - # thread_1.join - # thread_2.join + referential_1.save + referential_2.save expect(referential_1).to be_persisted expect(referential_2).not_to be_persisted - ensure Apartment::Tenant.drop(referential_1.slug) if referential_1.persisted? Apartment::Tenant.drop(referential_2.slug) if referential_2.persisted? |
