Merge branch 'master' into pin-refunds

This commit is contained in:
Rohan Mitchell
2015-05-01 14:58:19 +10:00
13 changed files with 224 additions and 5 deletions

View File

@@ -0,0 +1,30 @@
require 'spec_helper'
describe Spree::Admin::OrdersController do
let!(:order) { create(:order) }
context "updating an order with line items" do
let(:line_item) { create(:line_item) }
before { login_as_admin }
it "updates distribution charges" do
order.line_items << line_item
order.save
Spree::Order.any_instance.should_receive(:update_distribution_charge!)
spree_put :update, {
id: order,
order: {
number: order.number,
distributor_id: order.distributor_id,
order_cycle_id: order.order_cycle_id,
line_items_attributes: [
{
id: line_item.id,
quantity: line_item.quantity
}
]
}
}
end
end
end

View File

@@ -8,6 +8,7 @@ module Spree
describe "search action" do
let!(:p1) { create(:simple_product, name: 'Product 1') }
let!(:p2) { create(:simple_product, name: 'Product 2') }
let!(:vo) { create(:variant_override, variant: p1.master, hub: d, count_on_hand: 44) }
let!(:d) { create(:distributor_enterprise) }
let!(:oc) { create(:simple_order_cycle, distributors: [d], variants: [p1.master]) }
@@ -16,6 +17,12 @@ module Spree
assigns(:variants).should == [p1.master]
end
it "applies variant overrides" do
spree_get :search, q: 'Prod', distributor_id: d.id.to_s
assigns(:variants).should == [p1.master]
assigns(:variants).first.count_on_hand.should == 44
end
it "filters by order cycle" do
spree_get :search, q: 'Prod', order_cycle_id: oc.id.to_s
assigns(:variants).should == [p1.master]

View File

@@ -186,6 +186,59 @@ describe Spree::Order do
end
end
describe "an order without shipping method" do
let(:order) { create(:order) }
it "cannot be shipped" do
order.ready_to_ship?.should == false
end
end
describe "an unpaid order with a shipment" do
let(:order) { create(:order, shipping_method: shipping_method) }
let(:shipping_method) { create(:shipping_method) }
before do
order.create_shipment!
order.reload
order.state = 'complete'
order.shipment.update!(order)
end
it "cannot be shipped" do
order.ready_to_ship?.should == false
end
end
describe "a paid order without a shipment" do
let(:order) { create(:order) }
before do
order.payment_state = 'paid'
order.state = 'complete'
end
it "cannot be shipped" do
order.ready_to_ship?.should == false
end
end
describe "a paid order with a shipment" do
let(:order) { create(:order, shipping_method: shipping_method) }
let(:shipping_method) { create(:shipping_method) }
before do
order.create_shipment!
order.payment_state = 'paid'
order.state = 'complete'
order.shipment.update!(order)
end
it "can be shipped" do
order.ready_to_ship?.should == true
end
end
describe "getting the shipping tax" do
let(:order) { create(:order, shipping_method: shipping_method) }
let(:shipping_method) { create(:shipping_method, calculator: Spree::Calculator::FlatRate.new(preferred_amount: 50.0)) }