From 6dfd26ac697256909ce407e3ec1be3182b9d727d Mon Sep 17 00:00:00 2001 From: Rohan Mitchell Date: Wed, 16 Jul 2014 10:33:23 +1000 Subject: [PATCH] order_with_totals_and_distribut{or,ion} --- spec/factories.rb | 5 +++-- spec/features/admin/orders_spec.rb | 6 ++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/spec/factories.rb b/spec/factories.rb index 394112125a..64afa6a21a 100644 --- a/spec/factories.rb +++ b/spec/factories.rb @@ -140,9 +140,10 @@ FactoryGirl.define do after(:create) { |c| c.set_preference(:per_kg, 0.5); c.save! } end - factory :order_with_totals_and_distributor, :parent => :order do #possibly called :order_with_line_items in newer Spree - # Ensure order has a distributor set + factory :order_with_totals_and_distribution, :parent => :order do #possibly called :order_with_line_items in newer Spree distributor { create(:distributor_enterprise) } + order_cycle { create(:simple_order_cycle) } + after(:create) do |order| p = create(:simple_product, :distributors => [order.distributor]) FactoryGirl.create(:line_item, :order => order, :product => p) diff --git a/spec/features/admin/orders_spec.rb b/spec/features/admin/orders_spec.rb index 3b8888bd50..04b04eee12 100644 --- a/spec/features/admin/orders_spec.rb +++ b/spec/features/admin/orders_spec.rb @@ -9,7 +9,7 @@ feature %q{ background do @user = create(:user) - @order = create(:order_with_totals_and_distributor, :user => @user, :state => 'complete', :payment_state => 'balance_due') + @order = create(:order_with_totals_and_distribution, user: @user, state: 'complete', payment_state: 'balance_due') # ensure order has a payment to capture @order.finalize! @@ -44,6 +44,8 @@ feature %q{ end scenario "can't change distributor or order cycle once order has been finalized" do + @order.update_attributes order_cycle_id: nil + login_to_admin_section visit '/admin/orders' page.find('td.actions a.icon-edit').click @@ -52,7 +54,7 @@ feature %q{ 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' + page.should have_selector 'p', text: "Order cycle: None" end scenario "capture multiple payments from the orders index page" do