diff options
| -rw-r--r-- | Gemfile | 1 | ||||
| -rw-r--r-- | Gemfile.lock | 3 | ||||
| -rw-r--r-- | app/models/compliance_check_message.rb (renamed from app/models/compliance_check_result.rb) | 2 | ||||
| -rw-r--r-- | app/models/compliance_control.rb | 4 | ||||
| -rw-r--r-- | app/models/generic_attribute_min_max.rb | 27 | ||||
| -rw-r--r-- | app/views/imports/index.html.slim | 2 | ||||
| -rw-r--r-- | config/locales/compliance_check_results.en.yml | 3 | ||||
| -rw-r--r-- | config/locales/compliance_check_results.fr.yml | 3 | ||||
| -rw-r--r-- | config/locales/import_messages.en.yml | 5 | ||||
| -rw-r--r-- | config/locales/import_messages.fr.yml | 5 | ||||
| -rw-r--r-- | db/migrate/20170915100935_change_crticity_type_for_compliance_control.rb | 5 | ||||
| -rw-r--r-- | db/migrate/20170918103913_alter_table_compliance_check_result_to_compliance_check_message.rb | 5 | ||||
| -rw-r--r-- | db/schema.rb | 34 | ||||
| -rw-r--r-- | lib/tasks/erd.rake | 4 | ||||
| -rw-r--r-- | spec/factories/compliance_check_messages.rb (renamed from spec/factories/compliance_check_results.rb) | 2 | ||||
| -rw-r--r-- | spec/models/compliance_check_message_spec.rb (renamed from spec/models/compliance_check_result_spec.rb) | 4 | 
16 files changed, 76 insertions, 33 deletions
| @@ -120,6 +120,7 @@ gem 'acts-as-taggable-on', '~> 4.0.0'  gem 'acts_as_list', '~> 0.6.0'  gem 'acts_as_tree', '~> 2.1.0', require: 'acts_as_tree' +gem "hstore_accessor", "~> 1.1"  gem 'rabl'  gem 'carrierwave', '~> 1.0' diff --git a/Gemfile.lock b/Gemfile.lock index 1e2ac3cf8..fef3270a3 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -255,6 +255,8 @@ GEM      hashdiff (0.3.4)      highline (1.7.8)      hike (1.2.3) +    hstore_accessor (1.1.0) +      activerecord (>= 4.0.0)      htmlbeautifier (1.3.1)      httparty (0.14.0)        multi_xml (>= 0.5.2) @@ -602,6 +604,7 @@ DEPENDENCIES    georuby-ext (= 0.0.5)    google-analytics-rails    has_array_of! +  hstore_accessor (~> 1.1)    htmlbeautifier    i18n-tasks    inherited_resources diff --git a/app/models/compliance_check_result.rb b/app/models/compliance_check_message.rb index 161e45189..86899eb15 100644 --- a/app/models/compliance_check_result.rb +++ b/app/models/compliance_check_message.rb @@ -1,4 +1,4 @@ -class ComplianceCheckResult < ActiveRecord::Base +class ComplianceCheckMessage < ActiveRecord::Base    belongs_to :compliance_check    belongs_to :compliance_check_resource  end diff --git a/app/models/compliance_control.rb b/app/models/compliance_control.rb index 685a00706..12ff4737a 100644 --- a/app/models/compliance_control.rb +++ b/app/models/compliance_control.rb @@ -2,9 +2,11 @@ class ComplianceControl < ActiveRecord::Base    belongs_to :compliance_control_set    belongs_to :compliance_control_block -  enum criticity: [:info, :warning, :error] +  extend Enumerize +  enumerize :criticity, in: %i(info warning error), scope: true, default: :info    validates :criticity, presence: true    validates :name, presence: true    validates :code, presence: true +  validates :compliance_control_set, presence: true  end diff --git a/app/models/generic_attribute_min_max.rb b/app/models/generic_attribute_min_max.rb new file mode 100644 index 000000000..e9a127c56 --- /dev/null +++ b/app/models/generic_attribute_min_max.rb @@ -0,0 +1,27 @@ +#module ComplianceControls + +  class GenericAttributeMinMax < ComplianceControl + + +    hstore_accessor :control_attributes, minimum: :integer, maximum: :integer +    #attribute :minimum, type: :integer, optionnal: true +    #attribute :maximum, type: :integer, optionnal: true +    # #attribute :target, type: ModelAttribute + +    @@default_criticity = :warning +    @@default_code = "3-Generic-2" + +    validate :min_max_values +    def min_max_values +      true +    end + +    after_initialize do +      self.name = 'GenericAttributeMinMax' +      self.code = @@default_code +      self.criticity = @@default_criticity +    end + +  end + +#end diff --git a/app/views/imports/index.html.slim b/app/views/imports/index.html.slim index 2203d3584..a6da730f1 100644 --- a/app/views/imports/index.html.slim +++ b/app/views/imports/index.html.slim @@ -24,7 +24,7 @@                ), \                TableBuilderHelper::Column.new( \                  key: :started_at, \ -                attribute: Proc.new { |n| l(n.started_at, format: :long) }, \ +                attribute: Proc.new { |n| l(n.started_at, format: :long) if n.started_at }, \                ), \                TableBuilderHelper::Column.new( \                  key: :name, \ diff --git a/config/locales/compliance_check_results.en.yml b/config/locales/compliance_check_results.en.yml index e0541ab36..cd22aefb1 100644 --- a/config/locales/compliance_check_results.en.yml +++ b/config/locales/compliance_check_results.en.yml @@ -1,3 +1,2 @@  en: -  compliance_check_results: -     +  compliance_check_messages: diff --git a/config/locales/compliance_check_results.fr.yml b/config/locales/compliance_check_results.fr.yml index b3ddc53f2..d3fbf0900 100644 --- a/config/locales/compliance_check_results.fr.yml +++ b/config/locales/compliance_check_results.fr.yml @@ -1,3 +1,2 @@  fr: -  compliance_check_results: -   +  compliance_check_messages: diff --git a/config/locales/import_messages.en.yml b/config/locales/import_messages.en.yml index 1ecdebcd1..e1ef8a078 100644 --- a/config/locales/import_messages.en.yml +++ b/config/locales/import_messages.en.yml @@ -10,7 +10,7 @@ en:        2_netexstif_2_2: "Le fichier calendriers.xml contient une frame nommée %{error_value} non acceptée"        2_netexstif_3_1: "Le fichier %{source_filename} ne contient pas de frame nommée NETEX_OFFRE_LIGNE"        2_netexstif_3_2: "Le fichier %{source_filename} contient une frame nommée %{error_value} non acceptée" -      2_netexstif_3_3: "la frame NETEX_OFFRE_LIGNE du fichier %{source_filename} ne contient pas la frame %{NETEX_STRUCTURE|NETEX_HORAIRE} obligatoire" +      2_netexstif_3_3: "la frame NETEX_OFFRE_LIGNE du fichier %{source_filename} ne contient pas la frame %{error_value} obligatoire"        2_netexstif_3_4: "la frame NETEX_OFFRE_LIGNE du fichier %{source_filename} contient une frame %{error_value} non acceptée"        2_netexstif_4: "%{source_filename}-Ligne %{source_line_number}-Colonne %{source_column_number} : l'identifiant %{source_objectid} de l'objet %{source_label} ne respecte pas la syntaxe [CODESPACE]:%{source_label}:[identifiant Technique]:LOC"        2_netexstif_6: "%{source_filename}-Ligne %{source_line_number}-Colonne %{source_column_number} : l'objet %{source_label} d'identifiant %{source_objectid} a un état de modification interdit : 'delete'" @@ -46,5 +46,6 @@ en:        2_netexstif_servicejourney_4: "%{source_filename}-Ligne %{source_line_number}-Colonne %{source_column_number} , objet ServiceJourney d'identifiant %{source_objectid} : le passingTime de rang %{error_value} fournit des horaires antérieurs au passingTime précédent."        2_netexstif_servicejourneypattern_1: "%{source_filename}-Ligne %{source_line_number}-Colonne %{source_column_number} : l'objet ServiceJourneyPattern d'identifiant %{source_objectid} ne référence pas de Route"        2_netexstif_servicejourneypattern_2: "%{source_filename}-Ligne %{source_line_number}-Colonne %{source_column_number} : l'objet ServiceJourneyPattern d'identifiant %{source_objectid} doit contenir au moins 2 StopPointInJourneyPattern" -      2_netexstif_servicejourneypattern_3: "%{source_filename}-Ligne %{source_line_number}-Colonne %{source_column_number} : l'objet ServiceJourneyPattern d'identifiant %{source_objectid} n'a pas de valeur pour l'attribut ServiceJourneyPatternType" +      2_netexstif_servicejourneypattern_3_1: "%{source_filename}-Ligne %{source_line_number}-Colonne %{source_column_number} : l'objet ServiceJourneyPattern d'identifiant %{source_objectid} n'a pas de valeur pour l'attribut ServiceJourneyPatternType" +      2_netexstif_servicejourneypattern_3_2: "%{source_filename}-Ligne %{source_line_number}-Colonne %{source_column_number} : l'objet ServiceJourneyPattern d'identifiant %{source_objectid} a une valeur interdite %{error_value} pour l'attribut ServiceJourneyPatternType différente de 'passenger'"        2_netexstif_servicejourneypattern_4: "%{source_filename}-Ligne %{source_line_number}-Colonne %{source_column_number}, objet ServiceJourneyPattern d'identifiant %{source_objectid} : les attributs 'order' des StopPointInJourneyPattern ne sont pas croissants." diff --git a/config/locales/import_messages.fr.yml b/config/locales/import_messages.fr.yml index 770cb2c30..8d6a4ee91 100644 --- a/config/locales/import_messages.fr.yml +++ b/config/locales/import_messages.fr.yml @@ -10,7 +10,7 @@ fr:        2_netexstif_2_2: "Le fichier calendriers.xml contient une frame nommée %{error_value} non acceptée"        2_netexstif_3_1: "Le fichier %{source_filename} ne contient pas de frame nommée NETEX_OFFRE_LIGNE"        2_netexstif_3_2: "Le fichier %{source_filename} contient une frame nommée %{error_value} non acceptée" -      2_netexstif_3_3: "la frame NETEX_OFFRE_LIGNE du fichier %{source_filename} ne contient pas la frame %{NETEX_STRUCTURE|NETEX_HORAIRE} obligatoire" +      2_netexstif_3_3: "la frame NETEX_OFFRE_LIGNE du fichier %{source_filename} ne contient pas la frame %{error_value} obligatoire"        2_netexstif_3_4: "la frame NETEX_OFFRE_LIGNE du fichier %{source_filename} contient une frame %{error_value} non acceptée"        2_netexstif_4: "%{source_filename}-Ligne %{source_line_number}-Colonne %{source_column_number} : l'identifiant %{source_objectid} de l'objet %{source_label} ne respecte pas la syntaxe [CODESPACE]:%{source_label}:[identifiant Technique]:LOC"        2_netexstif_6: "%{source_filename}-Ligne %{source_line_number}-Colonne %{source_column_number} : l'objet %{source_label} d'identifiant %{source_objectid} a un état de modification interdit : 'delete'" @@ -46,5 +46,6 @@ fr:        2_netexstif_servicejourney_4: "%{source_filename}-Ligne %{source_line_number}-Colonne %{source_column_number} , objet ServiceJourney d'identifiant %{source_objectid} : le passingTime de rang %{error_value} fournit des horaires antérieurs au passingTime précédent."        2_netexstif_servicejourneypattern_1: "%{source_filename}-Ligne %{source_line_number}-Colonne %{source_column_number} : l'objet ServiceJourneyPattern d'identifiant %{source_objectid} ne référence pas de Route"        2_netexstif_servicejourneypattern_2: "%{source_filename}-Ligne %{source_line_number}-Colonne %{source_column_number} : l'objet ServiceJourneyPattern d'identifiant %{source_objectid} doit contenir au moins 2 StopPointInJourneyPattern" -      2_netexstif_servicejourneypattern_3: "%{source_filename}-Ligne %{source_line_number}-Colonne %{source_column_number} : l'objet ServiceJourneyPattern d'identifiant %{source_objectid} n'a pas de valeur pour l'attribut ServiceJourneyPatternType" +      2_netexstif_servicejourneypattern_3_1: "%{source_filename}-Ligne %{source_line_number}-Colonne %{source_column_number} : l'objet ServiceJourneyPattern d'identifiant %{source_objectid} n'a pas de valeur pour l'attribut ServiceJourneyPatternType" +      2_netexstif_servicejourneypattern_3_2: "%{source_filename}-Ligne %{source_line_number}-Colonne %{source_column_number} : l'objet ServiceJourneyPattern d'identifiant %{source_objectid} a une valeur interdite %{error_value} pour l'attribut ServiceJourneyPatternType différente de 'passenger'"        2_netexstif_servicejourneypattern_4: "%{source_filename}-Ligne %{source_line_number}-Colonne %{source_column_number}, objet ServiceJourneyPattern d'identifiant %{source_objectid} : les attributs 'order' des StopPointInJourneyPattern ne sont pas croissants." diff --git a/db/migrate/20170915100935_change_crticity_type_for_compliance_control.rb b/db/migrate/20170915100935_change_crticity_type_for_compliance_control.rb new file mode 100644 index 000000000..f3e7e7339 --- /dev/null +++ b/db/migrate/20170915100935_change_crticity_type_for_compliance_control.rb @@ -0,0 +1,5 @@ +class ChangeCrticityTypeForComplianceControl < ActiveRecord::Migration +  def change +    change_column :compliance_controls, :criticity, :string +  end +end diff --git a/db/migrate/20170918103913_alter_table_compliance_check_result_to_compliance_check_message.rb b/db/migrate/20170918103913_alter_table_compliance_check_result_to_compliance_check_message.rb new file mode 100644 index 000000000..c0dc6225a --- /dev/null +++ b/db/migrate/20170918103913_alter_table_compliance_check_result_to_compliance_check_message.rb @@ -0,0 +1,5 @@ +class AlterTableComplianceCheckResultToComplianceCheckMessage < ActiveRecord::Migration +  def change +    rename_table :compliance_check_results, :compliance_check_messages +  end +end diff --git a/db/schema.rb b/db/schema.rb index 39162b447..2b62fa7f1 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: 20170913074922) do +ActiveRecord::Schema.define(version: 20170918103913) do    # These are extensions that must be enabled in order to support this database    enable_extension "plpgsql" @@ -155,17 +155,7 @@ ActiveRecord::Schema.define(version: 20170913074922) 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_results", id: :bigserial, force: :cascade do |t| +  create_table "compliance_check_messages", id: :bigserial, force: :cascade do |t|      t.integer  "compliance_check_id"      t.integer  "compliance_check_resource_id"      t.string   "message_key" @@ -175,8 +165,18 @@ ActiveRecord::Schema.define(version: 20170913074922) do      t.datetime "updated_at",                   null: false    end -  add_index "compliance_check_results", ["compliance_check_id"], name: "index_compliance_check_results_on_compliance_check_id", using: :btree -  add_index "compliance_check_results", ["compliance_check_resource_id"], name: "index_compliance_check_results_on_compliance_check_resource_id", using: :btree +  add_index "compliance_check_messages", ["compliance_check_id"], name: "index_compliance_check_messages_on_compliance_check_id", using: :btree +  add_index "compliance_check_messages", ["compliance_check_resource_id"], name: "index_compliance_check_messages_on_compliance_check_resource_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" @@ -237,7 +237,7 @@ ActiveRecord::Schema.define(version: 20170913074922) do      t.json     "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 @@ -966,8 +966,8 @@ ActiveRecord::Schema.define(version: 20170913074922) do    add_foreign_key "access_links", "access_points", name: "aclk_acpt_fkey"    add_foreign_key "api_keys", "organisations"    add_foreign_key "compliance_check_blocks", "compliance_check_sets" -  add_foreign_key "compliance_check_results", "compliance_check_resources" -  add_foreign_key "compliance_check_results", "compliance_checks" +  add_foreign_key "compliance_check_messages", "compliance_check_resources" +  add_foreign_key "compliance_check_messages", "compliance_checks"    add_foreign_key "compliance_check_sets", "compliance_control_sets"    add_foreign_key "compliance_check_sets", "referentials"    add_foreign_key "compliance_check_sets", "workbenches" diff --git a/lib/tasks/erd.rake b/lib/tasks/erd.rake index a9b1a3454..6b79967de 100644 --- a/lib/tasks/erd.rake +++ b/lib/tasks/erd.rake @@ -3,10 +3,10 @@ namespace :generate do    desc "Create model diagrams for Chouette"    task :model_diagram  => :environment do      sh "bundle exec rake erd only='Organisation,Referential,User,Workbench' filename='organisation' title='Organisation'" -    sh "bundle exec rake erd only='Calendar,Referential,Chouette::Line,Chouette::Route,Chouette::JourneyPattern,Chouette::VehicleJourney,Chouette::VehicleJourneyAtStop,Chouette::TimeTable,Chouette::TimeTableDate,Chouette::TimeTablePeriod,Chouette::Footnote,Chouette::Network,Chouette::Company,Chouette::StopPoint,Chouette::StopArea' filename='offer_datas' title='Offer Datas'" +    sh "bundle exec rake erd only='Calendar,Referential,ReferentialMetadata,Chouette::Line,Chouette::Route,Chouette::JourneyPattern,Chouette::VehicleJourney,Chouette::VehicleJourneyAtStop,Chouette::TimeTable,Chouette::TimeTableDate,Chouette::TimeTablePeriod,Chouette::Footnote,Chouette::Network,Chouette::Company,Chouette::StopPoint,Chouette::StopArea' filename='offer_datas' title='Offer Datas'"      sh "bundle exec rake erd only='Organisation,StopAreaReferential,StopAreaReferentialSync,StopAreaReferentialSyncMessage,StopAreaReferentialMembership,LineReferential,LineReferentialSync,LineReferentialSyncMessage,LineReferentialMembership' filename='referentiels_externes' title='Référentiels externes'"      sh "bundle exec rake erd only='NetexImport,Import,WorkbenchImport,ImportResource,ImportMessage' filename='import' title='Import'" -    #sh "bundle exec rake erd only='' filename='validation' title='Validation'" +    sh "bundle exec rake erd only='ComplianceControlSet,ComplianceControlBlock,ComplianceControl,ComplianceCheckSet,ComplianceCheckBlock,ComplianceCheck,ComplianceCheckResource,ComplianceCheckMessage' filename='validation' title='Validation'"      #sh "bundle exec rake erd only='VehicleJourney,VehicleJourneyExport' filename='export' title='Export'"      #sh "bundle exec rake erd only='' filename='intégration' title='Integration'"      #sh "bundle exec rake erd only='' filename='fusion' title='Fusion'" diff --git a/spec/factories/compliance_check_results.rb b/spec/factories/compliance_check_messages.rb index a56d77ce4..1a047a242 100644 --- a/spec/factories/compliance_check_results.rb +++ b/spec/factories/compliance_check_messages.rb @@ -1,5 +1,5 @@  FactoryGirl.define do -  factory :compliance_check_result do +  factory :compliance_check_message do      association :compliance_check      association :compliance_check_resource      message_key "message_key" diff --git a/spec/models/compliance_check_result_spec.rb b/spec/models/compliance_check_message_spec.rb index 95586862f..8b424595e 100644 --- a/spec/models/compliance_check_result_spec.rb +++ b/spec/models/compliance_check_message_spec.rb @@ -1,8 +1,8 @@  require 'rails_helper' -RSpec.describe ComplianceCheckResult, type: :model do +RSpec.describe ComplianceCheckMessage, type: :model do    it 'should have a valid factory' do -    expect(FactoryGirl.build(:compliance_check_result)).to be_valid +    expect(FactoryGirl.build(:compliance_check_message)).to be_valid    end    it { should belong_to :compliance_check } | 
