diff options
| author | Xinhui | 2017-09-06 11:17:28 +0200 |
|---|---|---|
| committer | Xinhui | 2017-09-06 11:22:20 +0200 |
| commit | 55f142f0a2ef77b88229585225edd561fcf53d92 (patch) | |
| tree | bf89183cd75c649fa79d5e1e9bd88df6298c2ff1 | |
| parent | 64e68de279967fc352f96e414ddb04bd32aa8a74 (diff) | |
| download | chouette-core-55f142f0a2ef77b88229585225edd561fcf53d92.tar.bz2 | |
Model ComplianceCheckResource
Refs #4391
| -rw-r--r-- | app/models/compliance_check_resource.rb | 5 | ||||
| -rw-r--r-- | config/initializers/apartment.rb | 3 | ||||
| -rw-r--r-- | db/migrate/20170906091136_create_compliance_check_resources.rb | 13 | ||||
| -rw-r--r-- | db/schema.rb | 12 | ||||
| -rw-r--r-- | spec/factories/compliance_check_resources.rb | 6 | ||||
| -rw-r--r-- | spec/models/compliance_check_resource_spec.rb | 7 |
6 files changed, 44 insertions, 2 deletions
diff --git a/app/models/compliance_check_resource.rb b/app/models/compliance_check_resource.rb new file mode 100644 index 000000000..7826f00c3 --- /dev/null +++ b/app/models/compliance_check_resource.rb @@ -0,0 +1,5 @@ +class ComplianceCheckResource < ActiveRecord::Base + extend Enumerize + + enumerize :status, in: %w[new successful warning failed] +end diff --git a/config/initializers/apartment.rb b/config/initializers/apartment.rb index faaa5ee81..0d65c3505 100644 --- a/config/initializers/apartment.rb +++ b/config/initializers/apartment.rb @@ -52,7 +52,8 @@ Apartment.configure do |config| 'ComplianceControlBlock', 'ComplianceCheck', 'ComplianceCheckSet', - 'ComplianceCheckBlock' + 'ComplianceCheckBlock', + 'ComplianceCheckResource', ] # use postgres schemas? diff --git a/db/migrate/20170906091136_create_compliance_check_resources.rb b/db/migrate/20170906091136_create_compliance_check_resources.rb new file mode 100644 index 000000000..45713fed5 --- /dev/null +++ b/db/migrate/20170906091136_create_compliance_check_resources.rb @@ -0,0 +1,13 @@ +class CreateComplianceCheckResources < ActiveRecord::Migration + def change + create_table :compliance_check_resources do |t| + t.string :status + t.string :name + t.string :type + t.string :reference + t.hstore :metrics + + t.timestamps null: false + end + end +end diff --git a/db/schema.rb b/db/schema.rb index 1cc3692cf..a1897ac49 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: 20170906084628) do +ActiveRecord::Schema.define(version: 20170906091136) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -155,6 +155,16 @@ ActiveRecord::Schema.define(version: 20170906084628) do add_index "compliance_check_blocks", ["compliance_check_set_id"], name: "index_compliance_check_blocks_on_compliance_check_set_id", using: :btree + create_table "compliance_check_resources", id: :bigserial, force: :cascade do |t| + t.string "status" + t.string "name" + t.string "type" + t.string "reference" + t.hstore "metrics" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end + create_table "compliance_check_sets", id: :bigserial, force: :cascade do |t| t.integer "referential_id" t.integer "compliance_control_set_id" diff --git a/spec/factories/compliance_check_resources.rb b/spec/factories/compliance_check_resources.rb new file mode 100644 index 000000000..813153be2 --- /dev/null +++ b/spec/factories/compliance_check_resources.rb @@ -0,0 +1,6 @@ +FactoryGirl.define do + factory :compliance_check_resource do + status :new + sequence(:name) { |n| "Compliance check resource #{n}" } + end +end diff --git a/spec/models/compliance_check_resource_spec.rb b/spec/models/compliance_check_resource_spec.rb new file mode 100644 index 000000000..a9366bea2 --- /dev/null +++ b/spec/models/compliance_check_resource_spec.rb @@ -0,0 +1,7 @@ +require 'rails_helper' + +RSpec.describe ComplianceCheckResource, type: :model do + it 'should have a valid factory' do + expect(FactoryGirl.build(:compliance_check_resource)).to be_valid + end +end |
