Upstream sync
This commit is contained in:
@@ -262,6 +262,93 @@ RSpec.feature 'User manages contract templates', type: :feature do
|
||||
expect(page).to have_content('Active template')
|
||||
end
|
||||
|
||||
scenario 'edit button is visible for not-signed contract template' do
|
||||
create(:contract_template, project: project)
|
||||
|
||||
visit project_contract_templates_path(project)
|
||||
|
||||
expect(page).to have_link(edit_button_label, exact: true, count: 1)
|
||||
end
|
||||
|
||||
scenario 'edit button is not visible for signed contract template' do
|
||||
ct = create(:contract_template, project: project)
|
||||
create(:appearance_release, contract_template: ct)
|
||||
|
||||
visit project_contract_templates_path(project)
|
||||
|
||||
expect(page).to have_link(edit_button_label, exact: true, count: 0)
|
||||
end
|
||||
|
||||
scenario 'duplicate button is visible for not signed contract template' do
|
||||
create(:contract_template, project: project)
|
||||
|
||||
visit project_contract_templates_path(project)
|
||||
|
||||
expect(page).to have_link(duplicate_button_label, exact: true, count: 1)
|
||||
end
|
||||
|
||||
scenario 'duplicate button is visible for signed contract template' do
|
||||
ct = create(:contract_template, project: project)
|
||||
create(:appearance_release, contract_template: ct)
|
||||
|
||||
visit project_contract_templates_path(project)
|
||||
|
||||
expect(page).to have_link(duplicate_button_label, exact: true, count: 1)
|
||||
end
|
||||
|
||||
scenario 'clicking edit button opens edit page for contract template' do
|
||||
ct = create(:contract_template, project: project)
|
||||
|
||||
visit project_contract_templates_path(project)
|
||||
|
||||
expect(page).to have_content ct.name
|
||||
|
||||
expect(page).not_to have_content 'Updated CT'
|
||||
expect(page).not_to have_content 'Medical'
|
||||
|
||||
click_link edit_button_label
|
||||
|
||||
expect(page).to have_content edit_page_heading
|
||||
|
||||
fill_in name_field, with: 'Updated CT'
|
||||
select 'Medical Release', from: 'Release type'
|
||||
fill_in_trix body_field, with: 'Updated legal text'
|
||||
click_on update_contract_template_button_label
|
||||
|
||||
expect(page).to have_content 'Updated CT'
|
||||
expect(page).to have_content 'Medical'
|
||||
end
|
||||
|
||||
scenario 'clicking duplicate button opens edit page for newly created contract template' do
|
||||
ct = create(:contract_template, project: project)
|
||||
|
||||
visit project_contract_templates_path(project)
|
||||
|
||||
expect(page).to have_content ct.name
|
||||
|
||||
expect(page).not_to have_content 'Modified duplicate'
|
||||
expect(page).not_to have_content 'Misc'
|
||||
|
||||
expect do
|
||||
click_link duplicate_button_label
|
||||
end.to change(ContractTemplate, :count).by(1)
|
||||
|
||||
expect(page).to have_content edit_page_heading
|
||||
name_input = find("##{name_field}")
|
||||
expect(name_input.value).to eq duplicate_release_name(ct.name)
|
||||
|
||||
fill_in name_field, with: 'Modified duplicate'
|
||||
select 'Misc Release', from: 'Release type'
|
||||
fill_in_trix body_field, with: 'Legal text for duplicate'
|
||||
click_on update_contract_template_button_label
|
||||
|
||||
expect(page).to have_content 'Modified duplicate'
|
||||
expect(page).to have_content 'Misc'
|
||||
expect(ct.body.id).not_to eq ContractTemplate.last.body.id
|
||||
expect(ct.guardian_clause.id).not_to eq ContractTemplate.last.guardian_clause.id
|
||||
expect(ct.signature_legal_text.id).not_to eq ContractTemplate.last.signature_legal_text.id
|
||||
end
|
||||
|
||||
context 'When the user is associate' do
|
||||
let(:current_user) { create(:user, :associate) }
|
||||
|
||||
@@ -280,6 +367,22 @@ RSpec.feature 'User manages contract templates', type: :feature do
|
||||
expect(page).to have_content schedule_demo
|
||||
expect(page).not_to have_content create_release_template
|
||||
end
|
||||
|
||||
it 'does not show edit button' do
|
||||
create(:contract_template, project: project)
|
||||
|
||||
visit project_contract_templates_path(project)
|
||||
|
||||
expect(page).to have_link(edit_button_label, exact: true, count: 0)
|
||||
end
|
||||
|
||||
it 'does not show duplicate button' do
|
||||
create(:contract_template, project: project)
|
||||
|
||||
visit project_contract_templates_path(project)
|
||||
|
||||
expect(page).to have_link(duplicate_button_label, exact: true, count: 0)
|
||||
end
|
||||
end
|
||||
|
||||
context 'When the user is account manager' do
|
||||
@@ -300,6 +403,40 @@ RSpec.feature 'User manages contract templates', type: :feature do
|
||||
expect(page).to have_content schedule_demo
|
||||
expect(page).to have_content create_release_template
|
||||
end
|
||||
|
||||
it 'shows edit button when contract template is not signed' do
|
||||
create(:contract_template, project: project)
|
||||
|
||||
visit project_contract_templates_path(project)
|
||||
|
||||
expect(page).to have_link(edit_button_label, exact: true, count: 1)
|
||||
end
|
||||
|
||||
it 'does not show edit button when contract template is signed' do
|
||||
ct = create(:contract_template, project: project)
|
||||
create(:appearance_release, contract_template: ct)
|
||||
|
||||
visit project_contract_templates_path(project)
|
||||
|
||||
expect(page).to have_link(edit_button_label, exact: true, count: 0)
|
||||
end
|
||||
|
||||
it 'shows duplicate button when contract template is not signed' do
|
||||
create(:contract_template, project: project)
|
||||
|
||||
visit project_contract_templates_path(project)
|
||||
|
||||
expect(page).to have_link(duplicate_button_label, exact: true, count: 1)
|
||||
end
|
||||
|
||||
it 'shows duplicate button when contract template is signed' do
|
||||
ct = create(:contract_template, project: project)
|
||||
create(:appearance_release, contract_template: ct)
|
||||
|
||||
visit project_contract_templates_path(project)
|
||||
|
||||
expect(page).to have_link(duplicate_button_label, exact: true, count: 1)
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
@@ -355,4 +492,28 @@ RSpec.feature 'User manages contract templates', type: :feature do
|
||||
def signature_legal_text_trix_field
|
||||
'Signature legal text'
|
||||
end
|
||||
|
||||
def edit_button_label
|
||||
t 'contract_templates.contract_template.actions.edit'
|
||||
end
|
||||
|
||||
def duplicate_button_label
|
||||
t 'contract_templates.contract_template.actions.duplicate'
|
||||
end
|
||||
|
||||
def edit_page_heading
|
||||
t 'contract_templates.edit.heading'
|
||||
end
|
||||
|
||||
def name_field
|
||||
'contract_template_name'
|
||||
end
|
||||
|
||||
def update_contract_template_button_label
|
||||
t 'helpers.submit.contract_template.update'
|
||||
end
|
||||
|
||||
def duplicate_release_name(template_name = '')
|
||||
t 'contract_templates.duplicate.name_prefix', template_name: template_name
|
||||
end
|
||||
end
|
||||
|
||||
@@ -260,7 +260,7 @@ feature "User managing medical releases" do
|
||||
expect(pdf_body).to have_content for_office_use_only.upcase
|
||||
expect(pdf_body).to have_content producer_label
|
||||
expect(pdf_body).to have_content production_label
|
||||
expect(pdf_body).to have_content employee_issued_to_label
|
||||
expect(pdf_body).to have_content issued_to_label
|
||||
expect(pdf_body).to have_content issued_by_label
|
||||
expect(pdf_body).to have_content date_issued
|
||||
expect(pdf_body).to have_content 'Big Joe'
|
||||
@@ -282,7 +282,7 @@ feature "User managing medical releases" do
|
||||
expect(pdf_body).not_to have_content for_office_use_only.upcase
|
||||
expect(pdf_body).not_to have_content producer_label
|
||||
expect(pdf_body).not_to have_content production_label
|
||||
expect(pdf_body).not_to have_content employee_issued_to_label
|
||||
expect(pdf_body).not_to have_content issued_to_label
|
||||
expect(pdf_body).not_to have_content issued_by_label
|
||||
expect(pdf_body).not_to have_content date_issued
|
||||
expect(pdf_body).not_to have_content 'Big Joe'
|
||||
@@ -580,8 +580,8 @@ feature "User managing medical releases" do
|
||||
t 'contracts.for_office_use_only.description_labels.production'
|
||||
end
|
||||
|
||||
def employee_issued_to_label
|
||||
t 'contracts.for_office_use_only.description_labels.employee_issued_to'
|
||||
def issued_to_label
|
||||
t 'contracts.for_office_use_only.description_labels.issued_to'
|
||||
end
|
||||
|
||||
def issued_by_label
|
||||
|
||||
Reference in New Issue
Block a user