Updated to work with 1-1 proper
This commit is contained in:
parent
042e013be7
commit
8ca407b1e4
18
Rakefile
18
Rakefile
|
@ -1,26 +1,10 @@
|
||||||
require 'rake'
|
require 'rake'
|
||||||
require 'rake/testtask'
|
|
||||||
require 'rake/packagetask'
|
|
||||||
require 'rubygems/package_task'
|
|
||||||
require 'rspec/core/rake_task'
|
require 'rspec/core/rake_task'
|
||||||
require 'spree/core/testing_support/common_rake'
|
require 'spree/core/testing_support/common_rake'
|
||||||
|
|
||||||
RSpec::Core::RakeTask.new
|
RSpec::Core::RakeTask.new
|
||||||
|
|
||||||
task :default => [:spec, :cucumber ]
|
task :default => [:spec ]
|
||||||
|
|
||||||
spec = eval(File.read('spree_paypal_express.gemspec'))
|
|
||||||
|
|
||||||
Gem::PackageTask.new(spec) do |p|
|
|
||||||
p.gem_spec = spec
|
|
||||||
end
|
|
||||||
|
|
||||||
desc "Release to gemcutter"
|
|
||||||
task :release => :package do
|
|
||||||
require 'rake/gemcutter'
|
|
||||||
Rake::Gemcutter::Tasks.new(spec).define
|
|
||||||
Rake::Task['gem:push'].invoke
|
|
||||||
end
|
|
||||||
|
|
||||||
desc "Generates a dummy app for testing"
|
desc "Generates a dummy app for testing"
|
||||||
task :test_app do
|
task :test_app do
|
||||||
|
|
|
@ -127,7 +127,7 @@ module Spree
|
||||||
:source => paypal_account,
|
:source => paypal_account,
|
||||||
:source_type => 'Spree::PaypalAccount',
|
:source_type => 'Spree::PaypalAccount',
|
||||||
:payment_method_id => params[:payment_method_id],
|
:payment_method_id => params[:payment_method_id],
|
||||||
:response_code => ppx_auth_response.params["ack"],
|
:response_code => ppx_auth_response.authorization,
|
||||||
:avs_response => ppx_auth_response.avs_result["code"])
|
:avs_response => ppx_auth_response.avs_result["code"])
|
||||||
|
|
||||||
payment.started_processing!
|
payment.started_processing!
|
||||||
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
Spree::CheckoutHelper.module_eval do
|
||||||
|
|
||||||
|
def checkout_states
|
||||||
|
%w(address delivery payment confirm complete)
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
|
@ -1,3 +1,3 @@
|
||||||
<a href="<%= paypal_payment_order_checkout_url @order, :payment_method_id => payment_method %>" style="text-align: center;">
|
<a id="ppx" href="<%= paypal_payment_order_checkout_url @order, :payment_method_id => payment_method %>" style="text-align: center;">
|
||||||
<img src="https://www.paypal.com/en_US/i/btn/btn_xpressCheckout.gif" align="left" style="margin-right:7px;"/>
|
<img src="https://www.paypal.com/en_US/i/btn/btn_xpressCheckout.gif" align="left" style="margin-right:7px;"/>
|
||||||
</a>
|
</a>
|
||||||
|
|
|
@ -1,26 +0,0 @@
|
||||||
namespace :spree_paypal_express do
|
|
||||||
desc "Copies all migrations and assets (NOTE: This will be obsolete with Rails 3.1)"
|
|
||||||
task :install do
|
|
||||||
Rake::Task['spree_paypal_express:install:migrations'].invoke
|
|
||||||
Rake::Task['spree_paypal_express:install:assets'].invoke
|
|
||||||
end
|
|
||||||
|
|
||||||
namespace :install do
|
|
||||||
desc "Copies all migrations (NOTE: This will be obsolete with Rails 3.1)"
|
|
||||||
task :migrations do
|
|
||||||
source = File.join(File.dirname(__FILE__), '..', '..', 'db')
|
|
||||||
destination = File.join(Rails.root, 'db')
|
|
||||||
puts "INFO: Mirroring assets from #{source} to #{destination}"
|
|
||||||
Spree::Core::FileUtilz.mirror_files(source, destination)
|
|
||||||
end
|
|
||||||
|
|
||||||
desc "Copies all assets (NOTE: This will be obsolete with Rails 3.1)"
|
|
||||||
task :assets do
|
|
||||||
source = File.join(File.dirname(__FILE__), '..', '..', 'public')
|
|
||||||
destination = File.join(Rails.root, 'public')
|
|
||||||
puts "INFO: Mirroring assets from #{source} to #{destination}"
|
|
||||||
Spree::Core::FileUtilz.mirror_files(source, destination)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
|
|
@ -14,7 +14,7 @@ module Spree
|
||||||
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, :authorization => 'ABC123456789',
|
||||||
: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") }
|
||||||
|
@ -167,7 +167,7 @@ module Spree
|
||||||
|
|
||||||
context "paypal_finish" do
|
context "paypal_finish" do
|
||||||
let(:paypal_account) { stub_model(PaypalAccount, :payer_id => "FWRVKNRRZ3WUC", :email => order.email ) }
|
let(:paypal_account) { stub_model(PaypalAccount, :payer_id => "FWRVKNRRZ3WUC", :email => order.email ) }
|
||||||
let(:authorize_response) { mock(ActiveMerchant::Billing::PaypalExpressResponse, :success? => true,
|
let(:authorize_response) { mock(ActiveMerchant::Billing::PaypalExpressResponse, :success? => true, :authorization => 'ABC123456789',
|
||||||
:params => {"payer" => order.user.email, "payer_id" => "FWRVKNRRZ3WUC", "gross_amount" => order_total, "payment_status" => "Pending"},
|
:params => {"payer" => order.user.email, "payer_id" => "FWRVKNRRZ3WUC", "gross_amount" => order_total, "payment_status" => "Pending"},
|
||||||
:avs_result => "F",
|
:avs_result => "F",
|
||||||
:to_yaml => "fake") }
|
:to_yaml => "fake") }
|
||||||
|
|
|
@ -18,7 +18,7 @@ describe Spree::BillingIntegration::PaypalExpressBase do
|
||||||
let(:provider) { gateway.provider }
|
let(:provider) { gateway.provider }
|
||||||
|
|
||||||
let(:account) do
|
let(:account) do
|
||||||
mock_model(Spree::PaypalAccount)
|
stub_model(Spree::PaypalAccount)
|
||||||
end
|
end
|
||||||
|
|
||||||
let(:payment) do
|
let(:payment) do
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
require 'spec_helper'
|
require 'spec_helper'
|
||||||
|
|
||||||
feature "paypal express" do
|
feature "Paypal Express checkout" do
|
||||||
background do
|
background do
|
||||||
PAYMENT_STATES = Spree::Payment.state_machine.states.keys unless defined? PAYMENT_STATES
|
# PAYMENT_STATES = Spree::Payment.state_machine.states.keys unless defined? PAYMENT_STATES
|
||||||
SHIPMENT_STATES = Spree::Shipment.state_machine.states.keys unless defined? SHIPMENT_STATES
|
# SHIPMENT_STATES = Spree::Shipment.state_machine.states.keys unless defined? SHIPMENT_STATES
|
||||||
ORDER_STATES = Spree::Order.state_machine.states.keys unless defined? ORDER_STATES
|
# ORDER_STATES = Spree::Order.state_machine.states.keys unless defined? ORDER_STATES
|
||||||
FactoryGirl.create(:shipping_method, :zone => Spree::Zone.find_by_name('North America'))
|
FactoryGirl.create(:shipping_method, :zone => Spree::Zone.find_by_name('North America'))
|
||||||
FactoryGirl.create(:payment_method, :environment => 'test')
|
FactoryGirl.create(:payment_method, :environment => 'test')
|
||||||
@product = FactoryGirl.create(:product, :name => "RoR Mug")
|
@product = FactoryGirl.create(:product, :name => "RoR Mug")
|
||||||
|
@ -15,7 +15,7 @@ feature "paypal express" do
|
||||||
|
|
||||||
let!(:address) { FactoryGirl.create(:address, :state => Spree::State.first) }
|
let!(:address) { FactoryGirl.create(:address, :state => Spree::State.first) }
|
||||||
|
|
||||||
scenario "can use paypal confirm", :js => true do
|
scenario "should display paypal link", :js => true do
|
||||||
visit spree.product_path(@product)
|
visit spree.product_path(@product)
|
||||||
|
|
||||||
click_button "Add To Cart"
|
click_button "Add To Cart"
|
||||||
|
@ -31,8 +31,13 @@ feature "paypal express" do
|
||||||
check "order_use_billing"
|
check "order_use_billing"
|
||||||
click_button "Save and Continue"
|
click_button "Save and Continue"
|
||||||
|
|
||||||
pending
|
#delivery
|
||||||
choose "Paypal"
|
|
||||||
click_button "Save and Continue"
|
click_button "Save and Continue"
|
||||||
|
|
||||||
|
choose "Paypal"
|
||||||
|
page.should have_selector('a#ppx')
|
||||||
|
click_button "Save and Continue"
|
||||||
|
|
||||||
|
current_path.should match /\A\/orders\/[A-Z][0-9]{9}\/checkout\/paypal_payment\z/
|
||||||
end
|
end
|
||||||
end
|
end
|
Loading…
Reference in New Issue