diff options
| author | Robert | 2017-10-03 18:15:05 +0200 | 
|---|---|---|
| committer | Robert | 2017-10-09 15:04:22 +0200 | 
| commit | ef82645b9a0227d7628c0cbac0df1c041ee83396 (patch) | |
| tree | 40c6206757b95b8b7cc489032440c6bbc948366f | |
| parent | e94f6f64a1c75cee5155b86c3d0fa51ac26ac96e (diff) | |
| download | chouette-core-ef82645b9a0227d7628c0cbac0df1c041ee83396.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 33a075e40..947a10719 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 | 
