diff options
| author | Robert | 2017-10-03 18:15:05 +0200 | 
|---|---|---|
| committer | Robert | 2017-10-03 23:00:07 +0200 | 
| commit | 71f03bd0c987cdcc5d99d34b19211c730766340e (patch) | |
| tree | 729013ea8a05add8ceff2b5f30e04166a8ca83f0 | |
| parent | 94e383a7db90ee1c68535b1b0123c60e167e68ff (diff) | |
| download | chouette-core-71f03bd0c987cdcc5d99d34b19211c730766340e.tar.bz2 | |
Refs: #4629@0.33h;  Fixes shoulda helper specs for ComplianceControl, safe for name
| -rw-r--r-- | app/models/compliance_control.rb | 5 | ||||
| -rw-r--r-- | spec/models/compliance_control_spec.rb | 29 | 
2 files changed, 10 insertions, 24 deletions
| diff --git a/app/models/compliance_control.rb b/app/models/compliance_control.rb index e859aaba0..40eb7b335 100644 --- a/app/models/compliance_control.rb +++ b/app/models/compliance_control.rb @@ -13,6 +13,11 @@ class ComplianceControl < ActiveRecord::Base    validates :compliance_control_set, presence: true    class << self +    def create *args +      super.tap do | x | +        require 'pry'; binding.pry +      end +    end      def default_criticity; :warning end      def default_code; "" end      def dynamic_attributes diff --git a/spec/models/compliance_control_spec.rb b/spec/models/compliance_control_spec.rb index 50c2b7b8d..641209d4f 100644 --- a/spec/models/compliance_control_spec.rb +++ b/spec/models/compliance_control_spec.rb @@ -9,31 +9,12 @@ RSpec.describe ComplianceControl, type: :model do    it { should belong_to :compliance_control_set }    it { should belong_to :compliance_control_block } -  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 +  it { should validate_presence_of :criticity } +  it 'should validate_presence_of :name' do +    expect( build :compliance_control, name: '' ).to_not be_valid     end - -  it 'should validate_presence_of origin_code' do -    compliance_control.origin_code = nil -    expect(compliance_control).not_to be_valid -  end - -  #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 } +  it { should validate_presence_of :code } +  it { should validate_presence_of :origin_code }  end | 
