Skip to content

armgit / sure

Public Imported from GitHub
0

The personal finance app for everyone (by everyone)

Ruby

Make Record payment submit the manual payment form (#4251)

alexcastgonzac80cb81c620
diff --git a/app/views/recurring_occurrences/show.html.erb b/app/views/recurring_occurrences/show.html.erb
index 6597b3f8e0..c485f14ccf 100644
--- a/app/views/recurring_occurrences/show.html.erb
+++ b/app/views/recurring_occurrences/show.html.erb
@@ -270,7 +270,8 @@
min: step %>
<%= form.date_field :paid_on, label: t(".manual_date_label"), value: Date.current %>
</div>
- <%= render DS::Button.new(text: t(".record_payment"), variant: "secondary", full_width: true) %>
+ <%# DS::Button defaults to type="button"; this one has to submit the form. %>
+ <%= render DS::Button.new(text: t(".record_payment"), variant: "secondary", full_width: true, type: "submit") %>
<% end %>
</div>
<% end %>
diff --git a/test/controllers/recurring_occurrences_controller_test.rb b/test/controllers/recurring_occurrences_controller_test.rb
index 8a97d1e029..f576d40232 100644
--- a/test/controllers/recurring_occurrences_controller_test.rb
+++ b/test/controllers/recurring_occurrences_controller_test.rb
@@ -39,6 +39,16 @@ class RecurringOccurrencesControllerTest < ActionDispatch::IntegrationTest
end
end
+ # DS::Button renders type="button" unless told otherwise, so Record payment
+ # did nothing when clicked; only Enter in a field submitted the form.
+ test "record payment submits the manual payment form" do
+ get recurring_occurrence_url(@occurrence), headers: { "Turbo-Frame" => "drawer" }
+
+ assert_select "form[action=?]", recurring_occurrence_allocations_path(@occurrence) do
+ assert_select "button[type=submit]", text: /Record payment/
+ end
+ end
+
# A whole-unit currency steps by 1. With a 0.01 minimum as the step base,
# every whole amount was off-step and the browser refused to submit it.
test "the manual payment steps from its minimum in the bill's currency" do