diff options
| author | Robert | 2017-09-27 18:43:01 +0200 |
|---|---|---|
| committer | Robert | 2017-09-27 18:43:01 +0200 |
| commit | 55779bdf1737eea5e5ae79bacfebabbc249643af (patch) | |
| tree | 42f0803a9bdba979cb92e0b8d57396d752fdd159 /spec/models | |
| parent | 76b7282eee5be4c5963ae949bae503501cfc8e28 (diff) | |
| parent | 28a352d2c4cba71c796a3504513e0664cec92cb5 (diff) | |
| download | chouette-core-55779bdf1737eea5e5ae79bacfebabbc249643af.tar.bz2 | |
Merge branch 'master' of github.com:af83/stif-boiv
Diffstat (limited to 'spec/models')
| -rw-r--r-- | spec/models/compliance_control_block_spec.rb | 3 | ||||
| -rw-r--r-- | spec/models/compliance_control_set_spec.rb | 2 | ||||
| -rw-r--r-- | spec/models/compliance_control_spec.rb | 37 |
3 files changed, 36 insertions, 6 deletions
diff --git a/spec/models/compliance_control_block_spec.rb b/spec/models/compliance_control_block_spec.rb index 248049b0c..f45ec3d42 100644 --- a/spec/models/compliance_control_block_spec.rb +++ b/spec/models/compliance_control_block_spec.rb @@ -1,9 +1,12 @@ require 'rails_helper' RSpec.describe ComplianceControlBlock, type: :model do + subject { create(:compliance_control_block) } + it 'should have a valid factory' do expect(FactoryGirl.build(:compliance_control_block)).to be_valid end it { should belong_to :compliance_control_set } + it { should belong_to :compliance_control } end diff --git a/spec/models/compliance_control_set_spec.rb b/spec/models/compliance_control_set_spec.rb index ededec5e0..edc684bbc 100644 --- a/spec/models/compliance_control_set_spec.rb +++ b/spec/models/compliance_control_set_spec.rb @@ -6,7 +6,7 @@ RSpec.describe ComplianceControlSet, type: :model do end it { should belong_to :organisation } - it { should have_many :compliance_controls } + it { should have_many(:compliance_controls).dependent(:destroy) } it { should validate_presence_of :name } end diff --git a/spec/models/compliance_control_spec.rb b/spec/models/compliance_control_spec.rb index b00ff4c5a..d7bffb0b2 100644 --- a/spec/models/compliance_control_spec.rb +++ b/spec/models/compliance_control_spec.rb @@ -1,14 +1,41 @@ require 'rails_helper' RSpec.describe ComplianceControl, type: :model do + + let(:compliance_control) { create :compliance_control } + it 'should have a valid factory' do - expect(FactoryGirl.build(:compliance_control)).to be_valid + expect(compliance_control).to be_valid end it { should belong_to :compliance_control_set } - it { should belong_to :compliance_control_block } + it { should have_one(:compliance_control_block).dependent(:destroy) } + + it 'should validate_presence_of criticity' do + compliance_control.criticity = nil + expect(compliance_control).not_to be_valid + end + + it 'should validate_presence_of name' do + compliance_control.name = nil + expect(compliance_control).not_to be_valid + end + + it 'should validate_presence_of code' do + compliance_control.code = nil + expect(compliance_control).not_to be_valid + end + + it 'should validate_presence_of origin_code' do + compliance_control.origin_code = nil + expect(compliance_control).not_to be_valid + end - it { should validate_presence_of :criticity } - it { should validate_presence_of :name } - it { should validate_presence_of :code } + #TODO dont know why the 'shortcuts' below to validates presence dont work + # That's why we dont it 'manually' + # it { should validate_presence_of :criticity } + # it { should validate_presence_of :name } + # it { should validate_presence_of :code } + # it { should validate_presence_of :origin_code } + end |
