diff --git a/app/services/form_builder_service.rb b/app/services/form_builder_service.rb index 33f4a607d..78a0fc77a 100644 --- a/app/services/form_builder_service.rb +++ b/app/services/form_builder_service.rb @@ -3,7 +3,7 @@ class FormBuilderService # charge, so controllers match against PAYMENT_METHOD_PAY_NOW rather than # repeating its label. Keep this the single source of truth for the label. PAYMENT_METHOD_PAY_NOW = "Credit card (now)".freeze - PAYMENT_METHOD_OPTIONS = [ PAYMENT_METHOD_PAY_NOW, "Credit card (later)", "Check", "Other" ].freeze + PAYMENT_METHOD_OPTIONS = [ PAYMENT_METHOD_PAY_NOW, "Credit card (later)", "Check" ].freeze SECTIONS = { person_identifier: { label: "Person identifier", method: :build_person_identifier_fields }, diff --git a/app/views/events/public_registrations/new.html.erb b/app/views/events/public_registrations/new.html.erb index 4d1a80d77..bf473bd62 100644 --- a/app/views/events/public_registrations/new.html.erb +++ b/app/views/events/public_registrations/new.html.erb @@ -122,7 +122,7 @@ <% else %> <% submitted_value = params.dig(:public_registration, :form_fields, field.id.to_s) %> <% if submitted_value.blank? && field.field_identifier == "payment_method" %> - <% submitted_value = @scholarship ? "Other" : FormBuilderService::PAYMENT_METHOD_PAY_NOW %> + <% submitted_value = FormBuilderService::PAYMENT_METHOD_PAY_NOW %> <% end %>
<%= render "events/public_registrations/form_field", field: field, value: submitted_value, label: email_label_overrides[field.field_identifier] %> diff --git a/spec/requests/events/public_registrations_spec.rb b/spec/requests/events/public_registrations_spec.rb index c11cf7ffc..3d46433ff 100644 --- a/spec/requests/events/public_registrations_spec.rb +++ b/spec/requests/events/public_registrations_spec.rb @@ -442,6 +442,38 @@ def post_with_scholarship(scholarship_answer) end end + describe "GET new payment method options" do + # A paid event so the payment section is not stripped from the form. + let(:event) { create(:event, cost_cents: 150_00) } + let!(:payment_method_field) do + field = create(:form_field, form: form, answer_type: :single_select_radio, + field_identifier: "payment_method", name: "Payment method", + required: false) + FormBuilderService::PAYMENT_METHOD_OPTIONS.each do |option_name| + field.form_field_answer_options.create!(answer_option: AnswerOption.find_or_create_by!(name: option_name)) + end + field + end + + it "does not offer 'Other' as a payment method" do + expect(FormBuilderService::PAYMENT_METHOD_OPTIONS).not_to include("Other") + end + + it "renders the remaining payment methods without 'Other'" do + get new_event_public_registration_path(event) + + expect(response.body).to include(%(value="Check")) + expect(response.body).not_to include(%(value="Other")) + end + + it "still shows the payment method (without 'Other') for a scholarship registrant" do + get new_event_public_registration_path(event, scholarship_requested: "true") + + expect(response.body).to include(%(value="Check")) + expect(response.body).not_to include(%(value="Other")) + end + end + describe "GET show" do let(:person) { create(:person) }