Testing the model in console (we need the other following models to be created before these tests : Company, CompanyProfile, Employee, EmployeeProfile).
Testing link to MasseurProfile 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).
Create an address : Address.create(street: "abc",city: "aze", zip_code: "100").
Give an address to the masseur : Masseur.address << Address.last
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 : Masseur.address << Address.last
[ ] if any problem occurs during the tests, refer to the 4th link of the reading list.
Must Have
A complete Address model able to belong to masseurs and companies.
Why ? To get Masseurs and Companies have an address.
How ? Create the model
rails g model Address street:string city:string zip_code: string firm_profile_id:integer masseur_profile_id:integer
Migration editing :
t.belongs_to :company_profile, index: true
.t.belongs_to :masseur_profile, index: true
.Model editing :
validates :city, presence: true
validates :zip_code, presence: true
has_one :company_profile, index: true, dependent: :destroy
has_one :masseur_profile, index: true, dependent: :destroy
Testing the model in console (we need the other following models to be created before these tests : Company, CompanyProfile, Employee, EmployeeProfile). Testing link to MasseurProfile 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)
. Create an address :Address.create(street: "abc",city: "aze", zip_code: "100")
. Give an address to the masseur :Masseur.address << Address.last
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 :Masseur.address << Address.last
[ ] if any problem occurs during the tests, refer to the 4th link of the reading list.
Must Have A complete Address model able to belong to masseurs and companies.
Reading List