diff --git a/Rakefile b/Rakefile index 29b6b92..4f5c785 100644 --- a/Rakefile +++ b/Rakefile @@ -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 diff --git a/app/controllers/spree/checkout_controller_decorator.rb b/app/controllers/spree/checkout_controller_decorator.rb index 81801f9..bfca620 100644 --- a/app/controllers/spree/checkout_controller_decorator.rb +++ b/app/controllers/spree/checkout_controller_decorator.rb @@ -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! diff --git a/app/helpers/spree/checkout_helper_decorator.rb b/app/helpers/spree/checkout_helper_decorator.rb new file mode 100644 index 0000000..e7af68a --- /dev/null +++ b/app/helpers/spree/checkout_helper_decorator.rb @@ -0,0 +1,7 @@ +Spree::CheckoutHelper.module_eval do + + def checkout_states + %w(address delivery payment confirm complete) + end + +end diff --git a/app/views/spree/checkout/payment/_paypalexpress.html.erb b/app/views/spree/checkout/payment/_paypalexpress.html.erb index f511a03..c64e045 100644 --- a/app/views/spree/checkout/payment/_paypalexpress.html.erb +++ b/app/views/spree/checkout/payment/_paypalexpress.html.erb @@ -1,3 +1,3 @@ - + diff --git a/lib/tasks/spree_paypal_express.rake b/lib/tasks/spree_paypal_express.rake deleted file mode 100644 index 07567fb..0000000 --- a/lib/tasks/spree_paypal_express.rake +++ /dev/null @@ -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 diff --git a/spec/controllers/checkout_controller_spec.rb b/spec/controllers/checkout_controller_spec.rb index 1c4fa22..8a30e5f 100644 --- a/spec/controllers/checkout_controller_spec.rb +++ b/spec/controllers/checkout_controller_spec.rb @@ -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 \ No newline at end of file +end diff --git a/spec/models/billing_integration/paypal_express_base_spec.rb b/spec/models/billing_integration/paypal_express_base_spec.rb index a346839..d58b5c4 100644 --- a/spec/models/billing_integration/paypal_express_base_spec.rb +++ b/spec/models/billing_integration/paypal_express_base_spec.rb @@ -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 diff --git a/spec/requests/paypal_express_spec.rb b/spec/requests/paypal_express_spec.rb index 0d8c33c..63cdb58 100644 --- a/spec/requests/paypal_express_spec.rb +++ b/spec/requests/paypal_express_spec.rb @@ -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 \ No newline at end of file +end