+
diff --git a/clock.rb b/clock.rb
index af07f963a0..b7b28be111 100644
--- a/clock.rb
+++ b/clock.rb
@@ -6,7 +6,7 @@
module Clockwork
handler do |job|
- puts "Running #{job}"
+ Rails.logger.info("Running #{job}")
end
DATA_TYPES = %w[Distribution Purchase Donation]
diff --git a/spec/requests/partners/profiles_requests_spec.rb b/spec/requests/partners/profiles_requests_spec.rb
index f4fd5d7ef7..f02942ff9e 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/services/partner_profile_update_service_spec.rb b/spec/services/partner_profile_update_service_spec.rb
index eb3097d669..f0dfcbfb87 100644
--- a/spec/services/partner_profile_update_service_spec.rb
+++ b/spec/services/partner_profile_update_service_spec.rb
@@ -21,11 +21,14 @@
end
context "and there are other errors in the profile" do
+ before do
+ profile.partner.awaiting_review!
+ end
it "does not store the new values and it returns a failure" do
expect(profile.served_areas.size).to eq(0)
result = PartnerProfileUpdateService.new(profile.partner, partner_params, other_incorrect_attributes).call
expect(result.success?).to eq(false)
- expect(result.error.to_s).to include("No social media presence must be checked")
+ expect(result.error.to_s).to include("'No social media presence' must be checked")
profile.reload
expect(profile.served_areas.size).to eq(0)
end
@@ -59,13 +62,16 @@
end
end
context "and there are errors on the profile" do
+ before do
+ profile.partner.awaiting_review!
+ end
it "maintains the old values and returns failure" do
profile.reload
expect(profile.served_areas.size).to eq(2)
- PartnerProfileUpdateService.new(profile.partner, partner_params, other_incorrect_attributes).call
+ result = PartnerProfileUpdateService.new(profile.partner, partner_params, other_incorrect_attributes).call
profile.reload
expect(profile.served_areas.size).to eq(2)
- expect(profile.errors).to_not be_empty
+ expect(result.success?).to eq(false)
end
end
end
@@ -108,7 +114,7 @@
it "returns failure" do
result = PartnerProfileUpdateService.new(partner, partner_params, basic_correct_attributes).call
expect(result.success?).to eq(false)
- expect(result.error.to_s).to include("Partner '#{partner.name}' had error(s) preventing the profile from being updated: Email is invalid")
+ expect(result.error.to_s).to include("Validation failed: Email is invalid")
end
it "doesn't update the partner profile" do
diff --git a/spec/services/partners/request_approval_service_spec.rb b/spec/services/partners/request_approval_service_spec.rb
index 151d27d84d..ff7113cd2e 100644
--- a/spec/services/partners/request_approval_service_spec.rb
+++ b/spec/services/partners/request_approval_service_spec.rb
@@ -31,9 +31,28 @@
end
end
+ context 'when the partner is not yet awaiting approval and mandatory fields are missed' do
+ it 'should return an error re mandatory fields' do
+ partner.update(name: '')
+ partner.profile.update(
+ agency_type: '',
+ address1: '',
+ city: '',
+ state: '',
+ zip_code: '',
+ program_name: '',
+ program_description: ''
+ )
+
+ expect(subject.errors.full_messages)
+ .to include("Name can't be blank, Agency type can't be blank, Address1 can't be blank, City can't be blank, State can't be blank, Zip code can't be blank, Program name can't be blank, Program description can't be blank")
+ end
+ end
+
context 'when the partner is not yet waiting for approval and there is no profile error' do
it 'does not have an error' do
partner.profile.update(website: 'website URL', facebook: '', twitter: '', instagram: '', no_social_media_presence: false)
+ partner.organization.update(one_step_partner_invite: true)
expect(subject.errors.full_messages).to be_empty
end
end
@@ -44,6 +63,7 @@
allow(OrganizationMailer).to receive(:partner_approval_request).with(partner: partner, organization: partner.organization).and_return(fake_mailer)
expect(partner.status).not_to eq(:awaiting_review)
partner.profile.update(website: 'website URL')
+ partner.organization.update(one_step_partner_invite: true)
end
it 'should set the status on the partner record to awaiting_review' do
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..ee46b79ef5 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'
@@ -91,21 +109,4 @@
end
end
end
-
- describe "request approval with invalid details" do
- let(:partner_user) { partner.primary_user }
- 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.'
- 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..69ba548efe 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