Skip to content

Commit

Permalink
[rubyforgood#4504] PR feedback: remove approval disabled when form in…
Browse files Browse the repository at this point in the history
… error state
  • Loading branch information
danielabar committed Nov 10, 2024
1 parent df73809 commit f1c7438
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 25 deletions.
4 changes: 0 additions & 4 deletions app/helpers/partners_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,6 @@ def show_submit_for_approval?(partner)
partner.invited? || partner.recertification_required?
end

def submit_for_approval_disabled?(partner_profile)
partner_profile.errors.any?
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
6 changes: 1 addition & 5 deletions app/views/partners/profiles/step/_form_actions.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@
<%= f.button :submit, "Save Progress", class: 'btn btn-primary mr-2', data: { action: "click->accordion#disableOpenClose" } %>

<% if show_submit_for_approval?(current_partner) %>
<% if submit_for_approval_disabled?(current_partner.profile) %>
<span class="btn btn-success disabled">Submit Profile for Approval</span>
<% else %>
<%= link_to 'Submit Profile for Approval', partners_approval_request_path, method: :post, class: 'btn btn-success' %>
<% end %>
<%= link_to 'Submit Profile for Approval', partners_approval_request_path, method: :post, class: 'btn btn-success' %>
<% end %>
</div>
14 changes: 0 additions & 14 deletions spec/helpers/partners_helper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,6 @@
end
end

describe "submit_for_approval_disabled?" do
it "returns true if partner profile has errors" do
profile = build_stubbed(:partner_profile)
profile.errors.add(:base, "Some error message")

expect(helper.submit_for_approval_disabled?(profile)).to be_truthy
end

it "returns false if partner profile is valid" do
profile = build_stubbed(:partner_profile)
expect(helper.submit_for_approval_disabled?(profile)).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
4 changes: 2 additions & 2 deletions spec/system/partners/profile_edit_system_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@
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 disabled
expect(page).to have_css("span.btn.btn-success.disabled", text: "Submit Profile for Approval")
# Submit for Approval is still enabled
expect(page).to have_link("Submit Profile for Approval", href: partners_approval_request_path)
end
end
end

0 comments on commit f1c7438

Please sign in to comment.