diff --git a/app/assets/javascripts/admin/spree_paypal_express.js b/app/assets/javascripts/admin/spree_paypal_express.js new file mode 100644 index 0000000..e69de29 diff --git a/app/assets/javascripts/store/spree_paypal_express.js b/app/assets/javascripts/store/spree_paypal_express.js new file mode 100644 index 0000000..e69de29 diff --git a/app/assets/stylesheets/admin/spree_paypal_express.css b/app/assets/stylesheets/admin/spree_paypal_express.css new file mode 100644 index 0000000..e69de29 diff --git a/app/assets/stylesheets/store/spree_paypal_express.css b/app/assets/stylesheets/store/spree_paypal_express.css new file mode 100644 index 0000000..e69de29 diff --git a/app/controllers/spree/checkout_controller_decorator.rb b/app/controllers/spree/checkout_controller_decorator.rb index 4cb9807..c8d20b8 100644 --- a/app/controllers/spree/checkout_controller_decorator.rb +++ b/app/controllers/spree/checkout_controller_decorator.rb @@ -90,6 +90,7 @@ module Spree @order.ship_address = order_ship_address @order.bill_address ||= order_ship_address end + @order.save if payment_method.preferred_review diff --git a/app/views/spree/shared/paypal_express_confirm.html.erb b/app/views/spree/shared/paypal_express_confirm.html.erb index d7839f9..5bcc1bc 100644 --- a/app/views/spree/shared/paypal_express_confirm.html.erb +++ b/app/views/spree/shared/paypal_express_confirm.html.erb @@ -1,10 +1,3 @@ -

<%= t("confirm") %>

-

- <%= raw t("order_not_yet_placed") %> -

- - -
<%= render :partial => 'spree/shared/error_messages', :locals => { :target => @order } %> @@ -13,6 +6,10 @@
<%= checkout_progress %>
+

+ <%= raw t("order_not_yet_placed") %> +

+
<%= render :partial => 'spree/shared/order_details', :locals => {:order => @order} -%> diff --git a/spec/controllers/checkout_controller_spec.rb b/spec/controllers/checkout_controller_spec.rb index 12bcc17..16838d0 100644 --- a/spec/controllers/checkout_controller_spec.rb +++ b/spec/controllers/checkout_controller_spec.rb @@ -108,7 +108,7 @@ module Spree get :paypal_confirm, {:order_id => order.number, :payment_method_id => "123", :token => token, :PayerID => "FWRVKNRRZ3WUC" } response.should render_template("shared/paypal_express_confirm") - + order.state.should == "payment" end end diff --git a/spec/factories/ppx_factory.rb b/spec/factories/ppx_factory.rb new file mode 100644 index 0000000..86a47d1 --- /dev/null +++ b/spec/factories/ppx_factory.rb @@ -0,0 +1,5 @@ +FactoryGirl.define do + factory :ppx, :class => Spree::BillingIntegration::PaypalExpress, :parent => :payment_method do + name 'Paypal' + end +end \ No newline at end of file diff --git a/spec/requests/paypal_express_spec.rb b/spec/requests/paypal_express_spec.rb index e69de29..0dc20dd 100644 --- a/spec/requests/paypal_express_spec.rb +++ b/spec/requests/paypal_express_spec.rb @@ -0,0 +1,40 @@ +require 'spec_helper' + +feature "paypal express" 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 + 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") + sign_in_as! FactoryGirl.create(:user) + + Factory(:ppx) + end + + let!(:address) { FactoryGirl.create(:address, :state => Spree::State.first) } + + scenario "can use paypal confirm", :js => true do + visit spree.product_path(@product) + + click_button "Add To Cart" + click_link "Checkout" + + str_addr = "bill_address" + select "United States", :from => "order_#{str_addr}_attributes_country_id" + ['firstname', 'lastname', 'address1', 'city', 'zipcode', 'phone'].each do |field| + fill_in "order_#{str_addr}_attributes_#{field}", :with => "#{address.send(field)}" + end + save_and_open_page + + + select "#{address.state.name}", :from => "order_#{str_addr}_attributes_state_id" + check "order_use_billing" + click_button "Save and Continue" + + choose "Paypal" + pending + click_button "Save and Continue" + end +end \ No newline at end of file diff --git a/spec/support/authentication_helpers.rb b/spec/support/authentication_helpers.rb new file mode 100644 index 0000000..2de8eb3 --- /dev/null +++ b/spec/support/authentication_helpers.rb @@ -0,0 +1,13 @@ +module AuthenticationHelpers + def sign_in_as!(user) + visit '/login' + fill_in 'Email', :with => user.email + fill_in 'Password', :with => 'secret' + click_button 'Login' + end + +end + +RSpec.configure do |c| + c.include AuthenticationHelpers, :type => :request +end