From 71f03bd0c987cdcc5d99d34b19211c730766340e Mon Sep 17 00:00:00 2001 From: Robert Date: Tue, 3 Oct 2017 18:15:05 +0200 Subject: Refs: #4629@0.33h; Fixes shoulda helper specs for ComplianceControl, safe for name --- app/models/compliance_control.rb | 5 +++++ 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 -- cgit v1.2.3