Rename 'Change Pick-up Date' to 'Change Collection Date'. Fix this to clear the cart. Do not clear distributor when setting Order.order_cycle to nil.

This commit is contained in:
Rohan Mitchell
2013-09-10 11:28:49 +10:00
parent d43df754d3
commit 0e8443e118
5 changed files with 36 additions and 6 deletions

View File

@@ -64,10 +64,9 @@ Spree::OrdersController.class_eval do
def clear
@order = current_order(true)
current_distributor = @order.distributor
@order.order_cycle = nil
@order.empty!
@order.set_order_cycle! nil
redirect_to main_app.shop_enterprise_path(current_distributor.id)
redirect_to main_app.enterprise_path(@order.distributor.id)
end
private

View File

@@ -51,7 +51,7 @@ Spree::Order.class_eval do
def set_order_cycle!(order_cycle)
self.order_cycle = order_cycle
self.distributor = nil unless self.order_cycle.andand.has_distributor? distributor
self.distributor = nil unless order_cycle.nil? || order_cycle.has_distributor?(distributor)
save!
end

View File

@@ -4,9 +4,9 @@
.columns.six
%h1= "Your order will be ready on #{current_order_cycle.exchanges.to_enterprises(current_distributor).outgoing.first.pickup_time}"
%i
= link_to 'Change Pick-up Date', spree.clear_orders_path, :id => 'reset_order_cycle'
= link_to 'Change Collection Date', spree.clear_orders_path, :id => 'reset_order_cycle'
(This will reset your cart)
%p Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore
%p.hide Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore
.columns.five
.row
%strong ORDERS CLOSE

View File

@@ -31,6 +31,33 @@ feature %q{
end
end
scenario "changing order cycle", js: true do
s = create(:supplier_enterprise)
d = create(:distributor_enterprise, name: 'Green Grass')
p = create(:simple_product, supplier: s)
oc = create(:simple_order_cycle, suppliers: [s], distributors: [d], variants: [p.master])
visit spree.root_path
click_link d.name
select_by_value oc.id, from: 'order_order_cycle_id'
click_link p.name
click_button 'Add To Cart'
click_link 'Continue shopping'
click_link 'Change Collection Date'
# Then we should be back at the landing page with a reset cart
page.should have_content 'Green Grass'
page.should have_content 'When do you want your order?'
cart = Spree::Order.last
cart.distributor.should == d
cart.order_cycle.should be_nil
cart.line_items.should be_empty
end
scenario "viewing order cycle and distributor choices", :future => true do
# When I go to the product listing page
visit spree.products_path

View File

@@ -171,10 +171,14 @@ describe Spree::Order do
it "clears the order cycle when setting to nil" do
oc = create(:simple_order_cycle)
d = create(:distributor_enterprise)
subject.set_order_cycle! oc
subject.distributor = d
subject.set_order_cycle! nil
subject.order_cycle.should be_nil
subject.distributor.should == d
end
end