Updated to work with 1-1 proper

This commit is contained in:
Brian Quinn 2012-07-20 11:23:01 +01:00
parent 042e013be7
commit 8ca407b1e4
8 changed files with 27 additions and 57 deletions

View File

@ -1,26 +1,10 @@
require 'rake'
require 'rake/testtask'
require 'rake/packagetask'
require 'rubygems/package_task'
require 'rspec/core/rake_task'
require 'spree/core/testing_support/common_rake'
RSpec::Core::RakeTask.new
task :default => [:spec, :cucumber ]
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
task :default => [:spec ]
desc "Generates a dummy app for testing"
task :test_app do

View File

@ -127,7 +127,7 @@ module Spree
:source => paypal_account,
:source_type => 'Spree::PaypalAccount',
: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"])
payment.started_processing!

View File

@ -0,0 +1,7 @@
Spree::CheckoutHelper.module_eval do
def checkout_states
%w(address delivery payment confirm complete)
end
end

View File

@ -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;"/>
</a>

View File

@ -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

View File

@ -14,7 +14,7 @@ module Spree
let(:details_for_response) { mock(ActiveMerchant::Billing::PaypalExpressResponse, :success? => true,
: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"},
:avs_result => "F",
:to_yaml => "fake") }
@ -167,7 +167,7 @@ module Spree
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,
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"},
:avs_result => "F",
:to_yaml => "fake") }
@ -318,4 +318,4 @@ module Spree
end
end
end
end
end

View File

@ -18,7 +18,7 @@ describe Spree::BillingIntegration::PaypalExpressBase do
let(:provider) { gateway.provider }
let(:account) do
mock_model(Spree::PaypalAccount)
stub_model(Spree::PaypalAccount)
end
let(:payment) do

View File

@ -1,10 +1,10 @@
require 'spec_helper'
feature "paypal express" do
feature "Paypal Express checkout" do
background do
PAYMENT_STATES = Spree::Payment.state_machine.states.keys unless defined? PAYMENT_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
# PAYMENT_STATES = Spree::Payment.state_machine.states.keys unless defined? PAYMENT_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
FactoryGirl.create(:shipping_method, :zone => Spree::Zone.find_by_name('North America'))
FactoryGirl.create(:payment_method, :environment => 'test')
@product = FactoryGirl.create(:product, :name => "RoR Mug")
@ -15,7 +15,7 @@ feature "paypal express" do
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)
click_button "Add To Cart"
@ -31,8 +31,13 @@ feature "paypal express" do
check "order_use_billing"
click_button "Save and Continue"
pending
choose "Paypal"
#delivery
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