[ ] in address.rb, check the presence of the following code : belongs_to :company_profile, belongs_to :masseur_profile. If it is not in the file, add it.
Testing the model in console (we need the other following models to be created before these tests : Company, CompanyProfile, Employee, EmployeeProfile and JoinTableMasseurCompany).
Testing link to Masseur devise model :
[ ] run rails console --sandbox and create a masseur : Masseur.create(email: "test@example.com", password: "123456", password_confirmation: "123456"). Then test the MasseurProfile creation : take the ID of the last created masseur Masseur.last, and next, MasseurProfile.create(masseur_id: the_id_of_the_last_created, first_name: "toto", last_name: "test", description: "Text written to fill the description attribute text text text", authorized: true)
Testing link to Address model :
[ ] create an address to this MasseurProfile : type Address.new to see which attributes are required and then Address.create(the_required_attributes). Now, we need to be connect this address to the MasseurProfile, so we need the ID of the last address (Address.last) and we link it : MasseurProfile.address_id = the_id_of_the_last_address
[ ] create a second address and link it to the MasseurProfile, to be sure it can have multiple addresses.
Testing link to CompanyProfile model :
[ ] create a company : Company.create(email: "test2@example.com", password: "123456", password_confirmation: "123456"). Then test the CompanyProfile creation : take the ID of the last created company Company.last, and next, CompanyProfile.create(company_id: the_id_of_the_last_created, name: "test", authorized: true). Now CompanyProfile is working, let's attach multiple companies to the masseur : JoinTableMasseurCompany.create(masseur: MasseurProfile.last, company: CompanyProfile.last, acceptation: nil, slot: nil)
[ ] create 20 MasseurProfile in the seed.rb
Must Have
[ ] A complete MasseurProfile model, connected to the Masseur model made with devise. The MasseurProfile model can get multiple addresses and companies.
[ ] A seed which contains 20 MasseurProfile creations.
Why ? To get a complete set of informations about the Masseur. This way masseurs will interract with companies.
How ? Create the model
rails g model MasseurProfile first_name:string last_name:string description:text pricing:integer authorized:boolean
Migration editing :
t.boolean :authorized
and edit it to gett.boolean :authorized, default: true
.t.boolean
line, add the following line code :t.belongs_to :masseur, index: true
.Model editing :
validates :first_name, presence: true
validates :last_name, presence: true
validates :authorized, presence: true
belongs_to :masseur
has_many :addresses, index: true, dependent: :destroy
has_many :company_profiles, through: :JoinTableMasseurCompany
Address model editing :
belongs_to :company_profile
,belongs_to :masseur_profile
. If it is not in the file, add it.Testing the model in console (we need the other following models to be created before these tests : Company, CompanyProfile, Employee, EmployeeProfile and JoinTableMasseurCompany). Testing link to Masseur devise model :
rails console --sandbox
and create a masseur :Masseur.create(email: "test@example.com", password: "123456", password_confirmation: "123456")
. Then test the MasseurProfile creation : take the ID of the last created masseurMasseur.last
, and next,MasseurProfile.create(masseur_id: the_id_of_the_last_created, first_name: "toto", last_name: "test", description: "Text written to fill the description attribute text text text", authorized: true)
Testing link to Address model :
Address.new
to see which attributes are required and thenAddress.create(the_required_attributes)
. Now, we need to be connect this address to the MasseurProfile, so we need the ID of the last address (Address.last
) and we link it :MasseurProfile.address_id = the_id_of_the_last_address
Testing link to CompanyProfile model :
[ ] create a company :
Company.create(email: "test2@example.com", password: "123456", password_confirmation: "123456")
. Then test the CompanyProfile creation : take the ID of the last created companyCompany.last
, and next,CompanyProfile.create(company_id: the_id_of_the_last_created, name: "test", authorized: true)
. Now CompanyProfile is working, let's attach multiple companies to the masseur :JoinTableMasseurCompany.create(masseur: MasseurProfile.last, company: CompanyProfile.last, acceptation: nil, slot: nil)
[ ] create 20 MasseurProfile in the seed.rb
Must Have
Reading List