add guardian fields to the medical releases
This commit is contained in:
@@ -28,6 +28,18 @@ RSpec.feature 'User manages contract templates', type: :feature do
|
||||
expect(page).to have_content('The release template has been created')
|
||||
end
|
||||
|
||||
scenario 'medical release template has a guardian clause field' do
|
||||
visit new_project_contract_template_path(project)
|
||||
|
||||
fill_in 'Name', with: 'My Release Template'
|
||||
select 'Medical Release', from: 'Release type'
|
||||
fill_hidden guardian_clause_field, with: 'Guardian clause text'
|
||||
click_on 'Create Release Template'
|
||||
|
||||
expect(page).to have_content('The release template has been created')
|
||||
expect(ContractTemplate.last.guardian_clause.body.to_s).to match /Guardian clause text/
|
||||
end
|
||||
|
||||
scenario 'preview new talent release template without guardian clause' do
|
||||
visit new_project_contract_template_path(project)
|
||||
select 'Talent Release', from: 'Release type'
|
||||
|
||||
@@ -4,6 +4,125 @@ feature "User managing medical releases" do
|
||||
let(:current_user) { create(:user) }
|
||||
let(:project) { create(:project, members: current_user, account: current_user.primary_account) }
|
||||
|
||||
context "when signed out" do
|
||||
scenario 'creating a release for an adult', js: true do
|
||||
allow(BrayniacAI::Validation).to receive(:create).and_return(double(:validation, valid: true))
|
||||
|
||||
project = create(:project, members: current_user, account: current_user.primary_account)
|
||||
contract_template = create(:contract_template, project: project)
|
||||
|
||||
visit new_account_project_contract_template_medical_release_path(project.account, project, contract_template)
|
||||
|
||||
fill_in person_first_name_field, with: 'Jane'
|
||||
fill_in person_last_name_field, with: 'Doe'
|
||||
fill_in_person_address_fields
|
||||
fill_in person_phone_field, with: '555-555-5555'
|
||||
fill_in person_email_field, with: 'jane.doe@test.com'
|
||||
drop_file Rails.root.join(file_fixture("person_photo.png")), type: :dropzone
|
||||
draw_signature file_fixture("signature.png"), "medical_release_signature_base64"
|
||||
|
||||
expect do
|
||||
click_button submit_release_button
|
||||
end.to change(MedicalRelease, :count).by(1)
|
||||
|
||||
expect(page).to have_content(successful_submission_message)
|
||||
end
|
||||
|
||||
scenario 'creating a release for a minor', js: true do
|
||||
allow(BrayniacAI::Validation).to receive(:create).and_return(double(:validation, valid: true))
|
||||
|
||||
project = create(:project, members: current_user, account: current_user.primary_account)
|
||||
contract_template = create(:contract_template, project: project)
|
||||
|
||||
visit new_account_project_contract_template_medical_release_path(project.account, project, contract_template)
|
||||
|
||||
expect(page).not_to have_content('GUARDIAN INFORMATION')
|
||||
expect(page).not_to have_content('GUARDIAN PHOTO')
|
||||
|
||||
page.check person_is_minor_checkbox
|
||||
expect(page).to have_content('GUARDIAN INFORMATION')
|
||||
expect(page).to have_content('GUARDIAN PHOTO')
|
||||
expect(page).to have_content 'Guardian Email'
|
||||
|
||||
fill_in guardian_first_name_field, with: 'Guardian'
|
||||
fill_in guardian_last_name_field, with: 'Name'
|
||||
fill_in guardian_phone_field, with: '001101'
|
||||
fill_in person_first_name_field, with: 'Jane'
|
||||
fill_in person_last_name_field, with: 'Doe'
|
||||
fill_in_person_address_fields
|
||||
fill_in person_phone_field, with: '555-555-5555'
|
||||
fill_in person_email_field, with: 'jane.doe@test.com'
|
||||
drop_file Rails.root.join(file_fixture("person_photo.png")), type: :dropzone
|
||||
attach_file guardian_photo_field, file_fixture('hemsworth.jpeg'), visible: :all
|
||||
draw_signature file_fixture('signature.png'), 'medical_release_signature_base64'
|
||||
|
||||
fill_in guardian_email_field, with: 'invalid@email'
|
||||
click_button submit_release_button
|
||||
expect(page).to have_content('Guardian email is not an email')
|
||||
|
||||
fill_in guardian_email_field, with: 'valid@email.com'
|
||||
fill_in_guardian_address_fields
|
||||
attach_file guardian_photo_field, file_fixture('hemsworth.jpeg'), visible: :all
|
||||
draw_signature file_fixture('signature.png'), 'medical_release_signature_base64'
|
||||
click_button submit_release_button
|
||||
|
||||
expect(page).to have_content(successful_submission_message)
|
||||
end
|
||||
|
||||
scenario 'creating a release for a minor with two guardians', js: true do
|
||||
allow(BrayniacAI::Validation).to receive(:create).and_return(double(:validation, valid: true))
|
||||
|
||||
project = create(:project, members: current_user, account: current_user.primary_account)
|
||||
contract_template = create(:contract_template, project: project)
|
||||
|
||||
visit new_account_project_contract_template_medical_release_path(project.account, project, contract_template)
|
||||
|
||||
expect(page).not_to have_content('SECOND GUARDIAN INFORMATION')
|
||||
expect(page).not_to have_content('SECOND GUARDIAN PHOTO')
|
||||
|
||||
page.check person_is_minor_checkbox
|
||||
expect(page).to have_content('GUARDIAN INFORMATION')
|
||||
expect(page).to have_content('GUARDIAN PHOTO')
|
||||
expect(page).to have_content 'Guardian Email'
|
||||
|
||||
expect(page).to have_content 'SECOND GUARDIAN INFORMATION'
|
||||
expect(page).to have_content 'SECOND GUARDIAN PHOTO'
|
||||
expect(page).to have_content 'Second Guardian Email'
|
||||
expect(page).to have_content 'Second Guardian Phone'
|
||||
expect(page).to have_content 'Second Guardian Address'
|
||||
|
||||
fill_in guardian_first_name_field, with: 'Guardian'
|
||||
fill_in guardian_last_name_field, with: 'Name'
|
||||
fill_in guardian_phone_field, with: '001101'
|
||||
fill_in person_first_name_field, with: 'Jane'
|
||||
fill_in person_last_name_field, with: 'Doe'
|
||||
fill_in_person_address_fields
|
||||
fill_in person_phone_field, with: '555-555-5555'
|
||||
fill_in person_email_field, with: 'jane.doe@test.com'
|
||||
drop_file Rails.root.join(file_fixture("person_photo.png")), type: :dropzone
|
||||
attach_file guardian_photo_field, file_fixture('hemsworth.jpeg'), visible: :all
|
||||
draw_signature file_fixture('signature.png'), 'medical_release_signature_base64'
|
||||
|
||||
fill_in guardian_email_field, with: 'invalid@email'
|
||||
click_button submit_release_button
|
||||
expect(page).to have_content('Guardian email is not an email')
|
||||
|
||||
fill_in guardian_email_field, with: 'valid@email.com'
|
||||
fill_in_guardian_address_fields
|
||||
attach_file guardian_photo_field, file_fixture('hemsworth.jpeg'), visible: :all
|
||||
draw_signature file_fixture('signature.png'), 'medical_release_signature_base64'
|
||||
|
||||
fill_in guardian_2_first_name_field, with: 'Second'
|
||||
fill_in guardian_2_last_name_field, with: 'Guardian'
|
||||
fill_in guardian_2_phone_field, with: '999'
|
||||
|
||||
click_button submit_release_button
|
||||
|
||||
expect(page).to have_content(successful_submission_message)
|
||||
expect(MedicalRelease.last.guardian_2_first_name).to eq 'Second'
|
||||
end
|
||||
end
|
||||
|
||||
context "when signed in as account manager" do
|
||||
before do
|
||||
sign_in current_user
|
||||
@@ -142,4 +261,111 @@ feature "User managing medical releases" do
|
||||
def view_release_pdf_link_for(release)
|
||||
['Download', href: medical_release_contracts_path(release, format: 'pdf')]
|
||||
end
|
||||
|
||||
def person_first_name_field
|
||||
"medical_release[person_first_name]"
|
||||
end
|
||||
|
||||
def person_last_name_field
|
||||
"medical_release[person_last_name]"
|
||||
end
|
||||
|
||||
def person_email_field
|
||||
"medical_release[person_email]"
|
||||
end
|
||||
|
||||
def person_phone_field
|
||||
"medical_release[person_phone]"
|
||||
end
|
||||
|
||||
def submit_release_button
|
||||
t 'shared.submit_release_short'
|
||||
end
|
||||
|
||||
def successful_submission_message
|
||||
"Your release was successfully submitted. Thank you."
|
||||
end
|
||||
|
||||
def fill_in_person_address_fields
|
||||
fill_in person_address_street1_field, with: "123 Test Lane"
|
||||
fill_in person_address_city_field, with: "New York"
|
||||
fill_in person_address_state_field, with: "NY"
|
||||
fill_in person_address_zip_field, with: '1000'
|
||||
end
|
||||
|
||||
def fill_in_guardian_address_fields
|
||||
fill_in guardian_address_street1_field, with: "124 Test Lane"
|
||||
fill_in guardian_address_city_field, with: "New York"
|
||||
fill_in guardian_address_state_field, with: "NY"
|
||||
fill_in guardian_address_zip_field, with: '1000'
|
||||
end
|
||||
|
||||
def person_address_street1_field
|
||||
t('helpers.label.medical_release.person_address_street1')
|
||||
end
|
||||
|
||||
def person_address_city_field
|
||||
t('helpers.label.medical_release.person_address_city')
|
||||
end
|
||||
|
||||
def person_address_state_field
|
||||
t('helpers.label.medical_release.person_address_state')
|
||||
end
|
||||
|
||||
def person_address_zip_field
|
||||
t('helpers.label.medical_release.person_address_zip')
|
||||
end
|
||||
|
||||
|
||||
def guardian_first_name_field
|
||||
t('helpers.label.medical_release.guardian_first_name')
|
||||
end
|
||||
|
||||
def guardian_last_name_field
|
||||
t('helpers.label.medical_release.guardian_last_name')
|
||||
end
|
||||
|
||||
def guardian_phone_field
|
||||
t('helpers.label.medical_release.guardian_phone')
|
||||
end
|
||||
|
||||
def guardian_email_field
|
||||
t('helpers.label.medical_release.guardian_email')
|
||||
end
|
||||
|
||||
def guardian_address_street1_field
|
||||
t('helpers.label.medical_release.guardian_address_street1')
|
||||
end
|
||||
|
||||
def guardian_address_city_field
|
||||
t('helpers.label.medical_release.guardian_address_city')
|
||||
end
|
||||
|
||||
def guardian_address_state_field
|
||||
t('helpers.label.medical_release.guardian_address_state')
|
||||
end
|
||||
|
||||
def guardian_address_zip_field
|
||||
t('helpers.label.medical_release.guardian_address_zip')
|
||||
end
|
||||
|
||||
def guardian_photo_field
|
||||
'medical_release[guardian_photo]'
|
||||
end
|
||||
|
||||
def person_is_minor_checkbox
|
||||
'medical_release_minor'
|
||||
end
|
||||
|
||||
def guardian_2_first_name_field
|
||||
'Second guardian first name'
|
||||
end
|
||||
|
||||
def guardian_2_last_name_field
|
||||
'Second guardian last name'
|
||||
end
|
||||
|
||||
def guardian_2_phone_field
|
||||
'Second guardian phone'
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user