Create relation between Administrateur, Gestionnaire and Procedure
This commit is contained in:
parent
f3d8645426
commit
dc18e7da6f
9 changed files with 35 additions and 5 deletions
|
@ -3,4 +3,7 @@ class Administrateur < ActiveRecord::Base
|
||||||
# :confirmable, :lockable, :timeoutable and :omniauthable
|
# :confirmable, :lockable, :timeoutable and :omniauthable
|
||||||
devise :database_authenticatable, :registerable,
|
devise :database_authenticatable, :registerable,
|
||||||
:recoverable, :rememberable, :trackable, :validatable
|
:recoverable, :rememberable, :trackable, :validatable
|
||||||
|
|
||||||
|
has_many :gestionnaires
|
||||||
|
has_many :procedures
|
||||||
end
|
end
|
||||||
|
|
|
@ -3,4 +3,6 @@ class Gestionnaire < ActiveRecord::Base
|
||||||
# :confirmable, :lockable, :timeoutable and :omniauthable
|
# :confirmable, :lockable, :timeoutable and :omniauthable
|
||||||
devise :database_authenticatable, :registerable,
|
devise :database_authenticatable, :registerable,
|
||||||
:recoverable, :rememberable, :trackable, :validatable
|
:recoverable, :rememberable, :trackable, :validatable
|
||||||
|
|
||||||
|
belongs_to :administrateur
|
||||||
end
|
end
|
||||||
|
|
|
@ -3,6 +3,8 @@ class Procedure < ActiveRecord::Base
|
||||||
has_many :types_de_champ
|
has_many :types_de_champ
|
||||||
has_many :dossiers
|
has_many :dossiers
|
||||||
|
|
||||||
|
belongs_to :administrateur
|
||||||
|
|
||||||
validates :libelle, presence: true, allow_blank: false, allow_nil: false
|
validates :libelle, presence: true, allow_blank: false, allow_nil: false
|
||||||
validates :description, presence: true, allow_blank: false, allow_nil: false
|
validates :description, presence: true, allow_blank: false, allow_nil: false
|
||||||
end
|
end
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
class CreateReferenceAdmninistrateurToProcedure < ActiveRecord::Migration
|
||||||
|
def change
|
||||||
|
add_reference :procedures, :administrateur, references: :procedures
|
||||||
|
end
|
||||||
|
end
|
|
@ -0,0 +1,5 @@
|
||||||
|
class CreateReferenceAdmninistrateurToGestionnaire < ActiveRecord::Migration
|
||||||
|
def change
|
||||||
|
add_reference :gestionnaires, :administrateur, references: :gestionnaires
|
||||||
|
end
|
||||||
|
end
|
|
@ -11,7 +11,7 @@
|
||||||
#
|
#
|
||||||
# It's strongly recommended that you check this file into your version control system.
|
# It's strongly recommended that you check this file into your version control system.
|
||||||
|
|
||||||
ActiveRecord::Schema.define(version: 20151105095431) do
|
ActiveRecord::Schema.define(version: 20151110091451) do
|
||||||
|
|
||||||
# These are extensions that must be enabled in order to support this database
|
# These are extensions that must be enabled in order to support this database
|
||||||
enable_extension "plpgsql"
|
enable_extension "plpgsql"
|
||||||
|
@ -117,6 +117,7 @@ ActiveRecord::Schema.define(version: 20151105095431) do
|
||||||
t.inet "last_sign_in_ip"
|
t.inet "last_sign_in_ip"
|
||||||
t.datetime "created_at"
|
t.datetime "created_at"
|
||||||
t.datetime "updated_at"
|
t.datetime "updated_at"
|
||||||
|
t.integer "administrateur_id"
|
||||||
end
|
end
|
||||||
|
|
||||||
add_index "gestionnaires", ["email"], name: "index_gestionnaires_on_email", unique: true, using: :btree
|
add_index "gestionnaires", ["email"], name: "index_gestionnaires_on_email", unique: true, using: :btree
|
||||||
|
@ -140,6 +141,7 @@ ActiveRecord::Schema.define(version: 20151105095431) do
|
||||||
t.datetime "updated_at", null: false
|
t.datetime "updated_at", null: false
|
||||||
t.boolean "test"
|
t.boolean "test"
|
||||||
t.boolean "use_api_carto", default: false
|
t.boolean "use_api_carto", default: false
|
||||||
|
t.integer "administrateur_id"
|
||||||
end
|
end
|
||||||
|
|
||||||
create_table "types_de_champ", force: :cascade do |t|
|
create_table "types_de_champ", force: :cascade do |t|
|
||||||
|
|
|
@ -15,4 +15,10 @@ describe Administrateur, type: :model do
|
||||||
it { is_expected.to have_db_column(:created_at) }
|
it { is_expected.to have_db_column(:created_at) }
|
||||||
it { is_expected.to have_db_column(:updated_at) }
|
it { is_expected.to have_db_column(:updated_at) }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe 'assocations' do
|
||||||
|
it { is_expected.to have_many(:gestionnaires) }
|
||||||
|
it { is_expected.to have_many(:procedures) }
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
require 'rails_helper'
|
require 'rails_helper'
|
||||||
|
|
||||||
describe Gestionnaire, type: :model do
|
describe Gestionnaire, type: :model do
|
||||||
|
|
||||||
describe 'database column' do
|
describe 'database column' do
|
||||||
it { is_expected.to have_db_column(:email) }
|
it { is_expected.to have_db_column(:email) }
|
||||||
it { is_expected.to have_db_column(:encrypted_password) }
|
it { is_expected.to have_db_column(:encrypted_password) }
|
||||||
|
@ -16,4 +15,8 @@ describe Gestionnaire, type: :model do
|
||||||
it { is_expected.to have_db_column(:created_at) }
|
it { is_expected.to have_db_column(:created_at) }
|
||||||
it { is_expected.to have_db_column(:updated_at) }
|
it { is_expected.to have_db_column(:updated_at) }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe 'association' do
|
||||||
|
it { is_expected.to belong_to(:administrateur) }
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -5,6 +5,8 @@ describe Procedure do
|
||||||
it { is_expected.to have_many(:types_de_piece_justificative) }
|
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(:types_de_champ) }
|
||||||
it { is_expected.to have_many(:dossiers) }
|
it { is_expected.to have_many(:dossiers) }
|
||||||
|
it { is_expected.to belong_to(:administrateur) }
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'attributes' do
|
describe 'attributes' do
|
||||||
|
|
Loading…
Reference in a new issue