Skip to content

Commit

Permalink
[finishes #187093497 #187226906] Added test for missing id in donate_…
Browse files Browse the repository at this point in the history
…to_fund route. Current theater apps give HTTP ERROR 404 when missing fund code, decided to make id optional and use default fund if missing id
  • Loading branch information
MayZamudio committed Mar 19, 2024
1 parent 59c6e78 commit 0f77ae4
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
1 change: 1 addition & 0 deletions app/controllers/store_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ def subscribe
def donate_to_fund_redirect
# redirect donate_to_fund route to quickdonate for potential printed material with donate_to_fund url
fund_code = params[:id]
fund_code = Donation.default_code.code if fund_code.blank?
redirect_to quick_donate_url(account_code_string: fund_code)
end

Expand Down
2 changes: 1 addition & 1 deletion config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@
get '/store/(:customer_id)' => 'store#index', :defaults => {:customer_id => nil}, :as => 'store'
get '/subscribe/(:customer_id)' => 'store#subscribe', :defaults => {:customer_id => nil}, :as => 'store_subscribe'
# get '/donate_to_fund/:id/(:customer_id)' => 'store#donate_to_fund', :defaults => {:customer_id => nil}, :as => 'donate_to_fund'
get '/donate_to_fund/:id/(:customer_id)', :defaults => {:customer_id => nil}, to: 'store#donate_to_fund_redirect'
get '/donate_to_fund/(:id)/(:customer_id)', :defaults => {:customer_id => nil}, to: 'store#donate_to_fund_redirect'
get '/store/cancel' => 'store#cancel', :as => 'store_cancel'

# subsequent actions in the above flow require a customer_id in the URL:
Expand Down
9 changes: 9 additions & 0 deletions spec/controllers/store_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,15 @@
get :donate_to_fund_redirect, {:id => fund_code, :customer_id => @anon}
expect(response).to redirect_to(quick_donate_path(account_code_string: fund_code))
end
it 'sets the fund code to default code when it is missing' do
get :donate_to_fund_redirect, { :customer_id => @anon }
expect(response).to redirect_to(quick_donate_path(account_code_string: Donation.default_code.code))
end
it 'sets the fund code to default code when it is invalid' do
invalid_fund_code = ' '
get :donate_to_fund_redirect, { id: invalid_fund_code, :customer_id => @anon }
expect(response).to redirect_to(quick_donate_path(account_code_string: Donation.default_code.code))
end
end

describe 'quick donation with nonexistent customer' do
Expand Down

0 comments on commit 0f77ae4

Please sign in to comment.