Skip to content

Commit

Permalink
redirect donate_to_fund to quick_donate and tests
Browse files Browse the repository at this point in the history
  • Loading branch information
MayZamudio committed Mar 14, 2024
1 parent 7c337d3 commit dd8b59d
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 8 deletions.
15 changes: 10 additions & 5 deletions app/controllers/store_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,16 @@ def subscribe
redirect_to(store_path(@customer), :alert => "There are no subscriptions on sale at this time.") if @subs_to_offer.empty?
end

def donate_to_fund
return_after_login params.except(:customer_id)
@account_code = AccountCode.find_by_code(params[:id]) ||
AccountCode.find_by_id(params[:id]) ||
AccountCode.default_account_code
# def donate_to_fund
# return_after_login params.except(:customer_id)
# @account_code = AccountCode.find_by_code(params[:id]) ||
# AccountCode.find_by_id(params[:id]) ||
# AccountCode.default_account_code
# end

def donate_to_fund_redirect
fund_code = params[:id]
redirect_to quick_donate_url(account_code_string: fund_code)
end

# Serve quick_donate page; POST calls #process_donation
Expand Down
2 changes: 1 addition & 1 deletion app/views/account_codes/index.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
%td= link_to account_code.code, edit_account_code_path(account_code)
%td= link_to account_code.name, edit_account_code_path(account_code)
%td= [account_code.description, account_code.donation_prompt].join('<br/>'.html_safe).html_safe
%td= purchase_link_popup link_icon, donate_to_fund_url(account_code.id), "donations to #{account_code.name_with_code}"
%td= purchase_link_popup link_icon, quick_donate_url(account_code_string: account_code.code), "donations to #{account_code.name_with_code}"
%br

= link_to 'Add New Account Code...', new_account_code_path , :class => 'btn btn-primary'
3 changes: 2 additions & 1 deletion config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,8 @@

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)' => '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 '/store/cancel' => 'store#cancel', :as => 'store_cancel'

# subsequent actions in the above flow require a customer_id in the URL:
Expand Down
2 changes: 1 addition & 1 deletion features/support/paths.rb
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def path_to(page_name)
date_str =~ /that performance/
edit_show_showdate_path(@showdate.show,@showdate)

when /the donation landing page coded for fund (.*)/i then donate_to_fund_path(AccountCode.find_by_code!($1))
when /the donation landing page coded for fund (.*)/i then quick_donate_path(AccountCode.find_by_code!($1))
when /the donation landing page coded for a nonexistent fund/i then donate_to_fund_path('999999')
when /the quick donation landing page for account code (.*)/i then '/donate/1?account_code_string=' + $1.to_s

Expand Down

0 comments on commit dd8b59d

Please sign in to comment.