From 4f8014306e84c6dca7129304cecc06ea69ad1a42 Mon Sep 17 00:00:00 2001 From: Rohan Mitchell Date: Fri, 23 Aug 2013 13:58:59 +1000 Subject: [PATCH] Admin can't change distributor or order cycle once order has been finalized --- .../add_distribution_fields.html.haml.deface | 26 +++++++++++++------ spec/features/admin/orders_spec.rb | 12 ++++++++- 2 files changed, 29 insertions(+), 9 deletions(-) diff --git a/app/overrides/spree/admin/orders/_form/add_distribution_fields.html.haml.deface b/app/overrides/spree/admin/orders/_form/add_distribution_fields.html.haml.deface index 3f79fccc03..b7c60863d4 100644 --- a/app/overrides/spree/admin/orders/_form/add_distribution_fields.html.haml.deface +++ b/app/overrides/spree/admin/orders/_form/add_distribution_fields.html.haml.deface @@ -3,12 +3,22 @@ %fieldset.no-border-bottom %legend{align => 'center'} Distribution - .alpha.six.columns - .field - = f.label :distributor_id - = f.collection_select :distributor_id, Enterprise.is_distributor.managed_by(spree_current_user), :id, :name, include_blank: true + - if @order.complete? + .alpha.six.columns + %p + %b Distributor: + = f.object.distributor.andand.name || "None" + .omega.six.columns + %p + %b Order cycle: + = f.object.order_cycle.andand.name || "None" - .omega.six.columns - .field - = f.label :order_cycle_id - = f.collection_select :order_cycle_id, OrderCycle.managed_by(spree_current_user), :id, :name, include_blank: true + - else + .alpha.six.columns + .field + = f.label :distributor_id + = f.collection_select :distributor_id, Enterprise.is_distributor.managed_by(spree_current_user), :id, :name, include_blank: true + .omega.six.columns + .field + = f.label :order_cycle_id + = f.collection_select :order_cycle_id, OrderCycle.managed_by(spree_current_user), :id, :name, include_blank: true diff --git a/spec/features/admin/orders_spec.rb b/spec/features/admin/orders_spec.rb index 8c63627505..72ea151d41 100644 --- a/spec/features/admin/orders_spec.rb +++ b/spec/features/admin/orders_spec.rb @@ -43,7 +43,17 @@ feature %q{ o.order_cycle.should == order_cycle end - it "can't change distributor and order cycle once order is created (or similar restriction)" + scenario "can't change distributor or order cycle once order has been finalized" do + login_to_admin_section + click_link 'Orders' + page.find('td.actions a.icon-edit').click + + page.should have_no_select 'order_distributor_id' + page.should have_no_select 'order_order_cycle_id' + + page.should have_selector 'p', text: "Distributor: #{@order.distributor.name}" + page.should have_selector 'p', text: 'Order cycle: None' + end 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.