diff options
| author | Luc Donnet | 2018-02-19 11:04:29 +0100 |
|---|---|---|
| committer | Luc Donnet | 2018-02-19 11:04:29 +0100 |
| commit | 7b17deff51545358009cb417cbb9d796565e7540 (patch) | |
| tree | a43a5586ad39d838dd607e600dbc15ff18a58ab3 /spec/models/referential_spec.rb | |
| parent | 89428163fc93a7e09ebb0ca47939f8558afeb5eb (diff) | |
| parent | 5f6008d165df4499319a2121a71842657d6ac3c9 (diff) | |
| download | chouette-core-7b17deff51545358009cb417cbb9d796565e7540.tar.bz2 | |
Merge branch 'master' into 0000-docker
Diffstat (limited to 'spec/models/referential_spec.rb')
| -rw-r--r-- | spec/models/referential_spec.rb | 43 |
1 files changed, 36 insertions, 7 deletions
diff --git a/spec/models/referential_spec.rb b/spec/models/referential_spec.rb index d0b1d6447..6d699f759 100644 --- a/spec/models/referential_spec.rb +++ b/spec/models/referential_spec.rb @@ -1,13 +1,6 @@ -require 'spec_helper' - describe Referential, :type => :model do let(:ref) { create :workbench_referential, metadatas: [create(:referential_metadata)] } - # it "create a rule_parameter_set" do - # referential = create(:referential) - # expect(referential.rule_parameter_sets.size).to eq(1) - # end - it { should have_many(:metadatas) } it { should belong_to(:workbench) } it { should belong_to(:referential_suite) } @@ -131,4 +124,40 @@ describe Referential, :type => :model do end end end + + 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 + + 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 + + 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 |
