make all fields required
This commit is contained in:
@@ -18,20 +18,20 @@
|
||||
<%= form.text_field :name, required: true, wrapper_class: "col-12" %>
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<%= form.text_area :description, placeholder: true, wrapper_class: "col-sm-12", rows: 6 %>
|
||||
<%= form.text_area :description, required: true, placeholder: true, wrapper_class: "col-sm-12", rows: 6 %>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<%= card_field_set_tag t(".contact_info.heading") do %>
|
||||
<div class="form-row">
|
||||
<%= form.text_field :person_first_name, wrapper_class: "col-sm-6" %>
|
||||
<%= form.text_field :person_last_name, wrapper_class: "col-sm-6" %>
|
||||
<%= form.phone_field :person_phone, wrapper_class: "col-sm-6" %>
|
||||
<%= form.email_field :person_email, wrapper_class: "col-sm-6" %>
|
||||
<%= form.text_field :person_company, wrapper_class: "col-sm-6" %>
|
||||
<%= form.text_field :person_title, wrapper_class: "col-sm-6" %>
|
||||
<%= form.text_field :person_first_name, required: true, wrapper_class: "col-sm-6" %>
|
||||
<%= form.text_field :person_last_name, required: true, wrapper_class: "col-sm-6" %>
|
||||
<%= form.phone_field :person_phone, required: true, wrapper_class: "col-sm-6" %>
|
||||
<%= form.email_field :person_email, required: true, wrapper_class: "col-sm-6" %>
|
||||
<%= form.text_field :person_company, required: true, wrapper_class: "col-sm-6" %>
|
||||
<%= form.text_field :person_title, required: true, wrapper_class: "col-sm-6" %>
|
||||
</div>
|
||||
<%= render "shared/address_fields", form: form, subject: "person" %>
|
||||
<%= render "shared/address_fields", form: form, subject: "person", required: true %>
|
||||
<% end %>
|
||||
|
||||
<%= card_field_set_tag t(".photo.heading") do %>
|
||||
|
||||
@@ -17,16 +17,12 @@ feature "User managing material releases" do
|
||||
|
||||
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 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
|
||||
@@ -34,17 +30,60 @@ feature "User managing material releases" do
|
||||
|
||||
visit new_account_project_contract_template_material_release_path(project.account, project, contract_template)
|
||||
|
||||
fill_in material_name_field, with: "Pepsi Logo"
|
||||
fill_in person_first_name_field, with: "Jane"
|
||||
fill_in person_last_name_field, with: "Doe"
|
||||
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("Your release was successfully submitted. Thank you.")
|
||||
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
|
||||
|
||||
context "when signed in" do
|
||||
@@ -216,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
|
||||
@@ -224,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
|
||||
@@ -282,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