Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/services/form_builder_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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 },
Expand Down
2 changes: 1 addition & 1 deletion app/views/events/public_registrations/new.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -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 %>
<div class="<%= field.grid_span_class %>">
<%= render "events/public_registrations/form_field", field: field, value: submitted_value, label: email_label_overrides[field.field_identifier] %>
Expand Down
32 changes: 32 additions & 0 deletions spec/requests/events/public_registrations_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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) }

Expand Down