diff options
| author | Robert | 2017-11-02 08:20:08 +0100 |
|---|---|---|
| committer | Robert | 2017-11-03 14:44:56 +0100 |
| commit | 6c24de52de8481c84e83c414563953cad13e869d (patch) | |
| tree | 4282d67e9cd415c8d47c4bb19740128651e8f34e /spec/models/referential_suite | |
| parent | c3c32ae541cfb018877af964f122b15f6f15b984 (diff) | |
| download | chouette-core-6c24de52de8481c84e83c414563953cad13e869d.tar.bz2 | |
Refs:#4802@0.5h;
CodeReview:
- Exchange fr and en translation files for referential_suites
- Consistent usage of `jeu de donées` and `espace de travail` dans les *fr.yml
Fixes: #4802@0.2h; Replaying former work. To identify spec regression
Step 3: Added validation of reference_suite#new/current
Made all specs pass
Diffstat (limited to 'spec/models/referential_suite')
| -rw-r--r-- | spec/models/referential_suite/referential_suite_current_new_spec.rb | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/spec/models/referential_suite/referential_suite_current_new_spec.rb b/spec/models/referential_suite/referential_suite_current_new_spec.rb new file mode 100644 index 000000000..a910a12da --- /dev/null +++ b/spec/models/referential_suite/referential_suite_current_new_spec.rb @@ -0,0 +1,64 @@ +RSpec.describe ReferentialSuite do + + describe 'Normalisation of current and new towards a proper Referential' do + + subject { create :referential_suite, new: nil, current: nil } + + describe 'valid' do + context 'current and new nil' do + it do + expect_it.to be_valid + end + end + + context 'current nil and new pointing correctly back' do + let( :child ){ create :referential, referential_suite: subject } + it do + subject.new_id = child.id + expect_it.to be_valid + end + end + + context 'new nil and current pointing correctly back' do + let( :child ){ create :referential, referential_suite: subject } + it do + subject.current_id = child.id + expect_it.to be_valid + end + end + + context 'new and current pointing correctly back' do + let( :child ){ create :referential, referential_suite: subject } + let( :sibbling ){ create :referential, referential_suite: subject } + it do + subject.current_id = child.id + subject.new_id = sibbling.id + expect_it.to be_valid + end + end + end + + describe 'invalid' do + context 'current points to incorrect referential(not a child), new is nil' do + let( :current ){ create :referential } + it do + subject.current_id = current.id + expect_it.not_to be_valid + expect( subject.errors.messages[:inconsistent_new] ).to be_nil + expect( subject.errors.messages[:inconsistent_current].first ).to match(%r<#{current.name}>) + end + end + context 'current points to correct referential, new to incorrect referential(not a child)' do + let( :current ){ create :referential, referential_suite: subject } + let( :new ){ create :referential, referential_suite: create( :referential_suite ) } + it do + subject.current_id = current.id + subject.new_id = new.id + expect_it.not_to be_valid + expect( subject.errors.messages[:inconsistent_current] ).to be_nil + expect( subject.errors.messages[:inconsistent_new].first ).to match(%r<#{new.name}>) + end + end + end + end +end |
