aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--app/models/compliance_check_resource.rb5
-rw-r--r--config/initializers/apartment.rb3
-rw-r--r--db/migrate/20170906091136_create_compliance_check_resources.rb13
-rw-r--r--db/schema.rb12
-rw-r--r--spec/factories/compliance_check_resources.rb6
-rw-r--r--spec/models/compliance_check_resource_spec.rb7
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