-
-
Notifications
You must be signed in to change notification settings - Fork 503
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow Organization and Partner Profile edit when associated records h…
…ave validation errors (#4737) * Validate Partner email during update too (not just creation) * Update wording for partner profile's pick-up email validations Starts with lowercase, no . at end * Display errors in Partner when updating Partner Profile instead of failing silently * Display errors in Partner Profile when updating Organization instead of showing 500
- Loading branch information
Showing
6 changed files
with
81 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -43,6 +43,7 @@ | |
end | ||
end | ||
end | ||
|
||
context "when served area client shares pre-exist" do | ||
let!(:original_served_area_1) { create(:partners_served_area, partner_profile: profile, county: county_1, client_share: 51) } | ||
let!(:original_served_area_2) { create(:partners_served_area, partner_profile: profile, county: county_2, client_share: 49) } | ||
|
@@ -93,5 +94,29 @@ | |
end | ||
end | ||
end | ||
|
||
context "when the partner has invalid attributes" do | ||
let(:partner) { profile.partner } | ||
|
||
before do | ||
# Want to have an invalid email on purpose | ||
# rubocop:disable Rails::SkipsModelValidations | ||
partner.update_columns(email: "not/an_email") | ||
# rubocop:enable Rails::SkipsModelValidations | ||
end | ||
|
||
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") | ||
end | ||
|
||
it "doesn't update the partner profile" do | ||
old_pick_up_email = profile.pick_up_email | ||
valid_profile_params = {pick_up_email: "[email protected] "} | ||
PartnerProfileUpdateService.new(profile.partner, partner_params, valid_profile_params).call | ||
expect(profile.pick_up_email).to eq(old_pick_up_email) | ||
end | ||
end | ||
end | ||
end |