mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-08 22:56:06 +00:00
Auto-merge from CI [skip ci]
This commit is contained in:
@@ -19,6 +19,7 @@ angular.module("ofn.admin").factory "BulkProducts", (PagedFetcher, dataFetcher)
|
||||
# when a respond_overrride for the clone action is used.
|
||||
id = data.product.id
|
||||
dataFetcher("/api/products/" + id + "?template=bulk_show").then (newProduct) =>
|
||||
@unpackProduct newProduct
|
||||
@insertProductAfter(product, newProduct)
|
||||
|
||||
updateVariantLists: (serverProducts, productsWithUnsavedVariants) ->
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
object @product
|
||||
attributes :id, :name, :variant_unit, :variant_unit_scale, :variant_unit_name, :on_demand
|
||||
|
||||
# TODO: This is used by bulk product edit when a product is cloned.
|
||||
# But the list of products is serialized by Api::Admin::ProductSerializer.
|
||||
# This should probably be unified.
|
||||
|
||||
attributes :id, :name, :sku, :variant_unit, :variant_unit_scale, :variant_unit_name, :on_demand, :inherits_properties
|
||||
attributes :on_hand, :price, :available_on, :permalink_live, :tax_category_id
|
||||
|
||||
# Infinity is not a valid JSON object, but Rails encodes it anyway
|
||||
node( :taxon_ids ) { |p| p.taxons.map{ |t| t.id }.join(",") }
|
||||
@@ -8,6 +14,8 @@ node( :price ) { |p| p.price.nil? ? '0.0' : p.price }
|
||||
|
||||
node( :available_on ) { |p| p.available_on.blank? ? "" : p.available_on.strftime("%F %T") }
|
||||
node( :permalink_live ) { |p| p.permalink }
|
||||
node( :producer_id ) { |p| p.supplier_id }
|
||||
node( :category_id ) { |p| p.primary_taxon_id }
|
||||
node( :supplier ) do |p|
|
||||
partial 'api/enterprises/bulk_show', :object => p.supplier
|
||||
end
|
||||
|
||||
@@ -222,7 +222,7 @@ module OpenFoodNetwork
|
||||
proc { |line_items| line_items.first.order.order_cycle.andand.name },
|
||||
proc { |line_items| line_items.first.order.payments.first.andand.payment_method.andand.name },
|
||||
proc { |line_items| line_items.first.order.user.andand.customer_of(line_items.first.order.distributor).andand.code },
|
||||
proc { |line_items| "" },
|
||||
proc { |line_items| line_items.first.order.user.andand.customer_of(line_items.first.order.distributor).andand.tags.andand.join(', ') },
|
||||
|
||||
proc { |line_items| line_items.first.order.bill_address.andand.address1 },
|
||||
proc { |line_items| line_items.first.order.bill_address.andand.address2 },
|
||||
|
||||
@@ -62,12 +62,15 @@ describe "BulkProducts service", ->
|
||||
id: 17
|
||||
|
||||
spyOn(BulkProducts, "insertProductAfter")
|
||||
spyOn(BulkProducts, "unpackProduct")
|
||||
BulkProducts.products = [originalProduct]
|
||||
$httpBackend.expectGET("/admin/products/oranges/clone.json").respond 200,
|
||||
product: clonedProduct
|
||||
$httpBackend.expectGET("/api/products/17?template=bulk_show").respond 200, clonedProduct
|
||||
BulkProducts.cloneProduct BulkProducts.products[0]
|
||||
$httpBackend.flush()
|
||||
expect(BulkProducts.unpackProduct).toHaveBeenCalledWith clonedProduct
|
||||
BulkProducts.unpackProduct(clonedProduct)
|
||||
expect(BulkProducts.insertProductAfter).toHaveBeenCalledWith originalProduct, clonedProduct
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user