Skip to content

Instantly share code, notes, and snippets.

@djkz
Created June 1, 2012 05:59
Show Gist options
  • Save djkz/2849349 to your computer and use it in GitHub Desktop.
Save djkz/2849349 to your computer and use it in GitHub Desktop.
Issue 1606
require 'spec_helper'
describe "ShipmentsCalculator" do
context "shows the right amount for each shipment", :js => true do
before do
reset_spree_preferences do |config|
config.allow_backorders = true
end
Spree::Zone.delete_all
Spree::ShippingMethod.delete_all
shipping_method = Factory(:shipping_method)
calculator = Spree::Calculator::PerItem.create!({:preferred_amount => 10, :calculable => shipping_method}, :without_protection => true)
shipping_method.calculator = calculator
shipping_method.save
@order = Factory(:order, :number => "R100", :state => "complete", :completed_at => Time.now, :shipping_method => shipping_method)
@order.bill_address = Factory(:address)
@order.ship_address = Factory(:address)
@order.save
product = create(:product, :name => 'spree t-shirt', :on_hand => 5)
product.master.count_on_hand = 5
product.master.save
@order.add_variant(product.master, 2)
@order.inventory_units.each do |iu|
iu.update_attribute_without_callbacks('state', 'sold')
end
@order.update!
visit spree.admin_path
click_link "Orders"
within('table#listing_orders tbody tr:nth-child(1)') { click_link "R100" }
end
specify do
click_link "Shipments"
click_on "New Shipment"
check "inventory_units_1"
click_button "Create"
click_link "Shipments"
click_on "New Shipment"
check "inventory_units_2"
click_button "Create"
click_link "Shipments"
Spree::Order.first.shipments.first.cost.should == 10
Spree::Order.first.shipments.last.cost.should == 10
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment