Skip to content

Commit

Permalink
[#4504] replace Submit for Approval link with Save and Review button
Browse files Browse the repository at this point in the history
  • Loading branch information
danielabar committed Nov 13, 2024
1 parent f1c7438 commit 1f94522
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 34 deletions.
6 changes: 5 additions & 1 deletion app/controllers/partners/profiles_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@ def update
if result.success?
flash[:success] = "Details were successfully updated."
if Flipper.enabled?("partner_step_form")
redirect_to edit_partners_profile_path
if params[:save_review]
redirect_to partners_profile_path
else
redirect_to edit_partners_profile_path
end
else
redirect_to partners_profile_path
end
Expand Down
4 changes: 0 additions & 4 deletions app/helpers/partners_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,6 @@ def humanize_boolean_3state(boolean)
end
end

def show_submit_for_approval?(partner)
partner.invited? || partner.recertification_required?
end

# In step-wise editing of the partner profile, the partial name is used as the section header by default.
# This helper allows overriding the header with a custom display name if needed.
def partial_display_name(partial)
Expand Down
7 changes: 2 additions & 5 deletions app/views/partners/profiles/step/_form_actions.html.erb
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
<%# locals: (f:, partner:) %>

<div class="form-group mt-4 d-flex justify-content-start mx-5">
<%= f.button :submit, "Save Progress", class: 'btn btn-primary mr-2', data: { action: "click->accordion#disableOpenClose" } %>

<% if show_submit_for_approval?(current_partner) %>
<%= link_to 'Submit Profile for Approval', partners_approval_request_path, method: :post, class: 'btn btn-success' %>
<% end %>
<%= f.submit "Save Progress", class: 'btn btn-primary mr-2', data: { action: "click->accordion#disableOpenClose" } %>
<%= f.submit "Save and Review", name: "save_review", class: 'btn btn-success' %>
</div>
17 changes: 0 additions & 17 deletions spec/helpers/partners_helper_spec.rb
Original file line number Diff line number Diff line change
@@ -1,21 +1,4 @@
describe PartnersHelper, type: :helper do
describe "show_submit_for_approval?" do
it "returns true if invited" do
partner = build_stubbed(:partner, status: :invited)
expect(helper.show_submit_for_approval?(partner)).to be_truthy
end

it "returns true if recertification required" do
partner = build_stubbed(:partner, status: :recertification_required)
expect(helper.show_submit_for_approval?(partner)).to be_truthy
end

it "returns false if awaiting review" do
partner = build_stubbed(:partner, status: :awaiting_review)
expect(helper.show_submit_for_approval?(partner)).to be_falsey
end
end

describe "partial_display_name" do
it "returns the humanized name by default" do
expect(helper.partial_display_name("agency_stability")).to eq("Agency stability")
Expand Down
23 changes: 16 additions & 7 deletions spec/system/partners/profile_edit_system_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,10 @@
all("input[type='submit'][value='Save Progress']").last.click
expect(page).to have_css(".alert-success", text: "Details were successfully updated.")

# Submit for Approval
expect(page).to have_link("Submit Profile for Approval", href: partners_approval_request_path)
first(:link, "Submit Profile for Approval").click
# Submit and Review
all("input[type='submit'][value='Save and Review']").last.click
expect(current_path).to eq(partners_profile_path)
expect(page).to have_css(".alert-success", text: "You have submitted your details for approval.")
expect(page).to have_css(".badge", text: "Awaiting Review")
expect(page).to have_css(".alert-success", text: "Details were successfully updated.")
end

it "displays the edit view with sections containing validation errors expanded" do
Expand Down Expand Up @@ -86,8 +84,19 @@
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)

# Submit for Approval is still enabled
expect(page).to have_link("Submit Profile for Approval", href: partners_approval_request_path)
# Try to Submit and Review from error state
all("input[type='submit'][value='Save and Review']").last.click

# 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, executive director 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
end
end

0 comments on commit 1f94522

Please sign in to comment.