[ ] 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, Masseur, MasseurProfile, Employee, EmployeeProfile).
Testing link to Company devise model :
[ ] run rails console --sandbox and create a company : Company.create(email: "test@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)
Testing link to Address model :
[ ] create an address to this CompanyProfile : 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 CompanyProfile, so we need the ID of the last address (Address.last) and we link it : CompanyProfile.address_id = the_id_of_the_last_address
[ ] create a second address and link it to the CompanyProfile, to be sure it can have multiple addresses.
Testing link to employees :
[ ] run Employee.create(email: "test2@example.com", password: "123456", password_confirmation: "123456"), then create his profile : EmployeeProfile.new to see the required fields and then create the EmployeeProfile (Employee.create(company_profile_id: the_last_company_profile_id_we_created, . . .)). After doing this two times to test having multiple employees run : tp CompanyProfile.last.employees
Must Have
A complete CompanyProfile model, connected to the Company model made with devise. The CompanyProfile model can get multiple addresses and multiple employees.
Why ? To get a complete set of informations about the Company. This way companies will interract with the employees and masseurs.
How ? Create the model
rails g model CompanyProfile name:string 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 :company, index: true
.Model editing :
validates :name, presence: true
validates :authorized, presence: true
belongs_to :company
has_many :employee_profiles, index: true, dependent: :destroy
has_many :addresses, index: true, dependent: :destroy
has_many :masseur_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, Masseur, MasseurProfile, Employee, EmployeeProfile). Testing link to Company devise model :
rails console --sandbox
and create a company :Company.create(email: "test@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)
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 CompanyProfile, so we need the ID of the last address (Address.last
) and we link it :CompanyProfile.address_id = the_id_of_the_last_address
Employee.create(email: "test2@example.com", password: "123456", password_confirmation: "123456")
, then create his profile :EmployeeProfile.new
to see the required fields and then create the EmployeeProfile (Employee.create(company_profile_id: the_last_company_profile_id_we_created, . . .)
). After doing this two times to test having multiple employees run :tp CompanyProfile.last.employees
Must Have A complete CompanyProfile model, connected to the Company model made with devise. The CompanyProfile model can get multiple addresses and multiple employees.
Reading List