mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Making some changes to the data on the products inventory page
This commit is contained in:
@@ -8,17 +8,29 @@ module OpenFoodNetwork
|
||||
end
|
||||
|
||||
def header
|
||||
["Supplier", "Product", "SKU", "Variant", "On Hand", "Price"]
|
||||
[
|
||||
"Supplier",
|
||||
"Producer Suburb",
|
||||
"Product",
|
||||
"Product Properties",
|
||||
"Variant Value",
|
||||
"Price",
|
||||
"Group Buy Unit Quantity",
|
||||
"Amount"
|
||||
]
|
||||
end
|
||||
|
||||
def table
|
||||
variants.map do |variant|
|
||||
[variant.product.supplier.name,
|
||||
variant.product.name,
|
||||
variant.sku,
|
||||
variant.options_text,
|
||||
variant.count_on_hand,
|
||||
variant.price]
|
||||
variant.product.supplier.address.city,
|
||||
variant.product.name,
|
||||
variant.product.properties.map(&:name).join(", "),
|
||||
variant.options_text,
|
||||
variant.price,
|
||||
variant.product.group_buy_unit_size,
|
||||
""
|
||||
]
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -190,6 +190,8 @@ describe Spree::Admin::ReportsController do
|
||||
OpenFoodNetwork::ProductsAndInventoryReport.should_receive(:new)
|
||||
.with(user, {"test"=>"foo", "controller"=>"spree/admin/reports", "action"=>"products_and_inventory"})
|
||||
.and_return(report = double(:report))
|
||||
report.stub(:header).and_return []
|
||||
report.stub(:table).and_return []
|
||||
spree_get :products_and_inventory, :test => "foo"
|
||||
assigns(:report).should == report
|
||||
end
|
||||
@@ -236,6 +238,8 @@ describe Spree::Admin::ReportsController do
|
||||
OpenFoodNetwork::CustomersReport.should_receive(:new)
|
||||
.with(user, {"test"=>"foo", "controller"=>"spree/admin/reports", "action"=>"customers"})
|
||||
.and_return(report = double(:report))
|
||||
report.stub(:header).and_return []
|
||||
report.stub(:table).and_return []
|
||||
spree_get :customers, :test => "foo"
|
||||
assigns(:report).should == report
|
||||
end
|
||||
|
||||
@@ -143,10 +143,10 @@ feature %q{
|
||||
table = rows.map { |r| r.all("th,td").map { |c| c.text.strip } }
|
||||
|
||||
table.sort.should == [
|
||||
["Supplier", "Product", "SKU", "Variant", "On Hand", "Price"],
|
||||
[product_1.supplier.name, "Product Name", variant_1.sku, "Size: Test", "10", "100.0"],
|
||||
[product_1.supplier.name, "Product Name", variant_2.sku, "Size: S", "20", "80.0"],
|
||||
[product_2.supplier.name, "Product 2", product_2.master.sku, "", "9", "99.0"]
|
||||
["Supplier", "Producer Suburb", "Product", "Product Properties", "Variant Value", "Price", "Group Buy Unit Quantity", "Amount"],
|
||||
[product_1.supplier.name, product_1.supplier.address.city, "Product Name", product_1.properties.join(", "), "Size: Test", "100.0", product_1.group_buy_unit_size.to_s, ""],
|
||||
[product_1.supplier.name, product_1.supplier.address.city, "Product Name", product_1.properties.join(", "), "Size: S", "80.0", product_1.group_buy_unit_size.to_s, ""],
|
||||
[product_2.supplier.name, product_1.supplier.address.city, "Product 2", product_1.properties.join(", "), "", "99.0", product_1.group_buy_unit_size.to_s, ""]
|
||||
].sort
|
||||
end
|
||||
end
|
||||
|
||||
@@ -13,24 +13,40 @@ module OpenFoodNetwork
|
||||
end
|
||||
|
||||
it "Should return headers" do
|
||||
subject.header.should == ["Supplier", "Product", "SKU", "Variant", "On Hand", "Price"]
|
||||
subject.header.should == [
|
||||
"Supplier",
|
||||
"Producer Suburb",
|
||||
"Product",
|
||||
"Product Properties",
|
||||
"Variant Value",
|
||||
"Price",
|
||||
"Group Buy Unit Quantity",
|
||||
"Amount"
|
||||
]
|
||||
end
|
||||
|
||||
it "should build a table from a list of variants" do
|
||||
variant = double(:variant, sku: "sku",
|
||||
options_text: "Variant Name",
|
||||
count_on_hand: 10,
|
||||
price: 100)
|
||||
options_text: "Variant Name",
|
||||
count_on_hand: 10,
|
||||
price: 100)
|
||||
variant.stub_chain(:product, :supplier, :name).and_return("Supplier")
|
||||
variant.stub_chain(:product, :supplier, :address, :city).and_return("A city")
|
||||
variant.stub_chain(:product, :name).and_return("Product Name")
|
||||
variant.stub_chain(:product, :properties).and_return [double(name: "test"), double(name: "foo")]
|
||||
variant.stub_chain(:product, :group_buy_unit_size).and_return(21)
|
||||
subject.stub(:variants).and_return [variant]
|
||||
|
||||
subject.table.should == [[
|
||||
"Supplier",
|
||||
"A city",
|
||||
"Product Name",
|
||||
"sku",
|
||||
"test, foo",
|
||||
"Variant Name",
|
||||
10,
|
||||
100]]
|
||||
100,
|
||||
21,
|
||||
""
|
||||
]]
|
||||
end
|
||||
|
||||
it "fetches variants for some params" do
|
||||
|
||||
Reference in New Issue
Block a user