diff options
| author | Robert | 2017-09-29 17:01:18 +0200 | 
|---|---|---|
| committer | Robert | 2017-10-02 10:52:07 +0200 | 
| commit | ea6537e2f520ca9abba0ca63c68ee42afe08d872 (patch) | |
| tree | 51fa3272c33e1947e39de5d6a1e4d7cb76efd6e6 | |
| parent | 8f11900221be0837e0ee9717746cd4d952a64794 (diff) | |
| download | chouette-core-ea6537e2f520ca9abba0ca63c68ee42afe08d872.tar.bz2 | |
Refs: #4627@0.15h;
Put old behavior under tests, thusly also showing the motivation of this ticket.
9 files changed, 38 insertions, 4 deletions
| diff --git a/app/models/compliance_control.rb b/app/models/compliance_control.rb index 42f45b6ca..7317b81b8 100644 --- a/app/models/compliance_control.rb +++ b/app/models/compliance_control.rb @@ -3,6 +3,7 @@ class ComplianceControl < ActiveRecord::Base    belongs_to :compliance_control_set    belongs_to :compliance_control_block +  cattr_reader :default_criticity, :default_code    @@default_criticity = :warning    @@default_code = "" diff --git a/app/models/generic_attribute_control/min_max.rb b/app/models/generic_attribute_control/min_max.rb index 6a2e1f284..d18ff6344 100644 --- a/app/models/generic_attribute_control/min_max.rb +++ b/app/models/generic_attribute_control/min_max.rb @@ -2,6 +2,7 @@ module GenericAttributeControl    class MinMax < ComplianceControl      hstore_accessor :control_attributes, minimum: :integer, maximum: :integer +    cattr_reader :default_criticity, :default_code      @@default_criticity = :warning      @@default_code = "3-Generic-2" diff --git a/app/models/generic_attribute_control/pattern.rb b/app/models/generic_attribute_control/pattern.rb index 5b27da54e..9e5a311de 100644 --- a/app/models/generic_attribute_control/pattern.rb +++ b/app/models/generic_attribute_control/pattern.rb @@ -2,6 +2,7 @@ module GenericAttributeControl    class Pattern < ComplianceControl      hstore_accessor :control_attributes, value: :string, pattern: :string +    cattr_reader :default_criticity, :default_code      @@default_criticity = :warning      @@default_code = "3-Generic-3" @@ -10,4 +11,4 @@ module GenericAttributeControl        true      end    end -end
\ No newline at end of file +end diff --git a/app/models/generic_attribute_control/uniqueness.rb b/app/models/generic_attribute_control/uniqueness.rb index 4f1a82083..3efe1deac 100644 --- a/app/models/generic_attribute_control/uniqueness.rb +++ b/app/models/generic_attribute_control/uniqueness.rb @@ -2,6 +2,7 @@ module GenericAttributeControl    class Uniqueness < ComplianceControl      hstore_accessor :control_attributes, name: :string +    cattr_reader :default_criticity, :default_code      @@default_criticity = :warning      @@default_code = "3-Generic-3" @@ -10,4 +11,4 @@ module GenericAttributeControl        true      end    end -end
\ No newline at end of file +end diff --git a/spec/models/compliance_control_spec.rb b/spec/models/compliance_control_spec.rb index 0fc830021..50c2b7b8d 100644 --- a/spec/models/compliance_control_spec.rb +++ b/spec/models/compliance_control_spec.rb @@ -1,5 +1,3 @@ -require 'rails_helper' -  RSpec.describe ComplianceControl, type: :model do    let(:compliance_control) { create :compliance_control } diff --git a/spec/models/generic_attribute_control/min_max_spec.rb b/spec/models/generic_attribute_control/min_max_spec.rb new file mode 100644 index 000000000..5eb8ed74e --- /dev/null +++ b/spec/models/generic_attribute_control/min_max_spec.rb @@ -0,0 +1,8 @@ +RSpec.describe GenericAttributeControl::MinMax do +  context 'class attributes' do  +    it 'are correctly set' do +      expect( described_class.default_criticity ).to eq(:warning) +      expect( described_class.default_code).to eq("3-Generic-2") +    end +  end +end diff --git a/spec/models/generic_attribute_control/parent_class_spec.rb b/spec/models/generic_attribute_control/parent_class_spec.rb new file mode 100644 index 000000000..be60f71be --- /dev/null +++ b/spec/models/generic_attribute_control/parent_class_spec.rb @@ -0,0 +1,8 @@ +RSpec.describe ComplianceControl do +  context 'class attributes' do  +    it 'are correctly set' do +      expect( described_class.default_criticity ).to eq( :warning ) +      expect( described_class.default_code ).to eq( "" ) +    end +  end +end diff --git a/spec/models/generic_attribute_control/pattern_spec.rb b/spec/models/generic_attribute_control/pattern_spec.rb new file mode 100644 index 000000000..d1f2dcb5f --- /dev/null +++ b/spec/models/generic_attribute_control/pattern_spec.rb @@ -0,0 +1,8 @@ +RSpec.describe GenericAttributeControl::Pattern do +  context 'class attributes' do  +    it 'are correctly set' do +      expect( described_class.default_criticity ).to eq( :warning ) +      expect( described_class.default_code ).to eq( "3-Generic-3" ) +    end +  end +end diff --git a/spec/models/generic_attribute_control/uniqueness_spec.rb b/spec/models/generic_attribute_control/uniqueness_spec.rb new file mode 100644 index 000000000..dbf4feff4 --- /dev/null +++ b/spec/models/generic_attribute_control/uniqueness_spec.rb @@ -0,0 +1,8 @@ +RSpec.describe GenericAttributeControl::Uniqueness do +  context 'class attributes' do  +    it 'are correctly set' do +      expect( described_class.default_criticity ).to eq( :warning ) +      expect( described_class.default_code ).to eq( "3-Generic-3" ) +    end +  end +end | 
