+
diff --git a/spec/requests/partners/profiles_requests_spec.rb b/spec/requests/partners/profiles_requests_spec.rb
index f4fd5d7ef7..45af1c91ed 100644
--- a/spec/requests/partners/profiles_requests_spec.rb
+++ b/spec/requests/partners/profiles_requests_spec.rb
@@ -100,11 +100,34 @@
end
context "with no social media" do
+ before do
+ partner.awaiting_review!
+ end
+ let(:params) do
+ {
+ partner: {
+ name: "Partnerdude", profile: {
+ no_social_media_presence: '0',
+ website: "",
+ twitter: "",
+ facebook: "",
+ instagram: "",
+ agency_type: 'OTHER',
+ address1: '123 Main St',
+ city: 'Anytown',
+ state: 'CA',
+ zip_code: '12345',
+ program_name: 'Test Program',
+ program_description: 'Test Description'
+ }
+ }
+ }
+ end
+
it "shows an error" do
- put partners_profile_path(partner,
- partner: {name: "Partnerdude", profile: {no_social_media_presence: false}})
+ put partners_profile_path(partner, params)
expect(response).not_to redirect_to(anything)
- expect(response.body).to include("No social media presence must be checked if you have not provided any of Website, Twitter, Facebook, or Instagram.")
+ expect(response.body).to include("At least one social media field must be filled out or 'No social media presence' must be checked")
end
end
diff --git a/spec/system/partner_system_spec.rb b/spec/system/partner_system_spec.rb
index ff0d6ad839..9ff8732f9c 100644
--- a/spec/system/partner_system_spec.rb
+++ b/spec/system/partner_system_spec.rb
@@ -93,7 +93,7 @@
click_on 'New Partner Agency'
- fill_in 'Name *', with: partner_attributes[:name]
+ fill_in 'Name', with: partner_attributes[:name]
fill_in 'E-mail *', with: partner_attributes[:email]
fill_in 'Quota', with: partner_attributes[:quota]
fill_in 'Notes', with: partner_attributes[:notes]
@@ -125,7 +125,7 @@
assert page.has_content? "Partner Agencies for #{organization.name}"
click_on 'New Partner Agency'
- fill_in 'Name *', with: partner_attributes[:name]
+ fill_in 'Name', with: partner_attributes[:name]
find('button', text: 'Add Partner Agency').click
end
@@ -384,14 +384,6 @@
expect(partner.name).to eq(name)
end
- it "prevents a user from updating a partner with empty name" do
- visit subject
- fill_in "Name", with: ""
- click_button "Update Partner"
-
- expect(page.find(".alert")).to have_content "Something didn't work quite right -- try again?"
- end
-
it "User can uncheck send_reminders" do
visit subject
uncheck 'send_reminders'
@@ -458,12 +450,11 @@
describe "#edit_profile" do
let!(:partner) { create(:partner, name: "Frank") }
- subject { edit_profile_path(partner.id) }
context "when step-wise editing is enabled" do
before do
Flipper.enable(:partner_step_form)
- visit subject
+ visit edit_profile_path(partner.id)
end
it "displays all sections in a closed state by default" do
@@ -531,12 +522,10 @@
# Expect an alert-danger message containing validation errors
expect(page).to have_css(".alert-danger", text: /There is a problem/)
- expect(page).to have_content("No social media presence must be checked if you have not provided any of Website, Twitter, Facebook, or Instagram.")
expect(page).to have_content("Enable child based requests At least one request type must be set")
expect(page).to have_content("Pick up email can't have more than three email addresses")
# Expect media section, pick up person section, and partner settings section to be opened
- expect(page).to have_css("#media_information.accordion-collapse.collapse.show", visible: true)
expect(page).to have_css("#pick_up_person.accordion-collapse.collapse.show", visible: true)
expect(page).to have_css("#partner_settings.accordion-collapse.collapse.show", visible: true)
@@ -545,15 +534,172 @@
# Expect an alert-danger message containing validation errors
expect(page).to have_css(".alert-danger", text: /There is a problem/)
- expect(page).to have_content("No social media presence must be checked if you have not provided any of Website, Twitter, Facebook, or Instagram.")
expect(page).to have_content("Enable child based requests At least one request type must be set")
expect(page).to have_content("Pick up email can't have more than three email addresses")
# Expect media section, pick up person section, and partner settings section to be opened
- expect(page).to have_css("#media_information.accordion-collapse.collapse.show", visible: true)
expect(page).to have_css("#pick_up_person.accordion-collapse.collapse.show", visible: true)
expect(page).to have_css("#partner_settings.accordion-collapse.collapse.show", visible: true)
end
+
+ context "Mandatory fields validation" do
+ subject { all("input[type='submit'][value='Save Progress']").last.click }
+
+ before do
+ find("button[data-bs-target='#agency_information']").click
+ within "#agency_information" do
+ fill_in "Agency Name", with: "Agency1"
+ select "Basic Needs Bank", from: "Agency Type"
+ fill_in "Address (line 1)", with: "123 Main St"
+ fill_in "City", with: "Metropolis"
+ fill_in "State", with: "CA"
+ fill_in "Zip Code", with: "90210"
+ end
+ find("button[data-bs-target='#agency_stability']").click
+ within "#agency_stability" do
+ fill_in "Program Name(s)", with: "Program 1"
+ fill_in "Program Description(s)", with: "Really great program"
+ end
+ end
+
+ context "No social media filled" do
+ before do
+ find("button[data-bs-target='#media_information']").click
+ within "#media_information" do
+ fill_in "Website", with: ""
+ uncheck "No Social Media Presence"
+ end
+ end
+
+ context "partner status is invited" do
+ before do
+ partner.invited!
+ end
+
+ it "displays success message" do
+ expect {
+ subject
+ }.to change { partner.reload.updated_at }
+
+ expect(page).to have_content("Details were successfully updated.")
+ end
+ end
+
+ context "partner status is awaiting_review" do
+ before do
+ partner.awaiting_review!
+ end
+
+ it "displays validation errors" do
+ expect {
+ subject
+ }.not_to change { partner.reload.updated_at }
+ expect(page).to have_content("At least one social media field must be filled out or 'No social media presence' must be checked.")
+ end
+ end
+
+ context "partner status is approved" do
+ before do
+ partner.approved!
+ end
+
+ it "displays validation errors" do
+ expect {
+ subject
+ }.not_to change { partner.reload.updated_at }
+
+ expect(page).to have_content("At least one social media field must be filled out or 'No social media presence' must be checked.")
+ end
+
+ context "partner's organization one_step_partner_invite is true" do
+ before do
+ partner.organization.update!(one_step_partner_invite: true)
+ end
+
+ it "displays success message" do
+ expect {
+ subject
+ }.to change { partner.reload.updated_at }
+
+ expect(page).to have_content("Details were successfully updated.")
+ end
+ end
+ end
+ end
+
+ context "Mandatory fields empty" do
+ before do
+ # find("button[data-bs-target='#agency_information']").click
+ within "#agency_information" do
+ fill_in "Agency Name", with: ""
+ select "", from: "Agency Type"
+ fill_in "Address (line 1)", with: ""
+ fill_in "City", with: ""
+ fill_in "State", with: ""
+ fill_in "Zip Code", with: ""
+ end
+ # find("button[data-bs-target='#agency_stability']").click
+ within "#agency_stability" do
+ fill_in "Program Name(s)", with: ""
+ fill_in "Program Description(s)", with: ""
+ end
+ end
+ context "partner status is invited" do
+ before do
+ partner.invited!
+ end
+
+ it "displays success message" do
+ expect {
+ subject
+ }.to change { partner.reload.updated_at }
+
+ expect(page).to have_content("Details were successfully updated.")
+ end
+ end
+
+ context "partner status is awaiting_review" do
+ before do
+ partner.awaiting_review!
+ end
+
+ it "displays validation errors" do
+ expect {
+ subject
+ }.not_to change { partner.reload.updated_at }
+ expect(page).to have_content("Missing mandatory fields: agency_name, agency_type, address1, city, state, zip_code, program_name, program_description")
+ end
+ end
+
+ context "partner status is approved" do
+ before do
+ partner.approved!
+ end
+
+ it "displays validation errors" do
+ expect {
+ subject
+ }.not_to change { partner.reload.updated_at }
+
+ expect(page).to have_content("Missing mandatory fields: agency_name, agency_type, address1, city, state, zip_code, program_name, program_description")
+ end
+
+ context "partner's organization one_step_partner_invite is true" do
+ before do
+ partner.organization.update!(one_step_partner_invite: true)
+ end
+
+ it "displays success message" do
+ expect {
+ subject
+ }.to change { partner.reload.updated_at }
+
+ expect(page).to have_content("Details were successfully updated.")
+ end
+ end
+ end
+ end
+ end
end
end
diff --git a/spec/system/partners/approval_process_spec.rb b/spec/system/partners/approval_process_spec.rb
index 4b4f6305e7..ff6ef51e03 100644
--- a/spec/system/partners/approval_process_spec.rb
+++ b/spec/system/partners/approval_process_spec.rb
@@ -35,7 +35,16 @@
fill_in 'Executive Director Phone', with: '8889990000'
fill_in 'Executive Director Email', with: 'lorem@example.com'
fill_in 'Primary Contact Phone', with: '8889990000'
+ select "Basic Needs Bank", from: "Agency Type"
+ within "#agency_information" do
+ fill_in 'Address (line 1)', with: '1234 Main St'
+ fill_in 'City', with: 'Anytown'
+ fill_in 'State', with: 'CA'
+ fill_in 'Zip', with: '12345'
+ end
check 'No Social Media Presence'
+ fill_in 'Program Name(s)', with: 'Test Program'
+ fill_in 'Program Description', with: 'This is a test program description.'
click_on 'Update Information'
assert page.has_content? 'Details were successfully updated.'
@@ -59,7 +68,16 @@
fill_in 'Executive Director Name', with: 'Lorem'
fill_in 'Executive Director Phone', with: '8889990000'
fill_in 'Executive Director Email', with: 'lorem@example.com'
+ within "#agency_information" do
+ fill_in 'Address (line 1)', with: '1234 Main St'
+ fill_in 'City', with: 'Anytown'
+ fill_in 'State', with: 'CA'
+ fill_in 'Zip', with: '12345'
+ end
fill_in 'Primary Contact Phone', with: '8889990000'
+ select "Basic Needs Bank", from: "Agency Type"
+ fill_in 'Program Name(s)', with: 'Test Program'
+ fill_in 'Program Description', with: 'This is a test program description.'
check 'No Social Media Presence'
click_on 'Update Information'
@@ -97,15 +115,83 @@
let(:partner) { FactoryBot.create(:partner) }
before do
- partner.profile.update(website: '', facebook: '', twitter: '', instagram: '', no_social_media_presence: false)
login_as(partner_user)
visit partner_user_root_path
click_on 'My Profile'
- all('button', text: 'Submit for Approval').last.click
end
- it "should render an error message", :aggregate_failures do
- assert page.has_content? 'No social media presence must be checked if you have not provided any of Website, Twitter, Facebook, or Instagram.'
+ subject { all('button', text: 'Submit for Approval').last.click }
+
+ context "Social media information is absent" do
+ before do
+ partner.profile.update(website: '', facebook: '', twitter: '', instagram: '', no_social_media_presence: false)
+ end
+
+ context "partner status is invited" do
+ before do
+ partner.update(status: :invited)
+ end
+
+ it "should render an error message", :aggregate_failures do
+ subject
+ assert page.has_content? 'No social media presence must be checked if you have not provided any of Website, Twitter, Facebook, or Instagram.'
+ end
+
+ context "partner's organization one_step_partner_invite is true" do
+ before do
+ partner.organization.update(one_step_partner_invite: true)
+ end
+
+ it "should render an error message about social media presence only", :aggregate_failures do
+ subject
+ assert page.has_content? 'You have submitted your details for approval.'
+ end
+ end
+ end
+
+ context "partner status is awaiting_review" do
+ before do
+ partner.update(status: :awaiting_review)
+ end
+
+ it "should render an error message", :aggregate_failures do
+ subject
+ assert page.has_content? 'This partner has already requested approval.'
+ end
+ end
+ end
+
+ context "Mandatory fields are empty" do
+ before do
+ partner.update(name: '')
+ partner.profile.update(
+ agency_type: '',
+ address1: '',
+ city: '',
+ state: '',
+ zip_code: '',
+ program_name: '',
+ program_description: ''
+ )
+ end
+
+ context "partner status is invited" do
+ before do
+ partner.update(status: :invited)
+ end
+
+ it "should render error messages for each missing field", :aggregate_failures do
+ subject
+ assert page.has_content? "Name can't be blank"
+ assert page.has_content? "Agency type can't be blank"
+ assert page.has_content? "Address1 can't be blank"
+ assert page.has_content? "City can't be blank"
+ assert page.has_content? "State can't be blank"
+ assert page.has_content? "Zip code can't be blank"
+ assert page.has_content? "Program name can't be blank"
+ assert page.has_content? "Program description can't be blank"
+ end
+ end
end
end
end
diff --git a/spec/system/partners/profile_edit_system_spec.rb b/spec/system/partners/profile_edit_system_spec.rb
index 9fbb487aa7..507b1e779c 100644
--- a/spec/system/partners/profile_edit_system_spec.rb
+++ b/spec/system/partners/profile_edit_system_spec.rb
@@ -50,13 +50,6 @@
end
it "displays the edit view with sections containing validation errors expanded" do
- # Open up Media section and clear out website value
- find("button[data-bs-target='#media_information']").click
- within "#media_information" do
- fill_in "Website", with: ""
- uncheck "No Social Media Presence"
- end
-
# Open Pick up person section and fill in 4 email addresses
find("button[data-bs-target='#pick_up_person']").click
within "#pick_up_person" do
@@ -76,12 +69,10 @@
# Expect an alert-danger message containing validation errors
expect(page).to have_css(".alert-danger", text: /There is a problem/)
- expect(page).to have_content("No social media presence must be checked if you have not provided any of Website, Twitter, Facebook, or Instagram.")
expect(page).to have_content("Enable child based requests At least one request type must be set")
expect(page).to have_content("Pick up email can't have more than three email addresses")
- # Expect media section, pick up person section, and partner settings section to be opened
- expect(page).to have_css("#media_information.accordion-collapse.collapse.show", visible: true)
+ # Expect pick up person section, and partner settings section to be opened
expect(page).to have_css("#pick_up_person.accordion-collapse.collapse.show", visible: true)
expect(page).to have_css("#partner_settings.accordion-collapse.collapse.show", visible: true)
@@ -90,12 +81,10 @@
# Expect an alert-danger message containing validation errors
expect(page).to have_css(".alert-danger", text: /There is a problem/)
- expect(page).to have_content("No social media presence must be checked if you have not provided any of Website, Twitter, Facebook, or Instagram.")
expect(page).to have_content("Enable child based requests At least one request type must be set")
expect(page).to have_content("Pick up email can't have more than three email addresses")
- # Expect media section, pick up person section, and partner settings section to be opened
- expect(page).to have_css("#media_information.accordion-collapse.collapse.show", visible: true)
+ # Expect pick up person section, and partner settings section to be opened
expect(page).to have_css("#pick_up_person.accordion-collapse.collapse.show", visible: true)
expect(page).to have_css("#partner_settings.accordion-collapse.collapse.show", visible: true)
end
@@ -303,5 +292,164 @@
expect(page).to have_link("document2.md")
end
end
+
+ context "Mandatory fields validation" do
+ subject { all("input[type='submit'][value='Save Progress']").last.click }
+
+ before do
+ find("button[data-bs-target='#agency_information']").click
+ within "#agency_information" do
+ fill_in "Agency Name", with: "Agency1"
+ select "Basic Needs Bank", from: "Agency Type"
+ fill_in "Address (line 1)", with: "123 Main St"
+ fill_in "City", with: "Metropolis"
+ fill_in "State", with: "CA"
+ fill_in "Zip Code", with: "90210"
+ end
+ find("button[data-bs-target='#agency_stability']").click
+ within "#agency_stability" do
+ fill_in "Program Name(s)", with: "Program 1"
+ fill_in "Program Description(s)", with: "Really great program"
+ end
+ end
+
+ context "No social media filled" do
+ before do
+ find("button[data-bs-target='#media_information']").click
+ within "#media_information" do
+ fill_in "Website", with: ""
+ uncheck "No Social Media Presence"
+ end
+ end
+
+ context "partner status is invited" do
+ before do
+ partner1.invited!
+ end
+
+ it "displays success message" do
+ expect {
+ subject
+ }.to change { partner1.reload.updated_at }
+
+ expect(page).to have_content("Details were successfully updated.")
+ end
+ end
+
+ context "partner status is awaiting_review" do
+ before do
+ partner1.awaiting_review!
+ end
+
+ it "displays validation errors" do
+ expect {
+ subject
+ }.not_to change { partner1.reload.updated_at }
+
+ expect(page).to have_content("At least one social media field must be filled out or 'No social media presence' must be checked.")
+ end
+ end
+
+ context "partner status is approved" do
+ before do
+ partner1.approved!
+ end
+
+ it "displays validation errors" do
+ expect {
+ subject
+ }.not_to change { partner1.reload.updated_at }
+
+ expect(page).to have_content("At least one social media field must be filled out or 'No social media presence' must be checked.")
+ end
+
+ context "partner's organization one_step_partner_invite is true" do
+ before do
+ partner1.organization.update!(one_step_partner_invite: true)
+ end
+
+ it "displays success message" do
+ expect {
+ subject
+ }.to change { partner1.reload.updated_at }
+
+ expect(page).to have_content("Details were successfully updated.")
+ end
+ end
+ end
+ end
+
+ context "Mandatory fields empty" do
+ before do
+ # find("button[data-bs-target='#agency_information']").click
+ within "#agency_information" do
+ fill_in "Agency Name", with: ""
+ select "", from: "Agency Type"
+ fill_in "Address (line 1)", with: ""
+ fill_in "City", with: ""
+ fill_in "State", with: ""
+ fill_in "Zip Code", with: ""
+ end
+ # find("button[data-bs-target='#agency_stability']").click
+ within "#agency_stability" do
+ fill_in "Program Name(s)", with: ""
+ fill_in "Program Description(s)", with: ""
+ end
+ end
+ context "partner status is invited" do
+ before do
+ partner1.invited!
+ end
+
+ it "displays success message" do
+ expect {
+ subject
+ }.to change { partner1.reload.updated_at }
+
+ expect(page).to have_content("Details were successfully updated.")
+ end
+ end
+
+ context "partner status is awaiting_review" do
+ before do
+ partner1.awaiting_review!
+ end
+
+ it "displays validation errors" do
+ expect {
+ subject
+ }.not_to change { partner1.reload.updated_at }
+ expect(page).to have_content("Missing mandatory fields: agency_name, agency_type, address1, city, state, zip_code, program_name, program_description")
+ end
+ end
+
+ context "partner status is approved" do
+ before do
+ partner1.approved!
+ end
+
+ it "displays validation errors" do
+ expect {
+ subject
+ }.not_to change { partner1.reload.updated_at }
+ expect(page).to have_content("Missing mandatory fields: agency_name, agency_type, address1, city, state, zip_code, program_name, program_description")
+ end
+
+ context "partner's organization one_step_partner_invite is true" do
+ before do
+ partner1.organization.update!(one_step_partner_invite: true)
+ end
+
+ it "displays success message" do
+ expect {
+ subject
+ }.to change { partner1.reload.updated_at }
+
+ expect(page).to have_content("Details were successfully updated.")
+ end
+ end
+ end
+ end
+ end
end
end