diff options
| author | Robert | 2018-01-09 12:24:23 +0100 |
|---|---|---|
| committer | Robert | 2018-01-09 12:24:36 +0100 |
| commit | 0e91d206fd8278d0c43c34777f4a585481882b70 (patch) | |
| tree | 9ef641b3455de5d6da2c22ffb702661e4e69ff8d /spec | |
| parent | 7ea0a6079017c561aa8286198bd77b258cb2d240 (diff) | |
| download | chouette-core-0e91d206fd8278d0c43c34777f4a585481882b70.tar.bz2 | |
Refs: #5413@0.5h; Refactoring of #archived_or_finalised?
Diffstat (limited to 'spec')
| -rw-r--r-- | spec/models/referential_spec.rb | 38 |
1 files changed, 29 insertions, 9 deletions
diff --git a/spec/models/referential_spec.rb b/spec/models/referential_spec.rb index 45881333f..6d699f759 100644 --- a/spec/models/referential_spec.rb +++ b/spec/models/referential_spec.rb @@ -125,19 +125,39 @@ describe Referential, :type => :model do end end - context "used in a ReferentialSuite" do - before do - ref.referential_suite_id = 42 + context "to be referential_read_only or not to be referential_read_only" do + let( :referential ){ build_stubbed( :referential ) } + + context "in the beginning" do + it{ expect( referential ).not_to be_referential_read_only } + end + + context "after archivation" do + before{ referential.archived_at = 1.day.ago } + it{ expect( referential ).to be_referential_read_only } end - it "return true to in_referential_suite?" do - expect(ref.in_referential_suite?).to be(true) + context "used in a ReferentialSuite" do + before { referential.referential_suite_id = 42 } + + it{ expect( referential ).to be_referential_read_only } + + it "return true to in_referential_suite?" do + expect(referential).to be_in_referential_suite + end + + it "don't use detect_overlapped_referentials in validation" do + expect(referential).to_not receive(:detect_overlapped_referentials) + expect(referential).to be_valid + end end - it "don't use detect_overlapped_referentials in validation" do - expect(ref).to_not receive(:detect_overlapped_referentials) - ref.valid? + context "archived and finalised" do + before do + referential.archived_at = 1.month.ago + referential.referential_suite_id = 53 + end + it{ expect( referential ).to be_referential_read_only } end end - end |
