all tests are passing
This commit is contained in:
parent
e672f08265
commit
7eea3edd70
|
@ -2,3 +2,4 @@
|
||||||
spec/test_app
|
spec/test_app
|
||||||
spec/dummy
|
spec/dummy
|
||||||
.rvmrc
|
.rvmrc
|
||||||
|
.bundle
|
||||||
|
|
21
Gemfile
21
Gemfile
|
@ -11,11 +11,6 @@ group :test do
|
||||||
gem 'simplecov'
|
gem 'simplecov'
|
||||||
gem 'shoulda'
|
gem 'shoulda'
|
||||||
gem 'faker'
|
gem 'faker'
|
||||||
if RUBY_VERSION < "1.9"
|
|
||||||
gem "ruby-debug"
|
|
||||||
else
|
|
||||||
gem "ruby-debug19"
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
group :cucumber do
|
group :cucumber do
|
||||||
|
@ -25,10 +20,14 @@ group :cucumber do
|
||||||
gem 'capybara'
|
gem 'capybara'
|
||||||
gem 'faker'
|
gem 'faker'
|
||||||
gem 'launchy'
|
gem 'launchy'
|
||||||
|
|
||||||
if RUBY_VERSION < "1.9"
|
|
||||||
gem "ruby-debug"
|
|
||||||
else
|
|
||||||
gem "ruby-debug19"
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
gem 'awesome_print'
|
||||||
|
|
||||||
|
# if RUBY_VERSION < "1.9"
|
||||||
|
# gem "ruby-debug"
|
||||||
|
# else
|
||||||
|
# gem "ruby-debug19"
|
||||||
|
# end
|
||||||
|
|
||||||
|
gem 'debugger'
|
124
Gemfile.lock
124
Gemfile.lock
|
@ -1,50 +1,50 @@
|
||||||
|
PATH
|
||||||
|
remote: .
|
||||||
|
specs:
|
||||||
|
spree_paypal_express (1.1.0)
|
||||||
|
spree_core (>= 1.0.0)
|
||||||
|
|
||||||
PATH
|
PATH
|
||||||
remote: ../spree
|
remote: ../spree
|
||||||
specs:
|
specs:
|
||||||
spree (1.0.0)
|
spree (1.1.0.beta)
|
||||||
spree_api (= 1.0.0)
|
spree_api (= 1.1.0.beta)
|
||||||
spree_auth (= 1.0.0)
|
spree_auth (= 1.1.0.beta)
|
||||||
spree_cmd (= 1.0.0)
|
spree_cmd (= 1.1.0.beta)
|
||||||
spree_core (= 1.0.0)
|
spree_core (= 1.1.0.beta)
|
||||||
spree_dash (= 1.0.0)
|
spree_dash (= 1.1.0.beta)
|
||||||
spree_promo (= 1.0.0)
|
spree_promo (= 1.1.0.beta)
|
||||||
spree_sample (= 1.0.0)
|
spree_sample (= 1.1.0.beta)
|
||||||
spree_api (1.0.0)
|
spree_api (1.1.0.beta)
|
||||||
spree_auth (= 1.0.0)
|
spree_auth (= 1.1.0.beta)
|
||||||
spree_core (= 1.0.0)
|
spree_core (= 1.1.0.beta)
|
||||||
spree_auth (1.0.0)
|
spree_auth (1.1.0.beta)
|
||||||
cancan (= 1.6.7)
|
cancan (= 1.6.7)
|
||||||
devise (= 1.4.8)
|
devise (~> 2.0)
|
||||||
spree_core (= 1.0.0)
|
spree_core (= 1.1.0.beta)
|
||||||
spree_cmd (1.0.0)
|
spree_cmd (1.1.0.beta)
|
||||||
rails (>= 3.1.1, <= 3.1.3)
|
rails (>= 3.1.1, <= 3.2.1)
|
||||||
spree_core (1.0.0)
|
spree_core (1.1.0.beta)
|
||||||
activemerchant (= 1.20.1)
|
activemerchant (= 1.20.1)
|
||||||
acts_as_list (= 0.1.4)
|
acts_as_list (= 0.1.4)
|
||||||
deface (>= 0.7.2)
|
deface (>= 0.7.2)
|
||||||
ffaker (~> 1.12.0)
|
ffaker (~> 1.12.0)
|
||||||
highline (= 1.6.8)
|
highline (= 1.6.8)
|
||||||
jquery-rails (>= 1.0.18, <= 1.0.19)
|
jquery-rails (>= 1.0.19, <= 2.0.0)
|
||||||
kaminari (>= 0.13.0)
|
kaminari (>= 0.13.0)
|
||||||
meta_search (= 1.1.1)
|
meta_search (= 1.1.2)
|
||||||
nested_set (= 1.6.8)
|
nested_set (= 1.6.8)
|
||||||
paperclip (= 2.5.0)
|
paperclip (= 2.5.0)
|
||||||
rails (>= 3.1.1, <= 3.1.3)
|
rails (>= 3.1.1, <= 3.2.1)
|
||||||
state_machine (= 1.1.1)
|
state_machine (= 1.1.2)
|
||||||
stringex (~> 1.3.0)
|
stringex (~> 1.3.0)
|
||||||
spree_dash (1.0.0)
|
spree_dash (1.1.0.beta)
|
||||||
spree_core (= 1.0.0)
|
spree_core (= 1.1.0.beta)
|
||||||
spree_promo (1.0.0)
|
spree_promo (1.1.0.beta)
|
||||||
spree_auth (= 1.0.0)
|
spree_auth (= 1.1.0.beta)
|
||||||
spree_core (= 1.0.0)
|
spree_core (= 1.1.0.beta)
|
||||||
spree_sample (1.0.0)
|
spree_sample (1.1.0.beta)
|
||||||
spree_core (= 1.0.0)
|
spree_core (= 1.1.0.beta)
|
||||||
|
|
||||||
PATH
|
|
||||||
remote: .
|
|
||||||
specs:
|
|
||||||
spree_paypal_express (1.0.1)
|
|
||||||
spree_core (>= 0.70.1)
|
|
||||||
|
|
||||||
GEM
|
GEM
|
||||||
remote: http://rubygems.org/
|
remote: http://rubygems.org/
|
||||||
|
@ -90,10 +90,10 @@ GEM
|
||||||
multi_json (~> 1.0)
|
multi_json (~> 1.0)
|
||||||
acts_as_list (0.1.4)
|
acts_as_list (0.1.4)
|
||||||
addressable (2.2.6)
|
addressable (2.2.6)
|
||||||
archive-tar-minitar (0.5.2)
|
arel (2.2.3)
|
||||||
arel (2.2.1)
|
awesome_print (1.0.2)
|
||||||
bcrypt-ruby (3.0.1)
|
bcrypt-ruby (3.0.1)
|
||||||
braintree (2.13.4)
|
braintree (2.15.0)
|
||||||
builder (>= 2.0.0)
|
builder (>= 2.0.0)
|
||||||
builder (3.0.0)
|
builder (3.0.0)
|
||||||
cancan (1.6.7)
|
cancan (1.6.7)
|
||||||
|
@ -119,13 +119,21 @@ GEM
|
||||||
cucumber (>= 1.1.3)
|
cucumber (>= 1.1.3)
|
||||||
nokogiri (>= 1.5.0)
|
nokogiri (>= 1.5.0)
|
||||||
database_cleaner (0.5.2)
|
database_cleaner (0.5.2)
|
||||||
deface (0.7.2)
|
debugger (1.1.0)
|
||||||
|
columnize (>= 0.3.1)
|
||||||
|
debugger-linecache (~> 1.1)
|
||||||
|
debugger-ruby_core_source (~> 1.1)
|
||||||
|
debugger-linecache (1.1.1)
|
||||||
|
debugger-ruby_core_source (>= 1.1.1)
|
||||||
|
debugger-ruby_core_source (1.1.1)
|
||||||
|
deface (0.8.0)
|
||||||
nokogiri (~> 1.5.0)
|
nokogiri (~> 1.5.0)
|
||||||
rails (>= 3.0.9)
|
rails (>= 3.0.9)
|
||||||
devise (1.4.8)
|
devise (2.0.4)
|
||||||
bcrypt-ruby (~> 3.0)
|
bcrypt-ruby (~> 3.0)
|
||||||
orm_adapter (~> 0.0.3)
|
orm_adapter (~> 0.0.3)
|
||||||
warden (~> 1.0.3)
|
railties (~> 3.1)
|
||||||
|
warden (~> 1.1.1)
|
||||||
diff-lcs (1.1.3)
|
diff-lcs (1.1.3)
|
||||||
erubis (2.7.0)
|
erubis (2.7.0)
|
||||||
factory_girl (2.2.0)
|
factory_girl (2.2.0)
|
||||||
|
@ -152,16 +160,15 @@ GEM
|
||||||
railties (>= 3.0.0)
|
railties (>= 3.0.0)
|
||||||
launchy (2.0.5)
|
launchy (2.0.5)
|
||||||
addressable (~> 2.2.6)
|
addressable (~> 2.2.6)
|
||||||
linecache19 (0.5.12)
|
mail (2.3.3)
|
||||||
ruby_core_source (>= 0.1.4)
|
|
||||||
mail (2.3.0)
|
|
||||||
i18n (>= 0.4.0)
|
i18n (>= 0.4.0)
|
||||||
mime-types (~> 1.16)
|
mime-types (~> 1.16)
|
||||||
treetop (~> 1.4.8)
|
treetop (~> 1.4.8)
|
||||||
meta_search (1.1.1)
|
meta_search (1.1.2)
|
||||||
actionpack (~> 3.1.0)
|
actionpack (~> 3.1)
|
||||||
activerecord (~> 3.1.0)
|
activerecord (~> 3.1)
|
||||||
activesupport (~> 3.1.0)
|
activesupport (~> 3.1)
|
||||||
|
meta_search
|
||||||
polyamorous (~> 0.5.0)
|
polyamorous (~> 0.5.0)
|
||||||
mime-types (1.17.2)
|
mime-types (1.17.2)
|
||||||
money (3.7.1)
|
money (3.7.1)
|
||||||
|
@ -171,7 +178,7 @@ GEM
|
||||||
activerecord (>= 3.0.0)
|
activerecord (>= 3.0.0)
|
||||||
railties (>= 3.0.0)
|
railties (>= 3.0.0)
|
||||||
nokogiri (1.5.0)
|
nokogiri (1.5.0)
|
||||||
orm_adapter (0.0.6)
|
orm_adapter (0.0.7)
|
||||||
paperclip (2.5.0)
|
paperclip (2.5.0)
|
||||||
activerecord (>= 2.3.0)
|
activerecord (>= 2.3.0)
|
||||||
activesupport (>= 2.3.2)
|
activesupport (>= 2.3.2)
|
||||||
|
@ -220,16 +227,6 @@ GEM
|
||||||
activesupport (~> 3.0)
|
activesupport (~> 3.0)
|
||||||
railties (~> 3.0)
|
railties (~> 3.0)
|
||||||
rspec (~> 2.7.0)
|
rspec (~> 2.7.0)
|
||||||
ruby-debug-base19 (0.11.25)
|
|
||||||
columnize (>= 0.3.1)
|
|
||||||
linecache19 (>= 0.5.11)
|
|
||||||
ruby_core_source (>= 0.1.4)
|
|
||||||
ruby-debug19 (0.11.6)
|
|
||||||
columnize (>= 0.3.1)
|
|
||||||
linecache19 (>= 0.5.11)
|
|
||||||
ruby-debug-base19 (>= 0.11.19)
|
|
||||||
ruby_core_source (0.1.5)
|
|
||||||
archive-tar-minitar (>= 0.5.2)
|
|
||||||
rubyzip (0.9.6.1)
|
rubyzip (0.9.6.1)
|
||||||
selenium-webdriver (2.19.0)
|
selenium-webdriver (2.19.0)
|
||||||
childprocess (>= 0.2.5)
|
childprocess (>= 0.2.5)
|
||||||
|
@ -248,16 +245,16 @@ GEM
|
||||||
sqlite3 (1.3.5)
|
sqlite3 (1.3.5)
|
||||||
sqlite3-ruby (1.3.3)
|
sqlite3-ruby (1.3.3)
|
||||||
sqlite3 (>= 1.3.3)
|
sqlite3 (>= 1.3.3)
|
||||||
state_machine (1.1.1)
|
state_machine (1.1.2)
|
||||||
stringex (1.3.0)
|
stringex (1.3.2)
|
||||||
term-ansicolor (1.0.7)
|
term-ansicolor (1.0.7)
|
||||||
thor (0.14.6)
|
thor (0.14.6)
|
||||||
tilt (1.3.3)
|
tilt (1.3.3)
|
||||||
treetop (1.4.10)
|
treetop (1.4.10)
|
||||||
polyglot
|
polyglot
|
||||||
polyglot (>= 0.3.1)
|
polyglot (>= 0.3.1)
|
||||||
tzinfo (0.3.31)
|
tzinfo (0.3.33)
|
||||||
warden (1.0.6)
|
warden (1.1.1)
|
||||||
rack (>= 1.0)
|
rack (>= 1.0)
|
||||||
xpath (0.1.4)
|
xpath (0.1.4)
|
||||||
nokogiri (~> 1.3)
|
nokogiri (~> 1.3)
|
||||||
|
@ -266,15 +263,16 @@ PLATFORMS
|
||||||
ruby
|
ruby
|
||||||
|
|
||||||
DEPENDENCIES
|
DEPENDENCIES
|
||||||
|
awesome_print
|
||||||
capybara
|
capybara
|
||||||
cucumber-rails
|
cucumber-rails
|
||||||
database_cleaner (~> 0.5.2)
|
database_cleaner (~> 0.5.2)
|
||||||
|
debugger
|
||||||
factory_girl_rails (= 1.3.0)
|
factory_girl_rails (= 1.3.0)
|
||||||
faker
|
faker
|
||||||
launchy
|
launchy
|
||||||
nokogiri
|
nokogiri
|
||||||
rspec-rails (= 2.7.0)
|
rspec-rails (= 2.7.0)
|
||||||
ruby-debug19
|
|
||||||
shoulda
|
shoulda
|
||||||
simplecov
|
simplecov
|
||||||
spree!
|
spree!
|
||||||
|
|
|
@ -85,7 +85,6 @@ module Spree
|
||||||
else
|
else
|
||||||
order_ship_address.state_name = ship_address["state"]
|
order_ship_address.state_name = ship_address["state"]
|
||||||
end
|
end
|
||||||
|
|
||||||
order_ship_address.save!
|
order_ship_address.save!
|
||||||
|
|
||||||
@order.ship_address = order_ship_address
|
@order.ship_address = order_ship_address
|
||||||
|
@ -94,7 +93,7 @@ module Spree
|
||||||
@order.save
|
@order.save
|
||||||
|
|
||||||
if payment_method.preferred_review
|
if payment_method.preferred_review
|
||||||
render 'shared/paypal_express_confirm'
|
render 'spree/shared/paypal_express_confirm'
|
||||||
else
|
else
|
||||||
paypal_finish
|
paypal_finish
|
||||||
end
|
end
|
||||||
|
@ -158,7 +157,7 @@ module Spree
|
||||||
redirect_to completion_route
|
redirect_to completion_route
|
||||||
|
|
||||||
else
|
else
|
||||||
payment.fail!
|
payment.failure!
|
||||||
order_params = {}
|
order_params = {}
|
||||||
gateway_error(ppx_auth_response)
|
gateway_error(ppx_auth_response)
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
Spree::Core::Engine.routes.append do
|
Spree::Core::Engine.routes.draw do
|
||||||
resources :orders do
|
resources :orders do
|
||||||
resource :checkout, :controller => 'checkout' do
|
resource :checkout, :controller => 'checkout' do
|
||||||
member do
|
member do
|
||||||
|
|
|
@ -1,278 +1,282 @@
|
||||||
require File.dirname(__FILE__) + '/../spec_helper'
|
require File.dirname(__FILE__) + '/../spec_helper'
|
||||||
|
|
||||||
describe CheckoutController do
|
module Spree
|
||||||
let(:token) { "EC-2OPN7UJGFWK9OYFV" }
|
describe CheckoutController do
|
||||||
let(:order) { Factory(:ppx_order_with_totals, :state => "payment") }
|
let(:token) { "EC-2OPN7UJGFWK9OYFV" }
|
||||||
let(:order_total) { (order.total * 100).to_i }
|
let(:order) { Factory(:ppx_order_with_totals, :state => "payment") }
|
||||||
let(:gateway_provider) { mock(ActiveMerchant::Billing::PaypalExpressGateway) }
|
let(:order_total) { (order.total * 100).to_i }
|
||||||
let(:paypal_gateway) { mock(BillingIntegration::PaypalExpress, :id => 123, :preferred_review => false, :preferred_no_shipping => true, :provider => gateway_provider) }
|
let(:gateway_provider) { mock(ActiveMerchant::Billing::PaypalExpressGateway) }
|
||||||
|
let(:paypal_gateway) { mock(BillingIntegration::PaypalExpress, :id => 123, :preferred_review => false, :preferred_no_shipping => true, :provider => gateway_provider, :preferred_currency => "US"
|
||||||
|
) }
|
||||||
|
|
||||||
let(:details_for_response) { mock(ActiveMerchant::Billing::PaypalExpressResponse, :success? => true,
|
let(:details_for_response) { mock(ActiveMerchant::Billing::PaypalExpressResponse, :success? => true,
|
||||||
:params => {"payer" => order.user.email, "payer_id" => "FWRVKNRRZ3WUC"}, :address => {}) }
|
:params => {"payer" => order.user.email, "payer_id" => "FWRVKNRRZ3WUC"}, :address => {}) }
|
||||||
|
|
||||||
let(:purchase_response) { mock(ActiveMerchant::Billing::PaypalExpressResponse, :success? => true,
|
let(:purchase_response) { mock(ActiveMerchant::Billing::PaypalExpressResponse, :success? => true,
|
||||||
:params => {"payer" => order.user.email, "payer_id" => "FWRVKNRRZ3WUC", "gross_amount" => order_total, "payment_status" => "Completed"},
|
:params => {"payer" => order.user.email, "payer_id" => "FWRVKNRRZ3WUC", "gross_amount" => order_total, "payment_status" => "Completed"},
|
||||||
:avs_result => "F",
|
:avs_result => "F",
|
||||||
:to_yaml => "fake") }
|
:to_yaml => "fake") }
|
||||||
|
|
||||||
|
|
||||||
before do
|
|
||||||
Spree::Auth::Config.set(:registration_step => false)
|
|
||||||
controller.stub(:current_order => order, :check_authorization => true, :current_user => order.user)
|
|
||||||
order.stub(:checkout_allowed? => true, :completed? => false)
|
|
||||||
order.update!
|
|
||||||
end
|
|
||||||
|
|
||||||
it "should understand paypal routes" do
|
|
||||||
assert_routing("/orders/#{order.number}/checkout/paypal_payment", {:controller => "checkout", :action => "paypal_payment", :order_id => order.number })
|
|
||||||
assert_routing("/orders/#{order.number}/checkout/paypal_confirm", {:controller => "checkout", :action => "paypal_confirm", :order_id => order.number })
|
|
||||||
end
|
|
||||||
|
|
||||||
context "paypal_checkout" do
|
|
||||||
#feature not implemented
|
|
||||||
end
|
|
||||||
|
|
||||||
context "paypal_payment without auto_capture" do
|
|
||||||
let(:redirect_url) { "https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=#{token}&useraction=commit" }
|
|
||||||
|
|
||||||
before { Spree::Config.set(:auto_capture => false) }
|
|
||||||
|
|
||||||
it "should setup an authorize transaction and redirect to sandbox" do
|
|
||||||
PaymentMethod.should_receive(:find).at_least(1).with('123').and_return(paypal_gateway)
|
|
||||||
|
|
||||||
gateway_provider.should_receive(:redirect_url_for).with(token, {:review => false}).and_return redirect_url
|
|
||||||
paypal_gateway.provider.should_receive(:setup_authorization).with(order_total, anything()).and_return(mock(:success? => true, :token => token))
|
|
||||||
|
|
||||||
get :paypal_payment, {:order_id => order.number, :payment_method_id => "123" }
|
|
||||||
|
|
||||||
response.should redirect_to "https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=#{assigns[:ppx_response].token}&useraction=commit"
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
context "paypal_payment with auto_capture" do
|
|
||||||
let(:redirect_url) { "https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=#{token}&useraction=commit" }
|
|
||||||
|
|
||||||
before { Spree::Config.set(:auto_capture => true) }
|
|
||||||
|
|
||||||
it "should setup a purchase transaction and redirect to sandbox" do
|
|
||||||
PaymentMethod.should_receive(:find).at_least(1).with("123").and_return(paypal_gateway)
|
|
||||||
|
|
||||||
gateway_provider.should_receive(:redirect_url_for).with(token, {:review => false}).and_return redirect_url
|
|
||||||
paypal_gateway.provider.should_receive(:setup_purchase).with(order_total, anything()).and_return(mock(:success? => true, :token => token))
|
|
||||||
|
|
||||||
get :paypal_payment, {:order_id => order.number, :payment_method_id => "123" }
|
|
||||||
|
|
||||||
response.should redirect_to "https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=#{assigns[:ppx_response].token}&useraction=commit"
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
context "paypal_confirm" do
|
|
||||||
before { PaymentMethod.should_receive(:find).at_least(1).with("123").and_return(paypal_gateway) }
|
|
||||||
|
|
||||||
context "with auto_capture and no review" do
|
|
||||||
before do
|
|
||||||
Spree::Config.set(:auto_capture => true)
|
|
||||||
paypal_gateway.stub(:preferred_review => false)
|
|
||||||
end
|
|
||||||
|
|
||||||
it "should capture payment" do
|
|
||||||
paypal_gateway.provider.should_receive(:details_for).with(token).and_return(details_for_response)
|
|
||||||
|
|
||||||
paypal_gateway.provider.should_receive(:purchase).with(order_total, anything()).and_return(purchase_response)
|
|
||||||
|
|
||||||
get :paypal_confirm, {:order_id => order.number, :payment_method_id => "123", :token => token, :PayerID => "FWRVKNRRZ3WUC" }
|
|
||||||
|
|
||||||
response.should redirect_to order_url(order)
|
|
||||||
|
|
||||||
order.reload
|
|
||||||
order.state.should == "complete"
|
|
||||||
order.payments.size.should == 1
|
|
||||||
order.payment_state.should == "paid"
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
context "with review" do
|
|
||||||
before { paypal_gateway.stub(:preferred_review => true) }
|
|
||||||
|
|
||||||
it "should render review" do
|
|
||||||
paypal_gateway.provider.should_receive(:details_for).with(token).and_return(details_for_response)
|
|
||||||
|
|
||||||
get :paypal_confirm, {:order_id => order.number, :payment_method_id => "123", :token => token, :PayerID => "FWRVKNRRZ3WUC" }
|
|
||||||
|
|
||||||
response.should render_template("shared/paypal_express_confirm")
|
|
||||||
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
context "with review and shipping update" do
|
|
||||||
before do
|
|
||||||
paypal_gateway.stub(:preferred_review => true)
|
|
||||||
paypal_gateway.stub(:preferred_no_shipping => false)
|
|
||||||
|
|
||||||
details_for_response.stub(:params => details_for_response.params.merge({'first_name' => 'Dr.', 'last_name' => 'Evil'}),
|
|
||||||
:address => {'address1' => 'Apt. 187', 'address2'=> 'Some Str.', 'city' => 'Chevy Chase', 'country' => 'US', 'zip' => '20815', 'state' => 'MD' })
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
it "should update ship_address and render review" do
|
|
||||||
paypal_gateway.provider.should_receive(:details_for).with(token).and_return(details_for_response)
|
|
||||||
|
|
||||||
get :paypal_confirm, {:order_id => order.number, :payment_method_id => "123", :token => token, :PayerID => "FWRVKNRRZ3WUC" }
|
|
||||||
|
|
||||||
order.ship_address.address1.should == "Apt. 187"
|
|
||||||
response.should render_template("shared/paypal_express_confirm")
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
context "with un-successful repsonse" do
|
|
||||||
before { details_for_response.stub(:success? => false) }
|
|
||||||
|
|
||||||
it "should log error and redirect to payment step" do
|
|
||||||
paypal_gateway.provider.should_receive(:details_for).with(token).and_return(details_for_response)
|
|
||||||
|
|
||||||
controller.should_receive(:gateway_error).with(details_for_response)
|
|
||||||
|
|
||||||
get :paypal_confirm, {:order_id => order.number, :payment_method_id => "123", :token => token, :PayerID => "FWRVKNRRZ3WUC" }
|
|
||||||
|
|
||||||
response.should redirect_to edit_order_checkout_url(order, :state => 'payment')
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
context "paypal_finish" do
|
|
||||||
let(:paypal_account) { stub_model(PaypalAccount, :payer_id => "FWRVKNRRZ3WUC", :email => order.email ) }
|
|
||||||
let(:authorize_response) { mock(ActiveMerchant::Billing::PaypalExpressResponse, :success? => true,
|
|
||||||
:params => {"payer" => order.user.email, "payer_id" => "FWRVKNRRZ3WUC", "gross_amount" => order_total, "payment_status" => "Pending"},
|
|
||||||
:avs_result => "F",
|
|
||||||
:to_yaml => "fake") }
|
|
||||||
|
|
||||||
before do
|
before do
|
||||||
PaymentMethod.should_receive(:find).at_least(1).with("123").and_return(paypal_gateway)
|
Spree::Auth::Config.set(:registration_step => false)
|
||||||
PaypalAccount.should_receive(:find_by_payer_id).with("FWRVKNRRZ3WUC").and_return(paypal_account)
|
controller.stub(:current_order => order, :check_authorization => true, :current_user => order.user)
|
||||||
|
order.stub(:checkout_allowed? => true, :completed? => false)
|
||||||
|
order.update!
|
||||||
end
|
end
|
||||||
|
|
||||||
context "with auto_capture" do
|
it "should understand paypal routes" do
|
||||||
before { Spree::Config.set(:auto_capture => true) }
|
pending("Unknown how to make this work within the scope of an engine again")
|
||||||
|
|
||||||
it "should capture payment" do
|
assert_routing("/orders/#{order.number}/checkout/paypal_payment", {:controller => "checkout", :action => "paypal_payment", :order_id => order.number })
|
||||||
|
assert_routing("/orders/#{order.number}/checkout/paypal_confirm", {:controller => "checkout", :action => "paypal_confirm", :order_id => order.number })
|
||||||
paypal_gateway.provider.should_receive(:purchase).with(order_total, anything()).and_return(purchase_response)
|
|
||||||
|
|
||||||
get :paypal_finish, {:order_id => order.number, :payment_method_id => "123", :token => token, :PayerID => "FWRVKNRRZ3WUC" }
|
|
||||||
|
|
||||||
response.should redirect_to order_url(order)
|
|
||||||
|
|
||||||
order.reload
|
|
||||||
order.update!
|
|
||||||
order.payments.size.should == 1
|
|
||||||
order.payment_state.should == "paid"
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
context "with auto_capture and pending(echeck) response" do
|
context "paypal_checkout" do
|
||||||
before do
|
#feature not implemented
|
||||||
Spree::Config.set(:auto_capture => true)
|
|
||||||
purchase_response.params["payment_status"] = "pending"
|
|
||||||
end
|
|
||||||
|
|
||||||
it "should authorize payment" do
|
|
||||||
|
|
||||||
paypal_gateway.provider.should_receive(:purchase).with(order_total, anything()).and_return(purchase_response)
|
|
||||||
|
|
||||||
get :paypal_finish, {:order_id => order.number, :payment_method_id => "123", :token => token, :PayerID => "FWRVKNRRZ3WUC" }
|
|
||||||
|
|
||||||
response.should redirect_to order_url(order)
|
|
||||||
|
|
||||||
order.reload
|
|
||||||
order.update!
|
|
||||||
order.payments.size.should == 1
|
|
||||||
order.payment_state.should == "balance_due"
|
|
||||||
order.payment.state.should == "pending"
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
context "without auto_capture" do
|
context "paypal_payment without auto_capture" do
|
||||||
|
let(:redirect_url) { "https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=#{token}&useraction=commit" }
|
||||||
|
|
||||||
before { Spree::Config.set(:auto_capture => false) }
|
before { Spree::Config.set(:auto_capture => false) }
|
||||||
|
|
||||||
it "should authorize payment" do
|
it "should setup an authorize transaction and redirect to sandbox" do
|
||||||
|
PaymentMethod.should_receive(:find).at_least(1).with('123').and_return(paypal_gateway)
|
||||||
|
|
||||||
paypal_gateway.provider.should_receive(:authorize).with(order_total, anything()).and_return(authorize_response)
|
gateway_provider.should_receive(:redirect_url_for).with(token, {:review => false}).and_return redirect_url
|
||||||
|
paypal_gateway.provider.should_receive(:setup_authorization).with(order_total, anything()).and_return(mock(:success? => true, :token => token))
|
||||||
|
|
||||||
get :paypal_finish, {:order_id => order.number, :payment_method_id => "123", :token => token, :PayerID => "FWRVKNRRZ3WUC" }
|
get :paypal_payment, {:order_id => order.number, :payment_method_id => "123" }
|
||||||
|
|
||||||
response.should redirect_to order_url(order)
|
response.should redirect_to "https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=#{assigns[:ppx_response].token}&useraction=commit"
|
||||||
|
|
||||||
order.reload
|
|
||||||
order.update!
|
|
||||||
order.payments.size.should == 1
|
|
||||||
order.payment_state.should == "balance_due"
|
|
||||||
order.payment.state.should == "pending"
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
context "with un-successful repsonse" do
|
context "paypal_payment with auto_capture" do
|
||||||
|
let(:redirect_url) { "https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=#{token}&useraction=commit" }
|
||||||
|
|
||||||
|
before { Spree::Config.set(:auto_capture => true) }
|
||||||
|
|
||||||
|
it "should setup a purchase transaction and redirect to sandbox" do
|
||||||
|
PaymentMethod.should_receive(:find).at_least(1).with("123").and_return(paypal_gateway)
|
||||||
|
|
||||||
|
gateway_provider.should_receive(:redirect_url_for).with(token, {:review => false}).and_return redirect_url
|
||||||
|
paypal_gateway.provider.should_receive(:setup_purchase).with(order_total, anything()).and_return(mock(:success? => true, :token => token))
|
||||||
|
|
||||||
|
get :paypal_payment, {:order_id => order.number, :payment_method_id => "123" }
|
||||||
|
|
||||||
|
response.should redirect_to "https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=#{assigns[:ppx_response].token}&useraction=commit"
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
context "paypal_confirm" do
|
||||||
|
before { PaymentMethod.should_receive(:find).at_least(1).with("123").and_return(paypal_gateway) }
|
||||||
|
|
||||||
|
context "with auto_capture and no review" do
|
||||||
|
before do
|
||||||
|
Spree::Config.set(:auto_capture => true)
|
||||||
|
paypal_gateway.stub(:preferred_review => false)
|
||||||
|
end
|
||||||
|
|
||||||
|
it "should capture payment" do
|
||||||
|
paypal_gateway.provider.should_receive(:details_for).with(token).and_return(details_for_response)
|
||||||
|
|
||||||
|
paypal_gateway.provider.should_receive(:purchase).with(order_total, anything()).and_return(purchase_response)
|
||||||
|
|
||||||
|
get :paypal_confirm, {:order_id => order.number, :payment_method_id => "123", :token => token, :PayerID => "FWRVKNRRZ3WUC" }
|
||||||
|
|
||||||
|
response.should redirect_to spree.order_path(order)
|
||||||
|
|
||||||
|
order.reload
|
||||||
|
order.state.should == "complete"
|
||||||
|
order.payments.size.should == 1
|
||||||
|
order.payment_state.should == "paid"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context "with review" do
|
||||||
|
before { paypal_gateway.stub(:preferred_review => true) }
|
||||||
|
|
||||||
|
it "should render review" do
|
||||||
|
paypal_gateway.provider.should_receive(:details_for).with(token).and_return(details_for_response)
|
||||||
|
|
||||||
|
get :paypal_confirm, {:order_id => order.number, :payment_method_id => "123", :token => token, :PayerID => "FWRVKNRRZ3WUC" }
|
||||||
|
|
||||||
|
response.should render_template("shared/paypal_express_confirm")
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context "with review and shipping update" do
|
||||||
|
before do
|
||||||
|
paypal_gateway.stub(:preferred_review => true)
|
||||||
|
paypal_gateway.stub(:preferred_no_shipping => false)
|
||||||
|
|
||||||
|
details_for_response.stub(:params => details_for_response.params.merge({'first_name' => 'Dr.', 'last_name' => 'Evil'}),
|
||||||
|
:address => {'address1' => 'Apt. 187', 'address2'=> 'Some Str.', 'city' => 'Chevy Chase', 'country' => 'US', 'zip' => '20815', 'state' => 'MD' })
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
it "should update ship_address and render review" do
|
||||||
|
paypal_gateway.provider.should_receive(:details_for).with(token).and_return(details_for_response)
|
||||||
|
|
||||||
|
get :paypal_confirm, {:order_id => order.number, :payment_method_id => "123", :token => token, :PayerID => "FWRVKNRRZ3WUC" }
|
||||||
|
|
||||||
|
order.ship_address.address1.should == "Apt. 187"
|
||||||
|
response.should render_template("shared/paypal_express_confirm")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context "with un-successful repsonse" do
|
||||||
|
before { details_for_response.stub(:success? => false) }
|
||||||
|
|
||||||
|
it "should log error and redirect to payment step" do
|
||||||
|
paypal_gateway.provider.should_receive(:details_for).with(token).and_return(details_for_response)
|
||||||
|
|
||||||
|
controller.should_receive(:gateway_error).with(details_for_response)
|
||||||
|
|
||||||
|
get :paypal_confirm, {:order_id => order.number, :payment_method_id => "123", :token => token, :PayerID => "FWRVKNRRZ3WUC" }
|
||||||
|
|
||||||
|
response.should redirect_to spree.edit_order_checkout_path(order, :state => 'payment')
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
context "paypal_finish" do
|
||||||
|
let(:paypal_account) { stub_model(PaypalAccount, :payer_id => "FWRVKNRRZ3WUC", :email => order.email ) }
|
||||||
|
let(:authorize_response) { mock(ActiveMerchant::Billing::PaypalExpressResponse, :success? => true,
|
||||||
|
:params => {"payer" => order.user.email, "payer_id" => "FWRVKNRRZ3WUC", "gross_amount" => order_total, "payment_status" => "Pending"},
|
||||||
|
:avs_result => "F",
|
||||||
|
:to_yaml => "fake") }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
Spree::Config.set(:auto_capture => true)
|
PaymentMethod.should_receive(:find).at_least(1).with("123").and_return(paypal_gateway)
|
||||||
purchase_response.stub(:success? => false)
|
PaypalAccount.should_receive(:find_by_payer_id).with("FWRVKNRRZ3WUC").and_return(paypal_account)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should log error and redirect to payment step" do
|
context "with auto_capture" do
|
||||||
paypal_gateway.provider.should_receive(:purchase).with(order_total, anything()).and_return(purchase_response)
|
before { Spree::Config.set(:auto_capture => true) }
|
||||||
|
|
||||||
controller.should_receive(:gateway_error).with(purchase_response)
|
it "should capture payment" do
|
||||||
|
|
||||||
get :paypal_finish, {:order_id => order.number, :payment_method_id => "123", :token => token, :PayerID => "FWRVKNRRZ3WUC" }
|
paypal_gateway.provider.should_receive(:purchase).with(order_total, anything()).and_return(purchase_response)
|
||||||
|
|
||||||
response.should redirect_to edit_order_checkout_url(order, :state => 'payment')
|
get :paypal_finish, {:order_id => order.number, :payment_method_id => "123", :token => token, :PayerID => "FWRVKNRRZ3WUC" }
|
||||||
|
|
||||||
order.reload
|
response.should redirect_to spree.order_path(order)
|
||||||
|
|
||||||
|
order.reload
|
||||||
|
order.update!
|
||||||
|
order.payments.size.should == 1
|
||||||
|
order.payment_state.should == "paid"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context "with auto_capture and pending(echeck) response" do
|
||||||
|
before do
|
||||||
|
Spree::Config.set(:auto_capture => true)
|
||||||
|
purchase_response.params["payment_status"] = "pending"
|
||||||
|
end
|
||||||
|
|
||||||
|
it "should authorize payment" do
|
||||||
|
|
||||||
|
paypal_gateway.provider.should_receive(:purchase).with(order_total, anything()).and_return(purchase_response)
|
||||||
|
|
||||||
|
get :paypal_finish, {:order_id => order.number, :payment_method_id => "123", :token => token, :PayerID => "FWRVKNRRZ3WUC" }
|
||||||
|
|
||||||
|
response.should redirect_to spree.order_path(order)
|
||||||
|
|
||||||
|
order.reload
|
||||||
|
order.update!
|
||||||
|
order.payments.size.should == 1
|
||||||
|
order.payment_state.should == "balance_due"
|
||||||
|
order.payment.state.should == "pending"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context "without auto_capture" do
|
||||||
|
before { Spree::Config.set(:auto_capture => false) }
|
||||||
|
|
||||||
|
it "should authorize payment" do
|
||||||
|
|
||||||
|
paypal_gateway.provider.should_receive(:authorize).with(order_total, anything()).and_return(authorize_response)
|
||||||
|
|
||||||
|
get :paypal_finish, {:order_id => order.number, :payment_method_id => "123", :token => token, :PayerID => "FWRVKNRRZ3WUC" }
|
||||||
|
|
||||||
|
response.should redirect_to spree.order_path(order)
|
||||||
|
|
||||||
|
order.reload
|
||||||
|
order.update!
|
||||||
|
order.payments.size.should == 1
|
||||||
|
order.payment_state.should == "balance_due"
|
||||||
|
order.payment.state.should == "pending"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context "with un-successful repsonse" do
|
||||||
|
before do
|
||||||
|
Spree::Config.set(:auto_capture => true)
|
||||||
|
purchase_response.stub(:success? => false)
|
||||||
|
end
|
||||||
|
|
||||||
|
it "should log error and redirect to payment step" do
|
||||||
|
paypal_gateway.provider.should_receive(:purchase).with(order_total, anything()).and_return(purchase_response)
|
||||||
|
|
||||||
|
controller.should_receive(:gateway_error).with(purchase_response)
|
||||||
|
|
||||||
|
get :paypal_finish, {:order_id => order.number, :payment_method_id => "123", :token => token, :PayerID => "FWRVKNRRZ3WUC" }
|
||||||
|
|
||||||
|
response.should redirect_to spree.edit_order_checkout_path(order, :state => 'payment')
|
||||||
|
|
||||||
|
order.reload
|
||||||
|
order.update!
|
||||||
|
order.payments.size.should == 1
|
||||||
|
order.payment_state.should == "failed"
|
||||||
|
order.payment.state.should == "failed"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
context "order_opts" do
|
||||||
|
|
||||||
|
it "should return hash containing basic order details" do
|
||||||
|
opts = controller.send(:order_opts, order, paypal_gateway.id, 'payment')
|
||||||
|
|
||||||
|
opts.class.should == Hash
|
||||||
|
opts[:money].should == order_total
|
||||||
|
opts[:subtotal].should == (order.item_total * 100).to_i
|
||||||
|
opts[:order_id].should == order.number
|
||||||
|
opts[:custom].should == order.number
|
||||||
|
opts[:handling].should == 0
|
||||||
|
opts[:shipping].should == (order.ship_total * 100).to_i
|
||||||
|
|
||||||
|
opts[:return_url].should == spree.paypal_confirm_order_checkout_url(order, :payment_method_id => paypal_gateway.id, :host => "test.host")
|
||||||
|
opts[:cancel_return_url].should == spree.edit_order_url(order, :host => "test.host")
|
||||||
|
|
||||||
|
opts[:items].size.should > 0
|
||||||
|
opts[:items].size.should == order.line_items.count
|
||||||
|
end
|
||||||
|
|
||||||
|
it "should include credits in returned hash" do
|
||||||
|
order_total #need here so variable is set before credit is created.
|
||||||
|
order.adjustments.create(:label => "Credit", :amount => -1)
|
||||||
order.update!
|
order.update!
|
||||||
order.payments.size.should == 1
|
|
||||||
order.payment_state.should == "failed"
|
opts = controller.send(:order_opts, order, paypal_gateway.id, 'payment')
|
||||||
order.payment.state.should == "failed"
|
|
||||||
|
opts.class.should == Hash
|
||||||
|
opts[:money].should == order_total - 100
|
||||||
|
opts[:subtotal].should == ((order.item_total * 100) + (order.adjustments.select{|c| c.amount < 0}.sum(&:amount) * 100)).to_i
|
||||||
|
|
||||||
|
opts[:items].size.should == order.line_items.count + 1
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
context "order_opts" do
|
|
||||||
|
|
||||||
it "should return hash containing basic order details" do
|
|
||||||
opts = controller.send(:order_opts, order, paypal_gateway.id, 'payment')
|
|
||||||
|
|
||||||
opts.class.should == Hash
|
|
||||||
opts[:money].should == order_total
|
|
||||||
opts[:subtotal].should == (order.item_total * 100).to_i
|
|
||||||
opts[:order_id].should == order.number
|
|
||||||
opts[:custom].should == order.number
|
|
||||||
opts[:handling].should == 0
|
|
||||||
opts[:shipping].should == (order.ship_total * 100).to_i
|
|
||||||
|
|
||||||
opts[:return_url].should == paypal_confirm_order_checkout_url(order, :payment_method_id => paypal_gateway.id)
|
|
||||||
opts[:cancel_return_url].should == edit_order_url(order)
|
|
||||||
|
|
||||||
opts[:items].size.should > 0
|
|
||||||
opts[:items].size.should == order.line_items.count
|
|
||||||
end
|
|
||||||
|
|
||||||
it "should include credits in returned hash" do
|
|
||||||
order_total #need here so variable is set before credit is created.
|
|
||||||
order.adjustments.create(:label => "Credit", :amount => -1)
|
|
||||||
order.update!
|
|
||||||
|
|
||||||
opts = controller.send(:order_opts, order, paypal_gateway.id, 'payment')
|
|
||||||
|
|
||||||
opts.class.should == Hash
|
|
||||||
opts[:money].should == order_total - 100
|
|
||||||
opts[:subtotal].should == ((order.item_total * 100) + (order.adjustments.select{|c| c.amount < 0}.sum(&:amount) * 100)).to_i
|
|
||||||
|
|
||||||
opts[:items].size.should == order.line_items.count + 1
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -7,5 +7,5 @@ Factory.define(:ppx_order) do |record|
|
||||||
end
|
end
|
||||||
|
|
||||||
Factory.define :ppx_order_with_totals, :parent => :order do |f|
|
Factory.define :ppx_order_with_totals, :parent => :order do |f|
|
||||||
f.after_create { |order| Factory(:line_item, :order => order) }
|
f.after_create { |order| Factory(:line_item, :order => order, :price => 10) and order.line_items.reload }
|
||||||
end
|
end
|
||||||
|
|
|
@ -4,8 +4,13 @@ ENV["RAILS_ENV"] ||= 'test'
|
||||||
require File.expand_path("../dummy/config/environment", __FILE__)
|
require File.expand_path("../dummy/config/environment", __FILE__)
|
||||||
require 'rspec/rails'
|
require 'rspec/rails'
|
||||||
|
|
||||||
|
# Requires supporting ruby files with custom matchers and macros, etc,
|
||||||
|
# in spec/support/ and its subdirectories.
|
||||||
|
Dir[File.join(File.dirname(__FILE__), "support/**/*.rb")].each {|f| require f }
|
||||||
|
|
||||||
#include spree's factories
|
#include spree's factories
|
||||||
require 'spree/core/testing_support/factories'
|
require 'spree/core/testing_support/factories'
|
||||||
|
require 'spree/core/testing_support/fixtures'
|
||||||
|
|
||||||
# include local factories
|
# include local factories
|
||||||
Dir["#{File.dirname(__FILE__)}/factories/**/*.rb"].each do |f|
|
Dir["#{File.dirname(__FILE__)}/factories/**/*.rb"].each do |f|
|
||||||
|
@ -29,6 +34,7 @@ RSpec.configure do |config|
|
||||||
# examples within a transaction, comment the following line or assign false
|
# examples within a transaction, comment the following line or assign false
|
||||||
# instead of true.
|
# instead of true.
|
||||||
config.use_transactional_fixtures = true
|
config.use_transactional_fixtures = true
|
||||||
|
config.include Spree::UrlHelpers
|
||||||
end
|
end
|
||||||
|
|
||||||
Spree::Zone.class_eval do
|
Spree::Zone.class_eval do
|
||||||
|
@ -37,4 +43,12 @@ Spree::Zone.class_eval do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@configuration ||= Spree::AppConfiguration.find_or_create_by_name("Default configuration")
|
# class ActionController::TestCase
|
||||||
|
# module Behavior
|
||||||
|
# def process_with_default_host(action, parameters = nil, session = nil, flash = nil, http_method = 'GET')
|
||||||
|
# parameters = { :host => 'example.com' }.merge( parameters || {} )
|
||||||
|
# process_without_default_host(action, parameters, session, flash, http_method)
|
||||||
|
# end
|
||||||
|
# alias_method_chain :process, :default_host
|
||||||
|
# end
|
||||||
|
# end
|
||||||
|
|
|
@ -0,0 +1,33 @@
|
||||||
|
module Spree
|
||||||
|
module ControllerHacks
|
||||||
|
def get(action, parameters = nil, session = nil, flash = nil)
|
||||||
|
process_spree_action(action, parameters, session, flash, "GET")
|
||||||
|
end
|
||||||
|
|
||||||
|
# Executes a request simulating POST HTTP method and set/volley the response
|
||||||
|
def post(action, parameters = nil, session = nil, flash = nil)
|
||||||
|
process_spree_action(action, parameters, session, flash, "POST")
|
||||||
|
end
|
||||||
|
|
||||||
|
# Executes a request simulating PUT HTTP method and set/volley the response
|
||||||
|
def put(action, parameters = nil, session = nil, flash = nil)
|
||||||
|
process_spree_action(action, parameters, session, flash, "PUT")
|
||||||
|
end
|
||||||
|
|
||||||
|
# Executes a request simulating DELETE HTTP method and set/volley the response
|
||||||
|
def delete(action, parameters = nil, session = nil, flash = nil)
|
||||||
|
process_spree_action(action, parameters, session, flash, "DELETE")
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def process_spree_action(action, parameters = nil, session = nil, flash = nil, method = "GET")
|
||||||
|
parameters ||= {}
|
||||||
|
process(action, parameters.merge!(:use_route => :spree), session, flash, method)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
RSpec.configure do |c|
|
||||||
|
c.include Spree::ControllerHacks, :type => :controller
|
||||||
|
end
|
|
@ -0,0 +1,7 @@
|
||||||
|
module Spree
|
||||||
|
module UrlHelpers
|
||||||
|
def spree
|
||||||
|
Spree::Core::Engine.routes.url_helpers
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in New Issue