diff options
| author | Robert | 2017-10-10 22:31:59 +0200 |
|---|---|---|
| committer | Robert | 2017-10-12 17:49:51 +0200 |
| commit | 8963eb80e71fb1932250f123367f6830b27fb025 (patch) | |
| tree | 77d80f5d8224c45d3f599bd56ac29f6eab5c3eb4 | |
| parent | 60c26e2e636ad43ab63208886fdc8c72bdca49c7 (diff) | |
| download | chouette-core-8963eb80e71fb1932250f123367f6830b27fb025.tar.bz2 | |
Refs: #4709@0.75h;
DONE:
- Copied all node atts for ComplianceChecks
- Migration of CompliancCheck#criticity int -> string
TODO:
- Check what to do with attribute ComplianceCheck#type
| -rw-r--r-- | app/models/compliance_check.rb | 5 | ||||
| -rw-r--r-- | db/migrate/20171010202716_change_criticity_in_compliance_check_to_string.rb | 5 | ||||
| -rw-r--r-- | db/schema.rb | 4 | ||||
| -rw-r--r-- | lib/compliance_control_set_copier.rb | 2 | ||||
| -rw-r--r-- | spec/factories/compliance_checks.rb | 2 | ||||
| -rw-r--r-- | spec/lib/compliance_control_set_copier_spec.rb | 2 | ||||
| -rw-r--r-- | spec/models/compliance_check_message_spec.rb | 2 |
7 files changed, 14 insertions, 8 deletions
diff --git a/app/models/compliance_check.rb b/app/models/compliance_check.rb index 4c29129b9..0a2576b71 100644 --- a/app/models/compliance_check.rb +++ b/app/models/compliance_check.rb @@ -1,8 +1,9 @@ class ComplianceCheck < ActiveRecord::Base + extend Enumerize belongs_to :compliance_check_set belongs_to :compliance_check_block - - enum criticity: [:info, :warning, :error] + + enumerize :criticity, in: %i(info warning error), scope: true, default: :warning validates :criticity, presence: true validates :name, presence: true validates :code, presence: true diff --git a/db/migrate/20171010202716_change_criticity_in_compliance_check_to_string.rb b/db/migrate/20171010202716_change_criticity_in_compliance_check_to_string.rb new file mode 100644 index 000000000..684c37a06 --- /dev/null +++ b/db/migrate/20171010202716_change_criticity_in_compliance_check_to_string.rb @@ -0,0 +1,5 @@ +class ChangeCriticityInComplianceCheckToString < ActiveRecord::Migration + def change + change_column :compliance_checks, :criticity, :string + end +end diff --git a/db/schema.rb b/db/schema.rb index 7f02a342d..583851ffc 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20171003133042) do +ActiveRecord::Schema.define(version: 20171010202716) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -213,7 +213,7 @@ ActiveRecord::Schema.define(version: 20171003133042) do t.hstore "control_attributes" t.string "name" t.string "code" - t.integer "criticity" + t.string "criticity" t.text "comment" t.datetime "created_at", null: false t.datetime "updated_at", null: false diff --git a/lib/compliance_control_set_copier.rb b/lib/compliance_control_set_copier.rb index a9891ce6d..20518ee0e 100644 --- a/lib/compliance_control_set_copier.rb +++ b/lib/compliance_control_set_copier.rb @@ -59,8 +59,10 @@ class ComplianceControlSetCopier end def make_compliance_check(compliance_control) cck_set.compliance_checks.create( + control_attributes: compliance_control.control_attributes, criticity: compliance_control.criticity, name: name_with_refid(compliance_control.name), + comment: compliance_control.comment, code: compliance_control.code, origin_code: compliance_control.origin_code ).tap do | compliance_check | diff --git a/spec/factories/compliance_checks.rb b/spec/factories/compliance_checks.rb index f9af62c73..b20442c80 100644 --- a/spec/factories/compliance_checks.rb +++ b/spec/factories/compliance_checks.rb @@ -2,7 +2,7 @@ FactoryGirl.define do factory :compliance_check do sequence(:name) { |n| "Compliance check #{n}" } type "Type" - criticity :info + criticity "info" code "code" origin_code "code" comment "Text" diff --git a/spec/lib/compliance_control_set_copier_spec.rb b/spec/lib/compliance_control_set_copier_spec.rb index bdf2494d0..3cecc44d1 100644 --- a/spec/lib/compliance_control_set_copier_spec.rb +++ b/spec/lib/compliance_control_set_copier_spec.rb @@ -92,7 +92,7 @@ RSpec.describe ComplianceControlSetCopier do expect( cck_block.condition_attributes ).to eq(cc_block.condition_attributes) # Control/Check - att_names = %w{ type control_attributes code criticity comment origin_code } + att_names = %w{ control_attributes code criticity comment origin_code } expected = control.attributes.values_at(*att_names) << mk_name(control.name) actual = cck.attributes.values_at(*(att_names << 'name')) diff --git a/spec/models/compliance_check_message_spec.rb b/spec/models/compliance_check_message_spec.rb index 7c8f05953..b55537f95 100644 --- a/spec/models/compliance_check_message_spec.rb +++ b/spec/models/compliance_check_message_spec.rb @@ -1,5 +1,3 @@ -require 'rails_helper' - RSpec.describe ComplianceCheckMessage, type: :model do it 'should have a valid factory' do expect(FactoryGirl.build(:compliance_check_message)).to be_valid |
