Add model ModuleAPICarto
This commit is contained in:
parent
6a471fe867
commit
8130e7d155
6 changed files with 35 additions and 1 deletions
7
app/models/module_api_carto.rb
Normal file
7
app/models/module_api_carto.rb
Normal 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
|
|
@ -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
|
||||
|
|
9
db/migrate/20151207095904_create_module_api_carto.rb
Normal file
9
db/migrate/20151207095904_create_module_api_carto.rb
Normal 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
|
|
@ -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"
|
||||
|
|
11
spec/models/module_api_carto_spec.rb
Normal file
11
spec/models/module_api_carto_spec.rb
Normal 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
|
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in a new issue