mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-26 01:33:22 +00:00
create group buy report, display header
This commit is contained in:
11
lib/open_food_web/group_buy_report.rb
Normal file
11
lib/open_food_web/group_buy_report.rb
Normal file
@@ -0,0 +1,11 @@
|
||||
module OpenFoodWeb
|
||||
class GroupBuyReport
|
||||
def initialize orders
|
||||
@orders = orders
|
||||
end
|
||||
|
||||
def header
|
||||
["Supplier", "Product", "Unit Size", "Variant", "Weight", "Total Ordered", "Total Max"]
|
||||
end
|
||||
end
|
||||
end
|
||||
29
spec/lib/open_food_web/group_buy_spec.rb
Normal file
29
spec/lib/open_food_web/group_buy_spec.rb
Normal file
@@ -0,0 +1,29 @@
|
||||
require 'spec_helper'
|
||||
|
||||
module OpenFoodWeb
|
||||
describe GroupBuyReport do
|
||||
|
||||
before(:each) do
|
||||
@bill_address = create(:address)
|
||||
@distributor_address = create(:address, :address1 => "distributor address", :city => 'The Shire', :zipcode => "1234")
|
||||
@distributor = create(:distributor, :pickup_address => @distributor_address)
|
||||
product = create(:product)
|
||||
product_distribution = create(:product_distribution, :product => product, :distributor => @distributor, :shipping_method => create(:shipping_method))
|
||||
@shipping_instructions = "pick up on thursday please!"
|
||||
@order = create(:order, :distributor => @distributor, :bill_address => @bill_address, :special_instructions => @shipping_instructions)
|
||||
@payment_method = create(:payment_method)
|
||||
payment = create(:payment, :payment_method => @payment_method, :order => @order )
|
||||
@order.payments << payment
|
||||
@line_item = create(:line_item, :product => product, :order => @order)
|
||||
@order.line_items << @line_item
|
||||
end
|
||||
|
||||
it "should return a header row describing the report" do
|
||||
subject = GroupBuyReport.new [@order]
|
||||
|
||||
header = subject.header
|
||||
header.should == ["Supplier", "Product", "Unit Size", "Variant", "Weight", "Total Ordered", "Total Max"]
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user