aboutsummaryrefslogtreecommitdiffstats
path: root/spec/models/referential_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/models/referential_spec.rb')
-rw-r--r--spec/models/referential_spec.rb43
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