Upstream sync
This commit is contained in:
@@ -19,7 +19,7 @@ feature 'User managing appearance releases' do
|
||||
|
||||
fill_in person_first_name_field, with: 'Jane'
|
||||
fill_in person_last_name_field, with: 'Doe'
|
||||
fill_in person_address_field, with: '123 Test Lane, New York, NY 10000'
|
||||
fill_in_person_address_fields
|
||||
fill_in person_phone_field, with: '555-555-5555'
|
||||
fill_in person_email_field, with: 'jane.doe@test.com'
|
||||
fill_in person_date_of_birth, with: '01/01/1999'
|
||||
@@ -52,7 +52,7 @@ feature 'User managing appearance releases' do
|
||||
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_field, with: '123 Test Lane, New York, NY 10000'
|
||||
fill_in_person_address_fields
|
||||
fill_in person_phone_field, with: '555-555-5555'
|
||||
fill_in person_email_field, with: 'jane.doe@test.com'
|
||||
fill_in person_date_of_birth, with: '01/01/1999'
|
||||
@@ -65,7 +65,7 @@ feature 'User managing appearance releases' do
|
||||
expect(page).to have_content('Guardian email is not an email')
|
||||
|
||||
fill_in guardian_email_field, with: 'valid@email.com'
|
||||
fill_in guardian_address_field, with: '123 Test Lane, New York, NY 10000'
|
||||
fill_in_guardian_address_fields
|
||||
attach_file guardian_photo_field, file_fixture('hemsworth.jpeg'), visible: :all
|
||||
draw_signature file_fixture('signature.png'), 'appearance_release_signature_base64'
|
||||
click_button submit_release_button
|
||||
@@ -470,8 +470,20 @@ feature 'User managing appearance releases' do
|
||||
'Guardian email'
|
||||
end
|
||||
|
||||
def guardian_address_field
|
||||
'Guardian address'
|
||||
def guardian_address_street1_field
|
||||
t('helpers.label.appearance_release.guardian_address_street1')
|
||||
end
|
||||
|
||||
def guardian_address_city_field
|
||||
t('helpers.label.appearance_release.guardian_address_city')
|
||||
end
|
||||
|
||||
def guardian_address_state_field
|
||||
t('helpers.label.appearance_release.guardian_address_state')
|
||||
end
|
||||
|
||||
def guardian_address_zip_field
|
||||
t('helpers.label.appearance_release.guardian_address_zip')
|
||||
end
|
||||
|
||||
def guardian_photo_field
|
||||
@@ -490,8 +502,34 @@ feature 'User managing appearance releases' do
|
||||
t('helpers.label.appearance_release.person_last_name')
|
||||
end
|
||||
|
||||
def person_address_field
|
||||
t('helpers.label.appearance_release.person_address')
|
||||
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.appearance_release.person_address_street1')
|
||||
end
|
||||
|
||||
def person_address_city_field
|
||||
t('helpers.label.appearance_release.person_address_city')
|
||||
end
|
||||
|
||||
def person_address_state_field
|
||||
t('helpers.label.appearance_release.person_address_state')
|
||||
end
|
||||
|
||||
def person_address_zip_field
|
||||
t('helpers.label.appearance_release.person_address_zip')
|
||||
end
|
||||
|
||||
def person_email_field
|
||||
|
||||
145
spec/features/user_managing_medical_releases_spec.rb
Normal file
145
spec/features/user_managing_medical_releases_spec.rb
Normal file
@@ -0,0 +1,145 @@
|
||||
require "rails_helper"
|
||||
|
||||
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 in as account manager" do
|
||||
before do
|
||||
sign_in current_user
|
||||
end
|
||||
|
||||
scenario "Download All is visible" do
|
||||
create(:medical_release_with_contract_template, :native, project: project)
|
||||
create(:medical_release_with_contract_template, :non_native, project: project)
|
||||
|
||||
visit project_medical_releases_path(project)
|
||||
|
||||
expect(page).to have_content download_all_button
|
||||
end
|
||||
|
||||
scenario "Download action in Manage menu is visible" do
|
||||
create(:medical_release_with_contract_template, :native, project: project)
|
||||
create(:medical_release_with_contract_template, :non_native, project: project)
|
||||
|
||||
visit project_medical_releases_path(project)
|
||||
|
||||
expect(page).to have_link("Download", exact: true, count: 2)
|
||||
end
|
||||
|
||||
scenario "Downloading PDF of native medical release is possible" do
|
||||
native_release = create(:medical_release_with_contract_template, :native, project: project)
|
||||
|
||||
visit project_medical_releases_path(project)
|
||||
|
||||
click_link *view_release_pdf_link_for(native_release)
|
||||
expect(content_type).to eq('application/pdf')
|
||||
end
|
||||
end
|
||||
|
||||
context "when the user is manager(project manager)" do
|
||||
let(:current_user) { create(:user, :manager) }
|
||||
|
||||
before do
|
||||
sign_in current_user
|
||||
end
|
||||
|
||||
scenario "Download All is not visible" do
|
||||
create(:medical_release_with_contract_template, :native, project: project)
|
||||
create(:medical_release_with_contract_template, :non_native, project: project)
|
||||
|
||||
visit project_medical_releases_path(project)
|
||||
|
||||
expect(page).not_to have_content download_all_button
|
||||
end
|
||||
|
||||
scenario "Download action in Manage menu is not visible" do
|
||||
create(:medical_release_with_contract_template, :native, project: project)
|
||||
create(:medical_release_with_contract_template, :non_native, project: project)
|
||||
|
||||
visit project_medical_releases_path(project)
|
||||
|
||||
expect(page).to have_link("Download", exact: true, count: 0)
|
||||
end
|
||||
|
||||
scenario "Downloading PDF of native medical release is not possible" do
|
||||
native_release = create(:medical_release_with_contract_template, :native, project: project)
|
||||
|
||||
visit project_medical_releases_path(project)
|
||||
|
||||
link = medical_release_contracts_path(native_release, format: 'pdf')
|
||||
expect { visit link }.to raise_exception Pundit::NotAuthorizedError
|
||||
end
|
||||
|
||||
scenario "Downloading PDF of non native medical release is not possible" do
|
||||
non_native_release = create(:medical_release_with_contract_template, :non_native, project: project)
|
||||
|
||||
visit project_medical_releases_path(project)
|
||||
|
||||
link = medical_release_contracts_path(non_native_release, format: 'pdf')
|
||||
expect { visit link }.to raise_exception Pundit::NotAuthorizedError
|
||||
end
|
||||
end
|
||||
|
||||
context "when the user is associate" do
|
||||
let(:current_user) { create(:user, :associate) }
|
||||
|
||||
before do
|
||||
sign_in current_user
|
||||
end
|
||||
|
||||
scenario "Download All is not visible" do
|
||||
create(:medical_release_with_contract_template, :native, project: project)
|
||||
create(:medical_release_with_contract_template, :non_native, project: project)
|
||||
|
||||
visit project_medical_releases_path(project)
|
||||
|
||||
expect(page).not_to have_content download_all_button
|
||||
end
|
||||
|
||||
scenario "Download action in Manage menu is not visible" do
|
||||
create(:medical_release_with_contract_template, :native, project: project)
|
||||
create(:medical_release_with_contract_template, :non_native, project: project)
|
||||
|
||||
visit project_medical_releases_path(project)
|
||||
|
||||
expect(page).to have_link("Download", exact: true, count: 0)
|
||||
end
|
||||
|
||||
scenario "Downloading PDF of native medical release is not possible" do
|
||||
native_release = create(:medical_release_with_contract_template, :native, project: project)
|
||||
|
||||
visit project_medical_releases_path(project)
|
||||
|
||||
link = medical_release_contracts_path(native_release, format: 'pdf')
|
||||
expect { visit link }.to raise_exception Pundit::NotAuthorizedError
|
||||
end
|
||||
|
||||
scenario "Downloading PDF of non native medical release is not possible" do
|
||||
non_native_release = create(:medical_release_with_contract_template, :non_native, project: project)
|
||||
|
||||
visit project_medical_releases_path(project)
|
||||
|
||||
link = medical_release_contracts_path(non_native_release, format: 'pdf')
|
||||
expect { visit link }.to raise_exception Pundit::NotAuthorizedError
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def download_all_button
|
||||
'Download All'
|
||||
end
|
||||
|
||||
def download_action
|
||||
'Download'
|
||||
end
|
||||
|
||||
def manage_button
|
||||
t 'medical_releases.medical_release.actions.manage'
|
||||
end
|
||||
|
||||
def view_release_pdf_link_for(release)
|
||||
['Download', href: medical_release_contracts_path(release, format: 'pdf')]
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user