diff --git a/lib/open_food_web/group_buy_report.rb b/lib/open_food_web/group_buy_report.rb new file mode 100644 index 0000000000..4a48b1e92f --- /dev/null +++ b/lib/open_food_web/group_buy_report.rb @@ -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 \ No newline at end of file diff --git a/spec/lib/open_food_web/group_buy_spec.rb b/spec/lib/open_food_web/group_buy_spec.rb new file mode 100644 index 0000000000..6616ffb9fb --- /dev/null +++ b/spec/lib/open_food_web/group_buy_spec.rb @@ -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 \ No newline at end of file