Add model ModuleAPICarto

This commit is contained in:
Xavier J 2015-12-07 11:29:34 +01:00
parent 6a471fe867
commit 8130e7d155
6 changed files with 35 additions and 1 deletions

View file

@ -0,0 +1,7 @@
class ModuleAPICarto < ActiveRecord::Base
enum name: {'quartiers_prioritaires' => 'quartiers_prioritaires'}
belongs_to :procedure
validates :name, presence: true, allow_blank: false, allow_nil: false
end

View file

@ -2,6 +2,7 @@ class Procedure < ActiveRecord::Base
has_many :types_de_piece_justificative
has_many :types_de_champ
has_many :dossiers
has_many :module_api_cartos
accepts_nested_attributes_for :types_de_champ,:reject_if => proc { |attributes| attributes['libelle'].blank? }, :allow_destroy => true
accepts_nested_attributes_for :types_de_piece_justificative, :reject_if => proc { |attributes| attributes['libelle'].blank? }, :allow_destroy => true
belongs_to :administrateur

View file

@ -0,0 +1,9 @@
class CreateModuleAPICarto < ActiveRecord::Migration
def change
create_table :module_api_cartos do |t|
t.string :name
end
add_reference :module_api_cartos, :procedure, references: :procedures
end
end

View file

@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20151127103412) do
ActiveRecord::Schema.define(version: 20151207095904) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@ -132,6 +132,11 @@ ActiveRecord::Schema.define(version: 20151127103412) do
add_index "gestionnaires", ["email"], name: "index_gestionnaires_on_email", unique: true, using: :btree
add_index "gestionnaires", ["reset_password_token"], name: "index_gestionnaires_on_reset_password_token", unique: true, using: :btree
create_table "module_api_cartos", force: :cascade do |t|
t.string "name"
t.integer "procedure_id"
end
create_table "pieces_justificatives", force: :cascade do |t|
t.string "content"
t.integer "dossier_id"

View file

@ -0,0 +1,11 @@
require 'spec_helper'
describe ModuleAPICarto do
describe 'assocations' do
it { is_expected.to belong_to(:procedure) }
end
describe 'attributes' do
it { is_expected.to have_db_column(:name) }
end
end

View file

@ -5,6 +5,7 @@ describe Procedure do
it { is_expected.to have_many(:types_de_piece_justificative) }
it { is_expected.to have_many(:types_de_champ) }
it { is_expected.to have_many(:dossiers) }
it { is_expected.to have_many(:module_api_cartos) }
it { is_expected.to belong_to(:administrateur) }
end