From b5f2163c514550f9ac036bd17df6e900db01bcf6 Mon Sep 17 00:00:00 2001 From: Xavier J Date: Fri, 15 Jan 2016 15:28:56 +0100 Subject: [PATCH] Add Cadastre table --- app/models/cadastre.rb | 7 +++++++ .../20160115135025_create_cadastre_table.rb | 18 ++++++++++++++++++ db/schema.rb | 16 +++++++++++++++- spec/models/cadastre_spec.rb | 16 ++++++++++++++++ 4 files changed, 56 insertions(+), 1 deletion(-) create mode 100644 app/models/cadastre.rb create mode 100644 db/migrate/20160115135025_create_cadastre_table.rb create mode 100644 spec/models/cadastre_spec.rb diff --git a/app/models/cadastre.rb b/app/models/cadastre.rb new file mode 100644 index 000000000..57e40f2d5 --- /dev/null +++ b/app/models/cadastre.rb @@ -0,0 +1,7 @@ +class Cadastre < ActiveRecord::Base + belongs_to :dossier + + def geometry + JSON.parse(read_attribute(:geometry)) + end +end diff --git a/db/migrate/20160115135025_create_cadastre_table.rb b/db/migrate/20160115135025_create_cadastre_table.rb new file mode 100644 index 000000000..f69bf0dc2 --- /dev/null +++ b/db/migrate/20160115135025_create_cadastre_table.rb @@ -0,0 +1,18 @@ +class CreateCadastreTable < ActiveRecord::Migration + def change + create_table :cadastres do |t| + t.string :surface_intersection + t.float :surface_parcelle + t.string :numero + t.integer :feuille + t.string :section + t.string :code_dep + t.string :nom_com + t.string :code_com + t.string :code_arr + t.text :geometry + end + + add_reference :cadastres, :dossier, references: :dossiers + end +end diff --git a/db/schema.rb b/db/schema.rb index 1aa5d6a03..14dc16da9 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: 20160106100227) do +ActiveRecord::Schema.define(version: 20160115135025) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -35,6 +35,20 @@ ActiveRecord::Schema.define(version: 20160106100227) do add_index "administrateurs", ["email"], name: "index_administrateurs_on_email", unique: true, using: :btree add_index "administrateurs", ["reset_password_token"], name: "index_administrateurs_on_reset_password_token", unique: true, using: :btree + create_table "cadastres", force: :cascade do |t| + t.string "surface_intersection" + t.float "surface_parcelle" + t.string "numero" + t.integer "feuille" + t.string "section" + t.string "code_dep" + t.string "nom_com" + t.string "code_com" + t.string "code_arr" + t.text "geometry" + t.integer "dossier_id" + end + create_table "cerfas", force: :cascade do |t| t.string "content" t.integer "dossier_id" diff --git a/spec/models/cadastre_spec.rb b/spec/models/cadastre_spec.rb new file mode 100644 index 000000000..fd6c8978f --- /dev/null +++ b/spec/models/cadastre_spec.rb @@ -0,0 +1,16 @@ +require 'spec_helper' + +describe Cadastre do + it { is_expected.to have_db_column(:surface_intersection) } + it { is_expected.to have_db_column(:surface_parcelle) } + it { is_expected.to have_db_column(:numero) } + it { is_expected.to have_db_column(:feuille) } + it { is_expected.to have_db_column(:section) } + it { is_expected.to have_db_column(:code_dep) } + it { is_expected.to have_db_column(:nom_com) } + it { is_expected.to have_db_column(:code_com) } + it { is_expected.to have_db_column(:code_arr) } + it { is_expected.to have_db_column(:geometry) } + + it { is_expected.to belong_to(:dossier) } +end