[#888] link user to dossier
This commit is contained in:
parent
8c549bf27b
commit
ede01b024b
6 changed files with 19 additions and 3 deletions
|
@ -12,6 +12,7 @@ class Dossier < ActiveRecord::Base
|
|||
has_one :cerfa
|
||||
has_many :pieces_justificatives
|
||||
belongs_to :procedure
|
||||
belongs_to :user
|
||||
has_many :commentaires
|
||||
|
||||
delegate :siren, to: :entreprise
|
||||
|
|
|
@ -3,4 +3,6 @@ class User < ActiveRecord::Base
|
|||
# :confirmable, :lockable, :timeoutable and :omniauthable
|
||||
devise :database_authenticatable, :registerable,
|
||||
:recoverable, :rememberable, :trackable, :validatable
|
||||
|
||||
has_many :dossiers
|
||||
end
|
||||
|
|
6
db/migrate/20150923101000_add_user_to_dossier.rb
Normal file
6
db/migrate/20150923101000_add_user_to_dossier.rb
Normal file
|
@ -0,0 +1,6 @@
|
|||
class AddUserToDossier < ActiveRecord::Migration
|
||||
def change
|
||||
add_reference :dossiers, :user, index: true
|
||||
add_foreign_key :dossiers, :users
|
||||
end
|
||||
end
|
|
@ -11,7 +11,7 @@
|
|||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(version: 20150922141232) do
|
||||
ActiveRecord::Schema.define(version: 20150923101000) do
|
||||
|
||||
# These are extensions that must be enabled in order to support this database
|
||||
enable_extension "plpgsql"
|
||||
|
@ -44,12 +44,14 @@ ActiveRecord::Schema.define(version: 20150922141232) do
|
|||
t.string "montant_aide_demande"
|
||||
t.integer "procedure_id"
|
||||
t.date "date_previsionnelle"
|
||||
t.datetime "created_at"
|
||||
t.datetime "updated_at"
|
||||
t.datetime "created_at", default: '2015-09-22 09:25:29'
|
||||
t.datetime "updated_at", default: '2015-09-22 09:25:29'
|
||||
t.string "state"
|
||||
t.integer "user_id"
|
||||
end
|
||||
|
||||
add_index "dossiers", ["procedure_id"], name: "index_dossiers_on_procedure_id", using: :btree
|
||||
add_index "dossiers", ["user_id"], name: "index_dossiers_on_user_id", using: :btree
|
||||
|
||||
create_table "entreprises", force: :cascade do |t|
|
||||
t.string "siren"
|
||||
|
@ -150,4 +152,5 @@ ActiveRecord::Schema.define(version: 20150922141232) do
|
|||
|
||||
add_foreign_key "cerfas", "dossiers"
|
||||
add_foreign_key "commentaires", "dossiers"
|
||||
add_foreign_key "dossiers", "users"
|
||||
end
|
||||
|
|
|
@ -21,6 +21,7 @@ describe Dossier do
|
|||
it { is_expected.to have_one(:cerfa) }
|
||||
it { is_expected.to have_one(:etablissement) }
|
||||
it { is_expected.to have_one(:entreprise) }
|
||||
it { is_expected.to belong_to(:user) }
|
||||
end
|
||||
|
||||
describe 'delegation' do
|
||||
|
|
|
@ -15,4 +15,7 @@ describe User, type: :model do
|
|||
it { is_expected.to have_db_column(:created_at) }
|
||||
it { is_expected.to have_db_column(:updated_at) }
|
||||
end
|
||||
describe 'associations' do
|
||||
it { is_expected.to have_many(:dossiers) }
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue