From e928284c152277109e2baf42fbb703d06ca88f8b Mon Sep 17 00:00:00 2001 From: Xavier J Date: Tue, 24 Nov 2015 10:02:55 +0100 Subject: [PATCH] Add QuartierPrioritaire model and reference at Dossier --- app/models/dossier.rb | 1 + app/models/quartier_prioritaire.rb | 3 +++ .../20151124085333_create_quartier_prioritaire.rb | 12 ++++++++++++ db/schema.rb | 12 ++++++++++-- spec/models/dossier_spec.rb | 1 + spec/models/quartier_prioritaire_spec.rb | 10 ++++++++++ 6 files changed, 37 insertions(+), 2 deletions(-) create mode 100644 app/models/quartier_prioritaire.rb create mode 100644 db/migrate/20151124085333_create_quartier_prioritaire.rb create mode 100644 spec/models/quartier_prioritaire_spec.rb diff --git a/app/models/dossier.rb b/app/models/dossier.rb index cf5462c77..428781566 100644 --- a/app/models/dossier.rb +++ b/app/models/dossier.rb @@ -12,6 +12,7 @@ class Dossier < ActiveRecord::Base has_one :cerfa, dependent: :destroy has_many :pieces_justificatives, dependent: :destroy has_many :champs, dependent: :destroy + has_many :quartier_prioritaires, dependent: :destroy belongs_to :procedure belongs_to :user has_many :commentaires, dependent: :destroy diff --git a/app/models/quartier_prioritaire.rb b/app/models/quartier_prioritaire.rb new file mode 100644 index 000000000..12ad3ec94 --- /dev/null +++ b/app/models/quartier_prioritaire.rb @@ -0,0 +1,3 @@ +class QuartierPrioritaire < ActiveRecord::Base + belongs_to :dossier +end diff --git a/db/migrate/20151124085333_create_quartier_prioritaire.rb b/db/migrate/20151124085333_create_quartier_prioritaire.rb new file mode 100644 index 000000000..f25156894 --- /dev/null +++ b/db/migrate/20151124085333_create_quartier_prioritaire.rb @@ -0,0 +1,12 @@ +class CreateQuartierPrioritaire < ActiveRecord::Migration + def change + create_table :quartier_prioritaires do |t| + t.string :code + t.string :nom + t.string :commune + t.text :geometry + end + + add_reference :quartier_prioritaires, :dossier, references: :dossiers + end +end diff --git a/db/schema.rb b/db/schema.rb index 6776f9f2f..4835e6e14 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: 20151116175817) do +ActiveRecord::Schema.define(version: 20151124085333) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -108,7 +108,7 @@ ActiveRecord::Schema.define(version: 20151116175817) do create_table "exercices", force: :cascade do |t| t.string "ca" t.datetime "dateFinExercice" - t.integer "date_fin_exercice_timestamp" + t.datetime "date_fin_exercice_timestamp" t.integer "etablissement_id" end @@ -152,6 +152,14 @@ ActiveRecord::Schema.define(version: 20151116175817) do t.integer "administrateur_id" end + create_table "quartier_prioritaires", force: :cascade do |t| + t.string "code" + t.string "nom" + t.string "commune" + t.text "geometry" + t.integer "dossier_id" + end + create_table "types_de_champ", force: :cascade do |t| t.string "libelle" t.string "type_champ" diff --git a/spec/models/dossier_spec.rb b/spec/models/dossier_spec.rb index 627e932ce..0d5527dd8 100644 --- a/spec/models/dossier_spec.rb +++ b/spec/models/dossier_spec.rb @@ -18,6 +18,7 @@ describe Dossier do it { is_expected.to have_many(:pieces_justificatives) } it { is_expected.to have_many(:champs) } it { is_expected.to have_many(:commentaires) } + it { is_expected.to have_many(:quartier_prioritaires) } it { is_expected.to have_one(:cerfa) } it { is_expected.to have_one(:etablissement) } it { is_expected.to have_one(:entreprise) } diff --git a/spec/models/quartier_prioritaire_spec.rb b/spec/models/quartier_prioritaire_spec.rb new file mode 100644 index 000000000..50ae8dcb1 --- /dev/null +++ b/spec/models/quartier_prioritaire_spec.rb @@ -0,0 +1,10 @@ +require 'spec_helper' + +describe QuartierPrioritaire do + it { is_expected.to have_db_column(:code) } + it { is_expected.to have_db_column(:nom) } + it { is_expected.to have_db_column(:commune) } + it { is_expected.to have_db_column(:geometry) } + + it { is_expected.to belong_to(:dossier) } +end