Taskme update
This commit is contained in:
@@ -5,21 +5,84 @@ feature "User managing material releases" do
|
||||
let(:project) { create(:project, members: current_user, account: current_user.primary_account) }
|
||||
|
||||
context "when signed out" do
|
||||
scenario "creating a release", js: true do
|
||||
scenario "United States is default country" do
|
||||
contract_template = create(:contract_template, project: project)
|
||||
|
||||
visit new_account_project_contract_template_material_release_path(project.account, project, contract_template)
|
||||
expect(country_field_value).to eq "US"
|
||||
end
|
||||
|
||||
scenario "creating a release without photos", js: true do
|
||||
contract_template = create(:contract_template, project: project)
|
||||
|
||||
visit new_account_project_contract_template_material_release_path(project.account, project, contract_template)
|
||||
|
||||
by "filling out the form" do
|
||||
fill_in material_name_field, with: "Pepsi Logo"
|
||||
fill_in person_first_name_field, with: "Jane"
|
||||
fill_in person_last_name_field, with: "Doe"
|
||||
draw_signature file_fixture("signature.png"), "material_release_signature_base64"
|
||||
end
|
||||
fill_all_fields
|
||||
draw_signature file_fixture("signature.png"), "material_release_signature_base64"
|
||||
|
||||
click_button "I have read and agree to the above"
|
||||
click_button submit_release_button
|
||||
|
||||
expect(page).to have_content("Your release was successfully submitted. Thank you.")
|
||||
expect(page).to have_content success_submit_message
|
||||
end
|
||||
|
||||
scenario "creating a release with photos", js: true do
|
||||
contract_template = create(:contract_template, project: project)
|
||||
|
||||
visit new_account_project_contract_template_material_release_path(project.account, project, contract_template)
|
||||
|
||||
fill_all_fields
|
||||
draw_signature file_fixture("signature.png"), "material_release_signature_base64"
|
||||
drop_file Rails.root.join(file_fixture("material_photo.png")), type: :dropzone
|
||||
|
||||
click_button submit_release_button
|
||||
|
||||
expect(page).to have_content success_submit_message
|
||||
expect(MaterialRelease.last.photos.attached?).to eq true
|
||||
end
|
||||
|
||||
scenario "creating release is possible only after filling all fields", js: true do
|
||||
contract_template = create(:contract_template, project: project)
|
||||
|
||||
visit new_account_project_contract_template_material_release_path(project.account, project, contract_template)
|
||||
|
||||
fill_in material_name_field, with: "Pepsi Logo"
|
||||
expect_failed_client_side_validation
|
||||
|
||||
fill_in material_description_field, with: "Description text"
|
||||
expect_failed_client_side_validation
|
||||
|
||||
fill_in person_first_name_field, with: "Jane"
|
||||
expect_failed_client_side_validation
|
||||
|
||||
fill_in person_last_name_field, with: "Doe"
|
||||
expect_failed_client_side_validation
|
||||
|
||||
fill_in person_phone_field, with: "2229929229"
|
||||
expect_failed_client_side_validation
|
||||
|
||||
fill_in person_email_field, with: "mail@mail.com"
|
||||
expect_failed_client_side_validation
|
||||
|
||||
fill_in person_company_field, with: "Company"
|
||||
expect_failed_client_side_validation
|
||||
|
||||
fill_in person_title_field, with: "Mr."
|
||||
expect_failed_client_side_validation
|
||||
|
||||
fill_in person_address_street1_field, with: "Street 1 address"
|
||||
expect_failed_client_side_validation
|
||||
|
||||
fill_in person_city_field, with: "City"
|
||||
expect_failed_client_side_validation
|
||||
|
||||
fill_in person_state_field, with: "State"
|
||||
expect_failed_client_side_validation
|
||||
|
||||
fill_in person_zip_field, with: "ZIP"
|
||||
draw_signature file_fixture("signature.png"), "material_release_signature_base64"
|
||||
|
||||
click_button submit_release_button
|
||||
expect(page).to have_content success_submit_message
|
||||
end
|
||||
end
|
||||
|
||||
@@ -180,6 +243,10 @@ feature "User managing material releases" do
|
||||
|
||||
private
|
||||
|
||||
def country_field_value
|
||||
find_field("material_release[person_address_country]").value
|
||||
end
|
||||
|
||||
def photos_heading(photos_count = 1)
|
||||
t 'contracts.photos.heading', count: photos_count
|
||||
end
|
||||
@@ -188,6 +255,10 @@ feature "User managing material releases" do
|
||||
"material_release[name]"
|
||||
end
|
||||
|
||||
def material_description_field
|
||||
"material_release[description]"
|
||||
end
|
||||
|
||||
def person_first_name_field
|
||||
"material_release[person_first_name]"
|
||||
end
|
||||
@@ -196,6 +267,38 @@ feature "User managing material releases" do
|
||||
"material_release[person_last_name]"
|
||||
end
|
||||
|
||||
def person_phone_field
|
||||
"material_release[person_phone]"
|
||||
end
|
||||
|
||||
def person_email_field
|
||||
"material_release[person_email]"
|
||||
end
|
||||
|
||||
def person_company_field
|
||||
"material_release[person_company]"
|
||||
end
|
||||
|
||||
def person_title_field
|
||||
"material_release[person_title]"
|
||||
end
|
||||
|
||||
def person_address_street1_field
|
||||
"material_release[person_address_street1]"
|
||||
end
|
||||
|
||||
def person_city_field
|
||||
"material_release[person_address_city]"
|
||||
end
|
||||
|
||||
def person_state_field
|
||||
"material_release[person_address_state]"
|
||||
end
|
||||
|
||||
def person_zip_field
|
||||
"material_release[person_address_zip]"
|
||||
end
|
||||
|
||||
def have_photo(filename)
|
||||
have_selector("img[src*='#{filename}']")
|
||||
end
|
||||
@@ -224,6 +327,10 @@ feature "User managing material releases" do
|
||||
t "helpers.submit.material_release.create"
|
||||
end
|
||||
|
||||
def submit_release_button
|
||||
t 'shared.submit_release_long'
|
||||
end
|
||||
|
||||
def create_release_notice
|
||||
t "material_releases.create.notice"
|
||||
end
|
||||
@@ -250,4 +357,29 @@ feature "User managing material releases" do
|
||||
select "Other", from: "Restriction"
|
||||
fill_in "Describe other restrictions", with: "Test"
|
||||
end
|
||||
|
||||
def fill_all_fields
|
||||
fill_in material_name_field, with: "Pepsi Logo"
|
||||
fill_in material_description_field, with: "Description text"
|
||||
fill_in person_first_name_field, with: "Jane"
|
||||
fill_in person_last_name_field, with: "Doe"
|
||||
fill_in person_phone_field, with: "2229929229"
|
||||
fill_in person_email_field, with: "mail@mail.com"
|
||||
fill_in person_company_field, with: "Company"
|
||||
fill_in person_title_field, with: "Mr."
|
||||
fill_in person_address_street1_field, with: "Street 1 address"
|
||||
fill_in person_city_field, with: "City"
|
||||
fill_in person_state_field, with: "State"
|
||||
fill_in person_zip_field, with: "ZIP"
|
||||
end
|
||||
|
||||
def success_submit_message
|
||||
'Your release was successfully submitted. Thank you.'
|
||||
end
|
||||
|
||||
def expect_failed_client_side_validation
|
||||
draw_signature file_fixture("signature.png"), "material_release_signature_base64"
|
||||
click_button submit_release_button
|
||||
expect(page).not_to have_content success_submit_message
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user