aboutsummaryrefslogtreecommitdiffstats
path: root/spec/models/referential
diff options
context:
space:
mode:
authorRobert2017-11-01 20:30:01 +0100
committerRobert2017-11-02 07:52:45 +0100
commitc3c32ae541cfb018877af964f122b15f6f15b984 (patch)
tree8c4b33febc699f4878238bc15d12134e9f089e81 /spec/models/referential
parent28c086c3ec889e3fca806062dc8378ba5f22dfc2 (diff)
downloadchouette-core-c3c32ae541cfb018877af964f122b15f6f15b984.tar.bz2
Refs: #4802@2h; Replaying former work. To identify spec regression
Step 2: Added validation of reference->workbench->organisation consistency Made all specs pass Chased bug #4826
Diffstat (limited to 'spec/models/referential')
-rw-r--r--spec/models/referential/referential_org_through_workspec_spec.rb44
1 files changed, 44 insertions, 0 deletions
diff --git a/spec/models/referential/referential_org_through_workspec_spec.rb b/spec/models/referential/referential_org_through_workspec_spec.rb
new file mode 100644
index 000000000..358a9e5e6
--- /dev/null
+++ b/spec/models/referential/referential_org_through_workspec_spec.rb
@@ -0,0 +1,44 @@
+RSpec.describe Referential do
+
+ describe 'Normalisation between Workbench and Organisation' do
+
+ context 'no workbench' do
+ subject{ create( :referential, workbench: nil ) }
+ it do
+ expect_it.to be_valid
+ end
+ end
+ context 'workbench with same organisation' do
+ let( :workbench ){ create :workbench}
+ subject do
+ create( :referential,
+ workbench: workbench,
+ organisation: workbench.organisation )
+ end
+ it do
+ expect_it.to be_valid
+ end
+ end
+
+ context 'workbench with different organisation' do
+ let( :workbench ){ create :workbench}
+ subject do
+ build( :referential, workbench: workbench)
+ end
+ before do
+ subject.organisation = build_stubbed(:organisation)
+ end
+ it 'is not valid' do
+ expect_it.not_to be_valid
+ end
+ it 'has correct error message' do
+ subject.valid?
+ errors = subject.errors.messages[:inconsistent_organisation]
+ expect(errors.grep(%r<#{subject.organisation.name}>)).not_to be_empty
+ expect(errors.grep(%r<#{workbench.organisation.name}>)).not_to be_empty
+ end
+ end
+
+ end
+
+end