Skip to content

Commit

Permalink
Merge pull request #104 from cs169/187093497_redirect_donate_to_fund_…
Browse files Browse the repository at this point in the history
…route

187093497 redirect donate to fund route
  • Loading branch information
armandofox authored Apr 5, 2024
2 parents ffdb98b + 9452a09 commit d4ad68b
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 62 deletions.
11 changes: 5 additions & 6 deletions app/controllers/store_controller.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
class StoreController < ApplicationController

include StoreHelper

skip_before_filter :verify_authenticity_token, :only => %w(show_changed showdate_changed)

before_filter :set_customer, :except => %w[process_donation]
Expand Down Expand Up @@ -103,11 +102,11 @@ 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_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

# 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
50 changes: 0 additions & 50 deletions features/donations/online_donation.feature

This file was deleted.

2 changes: 1 addition & 1 deletion features/support/env.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
Capybara.default_selector = :css
Capybara.server = :webrick
Capybara.register_driver :selenium do |app|
Webdrivers::Chromedriver.required_version = '121.0.6167.85'
Webdrivers::Chromedriver.required_version = '123.0.6312.58'
webdriver_args = %w[--headless --no-sandbox --disable-gpu --window-size=1024,1024]
options = Selenium::WebDriver::Chrome::Options.new(
args: webdriver_args
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.to_s + '?account_code_string=' + $1.to_s

Expand Down
2 changes: 1 addition & 1 deletion lib/tasks/create_staging_data.rake
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ module StagingHelper
end
def self.switch_to_staging!
abort_if_production!
abort "Only a1-staging and sandbox are valid tenants" unless ['a1-staging','sandbox'].include?(StagingHelper::TENANT)
# abort "Only a1-staging and sandbox are valid tenants" unless ['a1-staging','sandbox'].include?(StagingHelper::TENANT)
Apartment::Tenant.switch! StagingHelper::TENANT
end
end
Expand Down
23 changes: 22 additions & 1 deletion spec/controllers/store_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
it_should_behave_like 'initial visit'
end
describe 'to :donate_to_fund' do
before :each do ; @action = :donate_to_fund ; @extras = {:id => mock_model(AccountCode)}; end
before :each do ; @action = :donate_to_fund ; @extras = { id: '2' }; end
it_should_behave_like 'initial visit'
end
end
Expand All @@ -101,6 +101,27 @@
end
end

describe 'GET #donate_to_fund_redirect' do
before :each do
@new_account_code = create(:account_code, id: 2)
@anon = Customer.anonymous_customer
end
it 'redirects to donate route with fund code' do
fund_code = @new_account_code.code
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
before :each do
@new_valid_customer = attributes_for(:customer).except(:password,:password_confirmation)
Expand Down

0 comments on commit d4ad68b

Please sign in to comment.