From 4967093b72e52392df4fe383ba73bb057771696c Mon Sep 17 00:00:00 2001 From: David Cook Date: Tue, 11 Jun 2013 15:07:41 +1000 Subject: [PATCH 01/17] Add capture button and resize columns --- app/overrides/add_capture_order_shortcut.rb | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 app/overrides/add_capture_order_shortcut.rb diff --git a/app/overrides/add_capture_order_shortcut.rb b/app/overrides/add_capture_order_shortcut.rb new file mode 100644 index 0000000000..c64379f866 --- /dev/null +++ b/app/overrides/add_capture_order_shortcut.rb @@ -0,0 +1,21 @@ +Deface::Override.new(:virtual_path => "spree/admin/orders/index", + :name => "add_capture_order_shortcut", + :insert_bottom => "[data-hook='admin_orders_index_row_actions']", + #copied from backend / app / views / spree / admin / payments / _list.html.erb: + :text => '<% order.payment.actions.grep(/^capture$/).each do |action| %> + <%= link_to_with_icon "icon-#{action}", t(action), fire_admin_order_payment_path(order, order.payment, :e => action), :method => :put, :no_text => true, :data => {:action => action} %> + <% end %>' + ) + +#Resize columns to fit new button (note: this may break with a new version of spree) +Deface::Override.new(:virtual_path => "spree/admin/orders/index", + :name => "add_capture_order_shortcut_first_column", + :set_attributes => "#listing_orders colgroup col:first-child", + :attributes => {:style => "width: 12%"} #was 16% + ) +Deface::Override.new(:virtual_path => "spree/admin/orders/index", + :name => "add_capture_order_shortcut_last_column", + :set_attributes => "#listing_orders colgroup col:last-child", + :attributes => {:style => "width: 12%"} #was 8% + ) + From df769a2f4ced3a787afb1675ca6256e5d0e6194d Mon Sep 17 00:00:00 2001 From: David Cook Date: Tue, 11 Jun 2013 16:57:14 +1000 Subject: [PATCH 02/17] ensure latest 'payment' object is used for the capture button --- app/overrides/add_capture_order_shortcut.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/overrides/add_capture_order_shortcut.rb b/app/overrides/add_capture_order_shortcut.rb index c64379f866..e0f22cb0da 100644 --- a/app/overrides/add_capture_order_shortcut.rb +++ b/app/overrides/add_capture_order_shortcut.rb @@ -2,7 +2,7 @@ Deface::Override.new(:virtual_path => "spree/admin/orders/index", :name => "add_capture_order_shortcut", :insert_bottom => "[data-hook='admin_orders_index_row_actions']", #copied from backend / app / views / spree / admin / payments / _list.html.erb: - :text => '<% order.payment.actions.grep(/^capture$/).each do |action| %> + :text => '<% order.payments.last.actions.grep(/^capture$/).each do |action| %> <%= link_to_with_icon "icon-#{action}", t(action), fire_admin_order_payment_path(order, order.payment, :e => action), :method => :put, :no_text => true, :data => {:action => action} %> <% end %>' ) From fb25946acd83eb7dcf1562c4489c561064ac5ac2 Mon Sep 17 00:00:00 2001 From: David Cook Date: Tue, 11 Jun 2013 17:00:07 +1000 Subject: [PATCH 03/17] Start to write a test spec.. (not complete) --- spec/features/admin/order_spec.rb | 46 +++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 spec/features/admin/order_spec.rb diff --git a/spec/features/admin/order_spec.rb b/spec/features/admin/order_spec.rb new file mode 100644 index 0000000000..5e86e7e12e --- /dev/null +++ b/spec/features/admin/order_spec.rb @@ -0,0 +1,46 @@ +require "spec_helper" + +feature %q{ + As a payment administrator + I want to capture multiple payments quickly from the one page +} do + include AuthenticationWorkflow + include WebHelper + + background do + #unfinished.. need to set up test data here + @user = create(:user) + #ref: order_factory https://github.com/spree/spree/blob/b4353b88a4fc56fa95303a48409a623f68f7f659/core/lib/spree/testing_support/factories/order_factory.rb + @orders = (1..3).map {create(:order_with_line_items, :user => @user, :bill_address => '', :ship_address => '')} + + end + + context "managing orders" do + scenario "capture multiple payments from the orders index page" do + #d.cook: could also test for an order that has had payment voided, then a new check payment created but not yet captured. But it's not critical and I know it works anyway. + login_to_admin_section + + click_link 'Orders' + + @orders.each |order| + + #click the link for the order + click_link "[data-action=capture]" + #click_link "[data-action=capture][href|=R#{order.number}]" #not sure if possible to select value within an attribute value, |= doesn't work + + #we should be notified + flash_message.should == "Payment Updated" + + #check the order was captured + order.payment_status.should == :captured + + #we should still be on the right page + + + end #orders.each + + + end #scenario + + end #context +end From ada95183a29529811469b4dff181e8db5ca7d578 Mon Sep 17 00:00:00 2001 From: David Cook Date: Tue, 11 Jun 2013 17:09:41 +1000 Subject: [PATCH 04/17] Start respond_override --- .../spree/admin/payments_controller_decorator.rb | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 app/controllers/spree/admin/payments_controller_decorator.rb diff --git a/app/controllers/spree/admin/payments_controller_decorator.rb b/app/controllers/spree/admin/payments_controller_decorator.rb new file mode 100644 index 0000000000..11894d5fe0 --- /dev/null +++ b/app/controllers/spree/admin/payments_controller_decorator.rb @@ -0,0 +1,9 @@ +# If a user fires an event on a payment from the orders page, set the responder to takes you back to the orders page (not payments page) +#Responder: http://guides.spreecommerce.com/developer/logic.html#overriding-controller-action-responses + +Spree::Admin::PaymentsController.class_eval do + respond_override :fire => { :html => { :success => lambda { + #if referrer == orders#index + # redirect_to orders#index + } } } +end From 269c6ac14fca03aeb4d4bfd32bcac6c613c99c41 Mon Sep 17 00:00:00 2001 From: David Cook Date: Tue, 11 Jun 2013 17:16:37 +1000 Subject: [PATCH 05/17] Use CSS substring selector for selecting Capture link by order number --- spec/features/admin/order_spec.rb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/spec/features/admin/order_spec.rb b/spec/features/admin/order_spec.rb index 5e86e7e12e..f4e4f1f0cd 100644 --- a/spec/features/admin/order_spec.rb +++ b/spec/features/admin/order_spec.rb @@ -25,8 +25,7 @@ feature %q{ @orders.each |order| #click the link for the order - click_link "[data-action=capture]" - #click_link "[data-action=capture][href|=R#{order.number}]" #not sure if possible to select value within an attribute value, |= doesn't work + click_link "[data-action=capture][href*=R#{order.number}]" #we should be notified flash_message.should == "Payment Updated" From 2b15f92ab8c613966c26a26cc4f254d9160352b2 Mon Sep 17 00:00:00 2001 From: David Cook Date: Wed, 12 Jun 2013 09:58:44 +1000 Subject: [PATCH 06/17] fix capture button to link to latest payment --- app/overrides/add_capture_order_shortcut.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/overrides/add_capture_order_shortcut.rb b/app/overrides/add_capture_order_shortcut.rb index e0f22cb0da..005fe34d14 100644 --- a/app/overrides/add_capture_order_shortcut.rb +++ b/app/overrides/add_capture_order_shortcut.rb @@ -3,7 +3,7 @@ Deface::Override.new(:virtual_path => "spree/admin/orders/index", :insert_bottom => "[data-hook='admin_orders_index_row_actions']", #copied from backend / app / views / spree / admin / payments / _list.html.erb: :text => '<% order.payments.last.actions.grep(/^capture$/).each do |action| %> - <%= link_to_with_icon "icon-#{action}", t(action), fire_admin_order_payment_path(order, order.payment, :e => action), :method => :put, :no_text => true, :data => {:action => action} %> + <%= link_to_with_icon "icon-#{action}", t(action), fire_admin_order_payment_path(order, order.payments.last, :e => action), :method => :put, :no_text => true, :data => {:action => action} %> <% end %>' ) From cf4582c08e3609cd760251c07fe2ecb98302d8f5 Mon Sep 17 00:00:00 2001 From: David Cook Date: Wed, 12 Jun 2013 11:24:49 +1000 Subject: [PATCH 07/17] Create respond_override to return user back to the referring page. (But it breaks payments#create respond_with..) --- .../spree/admin/payments_controller_decorator.rb | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/app/controllers/spree/admin/payments_controller_decorator.rb b/app/controllers/spree/admin/payments_controller_decorator.rb index 11894d5fe0..ff3da521b1 100644 --- a/app/controllers/spree/admin/payments_controller_decorator.rb +++ b/app/controllers/spree/admin/payments_controller_decorator.rb @@ -1,9 +1,16 @@ # If a user fires an event on a payment from the orders page, set the responder to takes you back to the orders page (not payments page) #Responder: http://guides.spreecommerce.com/developer/logic.html#overriding-controller-action-responses +#TODO: for some reason this :fire responder kills the payments#create respond_with.. (core/app/controllers/spree/admin/payments_controller.rb:37) + Spree::Admin::PaymentsController.class_eval do respond_override :fire => { :html => { :success => lambda { - #if referrer == orders#index - # redirect_to orders#index - } } } + redirect_to request.referer #keeps any filter and sort prefs + + #if request.referrer.path_parameters['controller'] == 'spree/admin/orders' + # redirect_to admin_orders_path + #else + # redirect_to admin_order_payments_path(@order) #default action + #end + } } } end From 415de37a6afcd9e95fbdcfbfa0dd6915fee061a6 Mon Sep 17 00:00:00 2001 From: David Cook Date: Wed, 12 Jun 2013 13:33:15 +1000 Subject: [PATCH 08/17] WIP for order spec --- spec/features/admin/order_spec.rb | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/spec/features/admin/order_spec.rb b/spec/features/admin/order_spec.rb index f4e4f1f0cd..d952f85b34 100644 --- a/spec/features/admin/order_spec.rb +++ b/spec/features/admin/order_spec.rb @@ -22,10 +22,10 @@ feature %q{ click_link 'Orders' - @orders.each |order| + @orders.each do |order| #click the link for the order - click_link "[data-action=capture][href*=R#{order.number}]" + click_link "[data-action=capture][href*=R#{order.order_id}]" #we should be notified flash_message.should == "Payment Updated" @@ -37,9 +37,6 @@ feature %q{ end #orders.each - - end #scenario - end #context -end +end #feature From 017275f40ea2d13bab8f4899d8455061561a8f76 Mon Sep 17 00:00:00 2001 From: David Cook Date: Wed, 12 Jun 2013 15:40:36 +1000 Subject: [PATCH 09/17] fix error when order has no payments (ie not yet complete) --- app/overrides/add_capture_order_shortcut.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/overrides/add_capture_order_shortcut.rb b/app/overrides/add_capture_order_shortcut.rb index 005fe34d14..b27dd95783 100644 --- a/app/overrides/add_capture_order_shortcut.rb +++ b/app/overrides/add_capture_order_shortcut.rb @@ -2,8 +2,10 @@ Deface::Override.new(:virtual_path => "spree/admin/orders/index", :name => "add_capture_order_shortcut", :insert_bottom => "[data-hook='admin_orders_index_row_actions']", #copied from backend / app / views / spree / admin / payments / _list.html.erb: - :text => '<% order.payments.last.actions.grep(/^capture$/).each do |action| %> - <%= link_to_with_icon "icon-#{action}", t(action), fire_admin_order_payment_path(order, order.payments.last, :e => action), :method => :put, :no_text => true, :data => {:action => action} %> + :text => '<% if ! order.payments.empty? %> + <% order.payments.last.actions.grep(/^capture$/).each do |action| %> + <%= link_to_with_icon "icon-#{action}", t(action), fire_admin_order_payment_path(order, order.payments.last, :e => action), :method => :put, :no_text => true, :data => {:action => action} %> + <% end %> <% end %>' ) From 30253ffd074374342ba7fd5ce8d5b52b206623c3 Mon Sep 17 00:00:00 2001 From: David Cook Date: Wed, 12 Jun 2013 15:51:07 +1000 Subject: [PATCH 10/17] align actions column left for better usability --- app/overrides/add_capture_order_shortcut.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/overrides/add_capture_order_shortcut.rb b/app/overrides/add_capture_order_shortcut.rb index b27dd95783..0fef9db5d4 100644 --- a/app/overrides/add_capture_order_shortcut.rb +++ b/app/overrides/add_capture_order_shortcut.rb @@ -20,4 +20,9 @@ Deface::Override.new(:virtual_path => "spree/admin/orders/index", :set_attributes => "#listing_orders colgroup col:last-child", :attributes => {:style => "width: 12%"} #was 8% ) - +#And align actions column (not spree standard, but looks better IMO) +Deface::Override.new(:virtual_path => "spree/admin/orders/index", + :name => "add_capture_order_shortcut_align", + :set_attributes => "[data-hook='admin_orders_index_row_actions']", + :attributes => {:class => "actions", :style => "text-align:left;"} #removes 'align-center' class + ) From a76232bb7e5083b504130c64ffbe374996300425 Mon Sep 17 00:00:00 2001 From: David Cook Date: Fri, 12 Jul 2013 14:02:37 +1000 Subject: [PATCH 11/17] Make sure admin_user has admin privilege for new version of Spree --- spec/support/request/authentication_workflow.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/support/request/authentication_workflow.rb b/spec/support/request/authentication_workflow.rb index df9ab27558..ce9cef74b0 100644 --- a/spec/support/request/authentication_workflow.rb +++ b/spec/support/request/authentication_workflow.rb @@ -8,7 +8,7 @@ module AuthenticationWorkflow :remember_me => false, :persistence_token => 'pass', :login => 'admin@ofw.org', - :role_ids => [admin_role.id]}) + :spree_role_ids => [admin_role.id]}) visit spree.admin_path fill_in 'user_email', :with => 'admin@ofw.org' From 4fc0608a44b8280a5bcf5f28f8664e06ff5db798 Mon Sep 17 00:00:00 2001 From: David Cook Date: Fri, 12 Jul 2013 16:41:20 +1000 Subject: [PATCH 12/17] Finish capture order test --- spec/features/admin/order_spec.rb | 48 +++++++++++++++++-------------- 1 file changed, 27 insertions(+), 21 deletions(-) diff --git a/spec/features/admin/order_spec.rb b/spec/features/admin/order_spec.rb index d952f85b34..9a5da195ec 100644 --- a/spec/features/admin/order_spec.rb +++ b/spec/features/admin/order_spec.rb @@ -8,35 +8,41 @@ feature %q{ include WebHelper background do - #unfinished.. need to set up test data here @user = create(:user) - #ref: order_factory https://github.com/spree/spree/blob/b4353b88a4fc56fa95303a48409a623f68f7f659/core/lib/spree/testing_support/factories/order_factory.rb - @orders = (1..3).map {create(:order_with_line_items, :user => @user, :bill_address => '', :ship_address => '')} - + @order = create(:order_with_totals_and_distributor, :user => @user, :state => 'complete', :payment_state => 'balance_due') + + # ensure order has a payment to capture + create :check_payment, order: @order, amount: @order.amount + + # ensure order shows up as completed + #@order.completed_at = Time.now #to show up in list as completed + #@order.save! + @order.finalize! end context "managing orders" do scenario "capture multiple payments from the orders index page" do - #d.cook: could also test for an order that has had payment voided, then a new check payment created but not yet captured. But it's not critical and I know it works anyway. + # d.cook: could also test for an order that has had payment voided, then a new check payment created but not yet captured. But it's not critical and I know it works anyway. login_to_admin_section click_link 'Orders' + #choose 'Only Show Complete Orders' + #click_button 'Filter Results' - @orders.each do |order| + # click the link for the order + page.find("[data-action=capture][href*=#{@order.number}]").click - #click the link for the order - click_link "[data-action=capture][href*=R#{order.order_id}]" + # we should be notified + flash_message.should == "Payment Updated" + + # check the order was captured + @order.reload + @order.payment_state.should == "paid" + + # we should still be on the right page + page.should have_selector "h1", text: "Listing Orders" #t(:listing_orders) + #current_path.should == admin_orders_path - #we should be notified - flash_message.should == "Payment Updated" - - #check the order was captured - order.payment_status.should == :captured - - #we should still be on the right page - - - end #orders.each - end #scenario - end #context -end #feature + end # scenario + end # context +end #f eature From 0ad7cde1984fad282c594912fbd21253c7f64950 Mon Sep 17 00:00:00 2001 From: David Cook Date: Fri, 12 Jul 2013 16:42:33 +1000 Subject: [PATCH 13/17] Add factory for an order with items and valid distributor --- spec/factories.rb | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/spec/factories.rb b/spec/factories.rb index 67f87abd00..ef9903c208 100644 --- a/spec/factories.rb +++ b/spec/factories.rb @@ -84,6 +84,14 @@ FactoryGirl.define do after(:create) { |c| c.set_preference(:per_kg, 0.5); c.save! } end + #Ensure order has a distributor set + factory :order_with_totals_and_distributor, :parent => :order do #possibly called :order_with_line_items in newer Spree + distributor { create(:distributor_enterprise) } + after(:create) do |order| + p = create(:simple_product, :distributors => [order.distributor]) + FactoryGirl.create(:line_item, :order => order, :product => p) + end + end end From c9432288c5535aa1f280b5983bf937e7bc80fb69 Mon Sep 17 00:00:00 2001 From: David Cook Date: Tue, 16 Jul 2013 15:36:14 +1000 Subject: [PATCH 14/17] Clean up comments and use admin_orders_path for checking current page --- spec/features/admin/order_spec.rb | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/spec/features/admin/order_spec.rb b/spec/features/admin/order_spec.rb index 9a5da195ec..f7b5ac5269 100644 --- a/spec/features/admin/order_spec.rb +++ b/spec/features/admin/order_spec.rb @@ -15,8 +15,6 @@ feature %q{ create :check_payment, order: @order, amount: @order.amount # ensure order shows up as completed - #@order.completed_at = Time.now #to show up in list as completed - #@order.save! @order.finalize! end @@ -26,10 +24,9 @@ feature %q{ login_to_admin_section click_link 'Orders' - #choose 'Only Show Complete Orders' - #click_button 'Filter Results' + current_path.should == spree.admin_orders_path - # click the link for the order + # click the 'capture' link for the order page.find("[data-action=capture][href*=#{@order.number}]").click # we should be notified @@ -40,8 +37,7 @@ feature %q{ @order.payment_state.should == "paid" # we should still be on the right page - page.should have_selector "h1", text: "Listing Orders" #t(:listing_orders) - #current_path.should == admin_orders_path + current_path.should == spree.admin_orders_path end # scenario end # context From 1d2704ab4c61f74016a9adfb9185a552d9e00e90 Mon Sep 17 00:00:00 2001 From: David Cook Date: Tue, 16 Jul 2013 15:55:28 +1000 Subject: [PATCH 15/17] Clean up comments --- .../spree/admin/payments_controller_decorator.rb | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/app/controllers/spree/admin/payments_controller_decorator.rb b/app/controllers/spree/admin/payments_controller_decorator.rb index ff3da521b1..c7225f3f54 100644 --- a/app/controllers/spree/admin/payments_controller_decorator.rb +++ b/app/controllers/spree/admin/payments_controller_decorator.rb @@ -1,16 +1,14 @@ -# If a user fires an event on a payment from the orders page, set the responder to takes you back to the orders page (not payments page) +# When a user fires an event, take them back to where they came from #Responder: http://guides.spreecommerce.com/developer/logic.html#overriding-controller-action-responses -#TODO: for some reason this :fire responder kills the payments#create respond_with.. (core/app/controllers/spree/admin/payments_controller.rb:37) - Spree::Admin::PaymentsController.class_eval do respond_override :fire => { :html => { :success => lambda { redirect_to request.referer #keeps any filter and sort prefs - #if request.referrer.path_parameters['controller'] == 'spree/admin/orders' - # redirect_to admin_orders_path + #if request.referrer.path_parameters['controller'] == spree.admin_orders_path + # redirect_to spree.admin_orders_path #else - # redirect_to admin_order_payments_path(@order) #default action + # redirect_to spree.admin_order_payments_path(@order) #default action #end } } } end From 1dd92d0133d55a053f54f48f12cb323aaa602787 Mon Sep 17 00:00:00 2001 From: Rohan Mitchell Date: Tue, 23 Jul 2013 16:50:42 +1000 Subject: [PATCH 16/17] Move deface to a partial --- app/overrides/add_capture_order_shortcut.rb | 7 +------ app/views/spree/admin/orders/_capture.html.haml | 5 +++++ 2 files changed, 6 insertions(+), 6 deletions(-) create mode 100644 app/views/spree/admin/orders/_capture.html.haml diff --git a/app/overrides/add_capture_order_shortcut.rb b/app/overrides/add_capture_order_shortcut.rb index 0fef9db5d4..f733d31531 100644 --- a/app/overrides/add_capture_order_shortcut.rb +++ b/app/overrides/add_capture_order_shortcut.rb @@ -1,12 +1,7 @@ Deface::Override.new(:virtual_path => "spree/admin/orders/index", :name => "add_capture_order_shortcut", :insert_bottom => "[data-hook='admin_orders_index_row_actions']", - #copied from backend / app / views / spree / admin / payments / _list.html.erb: - :text => '<% if ! order.payments.empty? %> - <% order.payments.last.actions.grep(/^capture$/).each do |action| %> - <%= link_to_with_icon "icon-#{action}", t(action), fire_admin_order_payment_path(order, order.payments.last, :e => action), :method => :put, :no_text => true, :data => {:action => action} %> - <% end %> - <% end %>' + :partial => 'spree/admin/orders/capture' ) #Resize columns to fit new button (note: this may break with a new version of spree) diff --git a/app/views/spree/admin/orders/_capture.html.haml b/app/views/spree/admin/orders/_capture.html.haml new file mode 100644 index 0000000000..80a7481066 --- /dev/null +++ b/app/views/spree/admin/orders/_capture.html.haml @@ -0,0 +1,5 @@ +-# copied from backend/app/views/spree/admin/payments/_list.html.erb + +- if order.payments.present? + - order.payments.last.actions.grep(/^capture$/).each do |action| + = link_to_with_icon "icon-#{action}", t(action), fire_admin_order_payment_path(order, order.payments.last, :e => action), :method => :put, :no_text => true, :data => {:action => action} From d83e8cb3ba687c2510b7cd588710cfbd7caa3c6d Mon Sep 17 00:00:00 2001 From: Rohan Mitchell Date: Tue, 23 Jul 2013 16:51:22 +1000 Subject: [PATCH 17/17] Remove commented out code, clean up comments and style --- .../spree/admin/payments_controller_decorator.rb | 10 ++-------- spec/factories.rb | 2 +- spec/features/admin/order_spec.rb | 12 ++++-------- 3 files changed, 7 insertions(+), 17 deletions(-) diff --git a/app/controllers/spree/admin/payments_controller_decorator.rb b/app/controllers/spree/admin/payments_controller_decorator.rb index c7225f3f54..df9e77f154 100644 --- a/app/controllers/spree/admin/payments_controller_decorator.rb +++ b/app/controllers/spree/admin/payments_controller_decorator.rb @@ -1,14 +1,8 @@ # When a user fires an event, take them back to where they came from -#Responder: http://guides.spreecommerce.com/developer/logic.html#overriding-controller-action-responses +# Responder: http://guides.spreecommerce.com/developer/logic.html#overriding-controller-action-responses Spree::Admin::PaymentsController.class_eval do respond_override :fire => { :html => { :success => lambda { - redirect_to request.referer #keeps any filter and sort prefs - - #if request.referrer.path_parameters['controller'] == spree.admin_orders_path - # redirect_to spree.admin_orders_path - #else - # redirect_to spree.admin_order_payments_path(@order) #default action - #end + redirect_to request.referer # Keeps any filter and sort prefs } } } end diff --git a/spec/factories.rb b/spec/factories.rb index ef9903c208..41f742b47d 100644 --- a/spec/factories.rb +++ b/spec/factories.rb @@ -84,8 +84,8 @@ FactoryGirl.define do after(:create) { |c| c.set_preference(:per_kg, 0.5); c.save! } end - #Ensure order has a distributor set factory :order_with_totals_and_distributor, :parent => :order do #possibly called :order_with_line_items in newer Spree + # Ensure order has a distributor set distributor { create(:distributor_enterprise) } after(:create) do |order| p = create(:simple_product, :distributors => [order.distributor]) diff --git a/spec/features/admin/order_spec.rb b/spec/features/admin/order_spec.rb index f7b5ac5269..036867bf68 100644 --- a/spec/features/admin/order_spec.rb +++ b/spec/features/admin/order_spec.rb @@ -13,8 +13,6 @@ feature %q{ # ensure order has a payment to capture create :check_payment, order: @order, amount: @order.amount - - # ensure order shows up as completed @order.finalize! end @@ -29,16 +27,14 @@ feature %q{ # click the 'capture' link for the order page.find("[data-action=capture][href*=#{@order.number}]").click - # we should be notified flash_message.should == "Payment Updated" # check the order was captured @order.reload @order.payment_state.should == "paid" - # we should still be on the right page + # we should still be on the same page current_path.should == spree.admin_orders_path - - end # scenario - end # context -end #f eature + end + end +end