mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-26 01:33:22 +00:00
test for cancelled orders in order and distributor report
This commit is contained in:
@@ -45,6 +45,13 @@ module OpenFoodWeb
|
||||
line_item31 = create(:line_item, :variant => @variant3, :order => order3)
|
||||
order3.line_items << line_item31
|
||||
@orders << order3
|
||||
|
||||
#order4 = create(:order, :distributor => distributor, :bill_address => bill_address, :special_instructions => shipping_instructions)
|
||||
#line_item41 = create(:line_item, :variant => @variant3, :order => order4)
|
||||
#order4.line_items << line_item41
|
||||
#order4.state = 'canceled'
|
||||
#@cancelled_order = order4
|
||||
#@orders << order4
|
||||
end
|
||||
|
||||
it "should return a header row describing the report" do
|
||||
@@ -93,5 +100,14 @@ module OpenFoodWeb
|
||||
variant_groups.length.should == 3
|
||||
product_groups.length.should == 3
|
||||
end
|
||||
|
||||
it "should not include cancelled orders in the counts" do
|
||||
subject = GroupBuyReport.new @orders
|
||||
|
||||
table_row_objects = subject.variants_and_quantities
|
||||
|
||||
#table.should_not ==
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -7,6 +7,7 @@ module OpenFoodWeb
|
||||
describe "orders and distributors report" do
|
||||
|
||||
before(:each) do
|
||||
#normal completed order
|
||||
@bill_address = create(:address)
|
||||
@distributor_address = create(:address, :address1 => "distributor address", :city => 'The Shire', :zipcode => "1234")
|
||||
@distributor = create(:distributor_enterprise, :address => @distributor_address)
|
||||
@@ -19,6 +20,14 @@ module OpenFoodWeb
|
||||
@order.payments << payment
|
||||
@line_item = create(:line_item, :product => product, :order => @order)
|
||||
@order.line_items << @line_item
|
||||
|
||||
#cancelled order
|
||||
@cancelled_order = create(:order, :distributor => @distributor, :bill_address => @bill_address, :special_instructions => @shipping_instructions)
|
||||
payment = create(:payment, :payment_method => @payment_method, :order => @cancelled_order )
|
||||
@cancelled_order.payments << payment
|
||||
line_item = create(:line_item, :product => product, :order => @cancelled_order)
|
||||
@cancelled_order.line_items << line_item
|
||||
@cancelled_order.state = 'canceled' #don't think this is right..
|
||||
end
|
||||
|
||||
it "should return a header row describing the report" do
|
||||
@@ -43,6 +52,20 @@ module OpenFoodWeb
|
||||
@payment_method.name,
|
||||
@distributor.name, @distributor.address.address1, @distributor.address.city, @distributor.address.zipcode, @shipping_instructions ]
|
||||
end
|
||||
|
||||
it "should hide cancelled orders by default" do
|
||||
subject = OrderAndDistributorReport.new [@order, @cancelled_order]
|
||||
|
||||
table = subject.table
|
||||
|
||||
table.should_not include([@cancelled_order.created_at, @cancelled_order.id,
|
||||
@bill_address.full_name, @cancelled_order.email, @bill_address.phone, @bill_address.city,
|
||||
@line_item.product.sku, @line_item.product.name, @line_item.variant.options_text, @line_item.quantity, @line_item.max_quantity, @line_item.price * @line_item.quantity, @line_item.itemwise_shipping_cost,
|
||||
@payment_method.name,
|
||||
@distributor.name, @distributor.address.address1, @distributor.address.city, @distributor.address.zipcode, @shipping_instructions ])
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user