Admin can't change distributor or order cycle once order has been finalized

This commit is contained in:
Rohan Mitchell
2013-08-23 13:58:59 +10:00
parent 158cd6994b
commit 4f8014306e
2 changed files with 29 additions and 9 deletions

View File

@@ -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

View File

@@ -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.