mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
BPUR: match product supplier on clone
This commit is contained in:
@@ -224,6 +224,7 @@ productsApp.controller('AdminBulkProductsCtrl', function($scope, $timeout, $http
|
||||
var id = data.product.id;
|
||||
dataFetcher("/admin/products/bulk_index.json?q[id_eq]="+id).then(function(data){
|
||||
var newProduct = data[0];
|
||||
$scope.matchSupplier(newProduct);
|
||||
$scope.products.push(newProduct);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -384,11 +384,13 @@ feature %q{
|
||||
|
||||
page.should have_selector "a.clone-product", :count => 4
|
||||
page.should have_field "product_name", with: "COPY OF #{p1.name}"
|
||||
page.should have_select "supplier", selected: "#{p1.supplier.name}"
|
||||
|
||||
visit '/admin/products/bulk_edit'
|
||||
|
||||
page.should have_selector "a.clone-product", :count => 4
|
||||
page.should have_field "product_name", with: "COPY OF #{p1.name}"
|
||||
page.should have_select "supplier", selected: "#{p1.supplier.name}"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -428,13 +428,15 @@ describe("AdminBulkProductsCtrl", function(){
|
||||
httpBackend.flush();
|
||||
});
|
||||
|
||||
it("adds the newly created product to scope.products", function(){
|
||||
it("adds the newly created product to scope.products and matches supplier", function(){
|
||||
spyOn(scope, "matchSupplier").andCallThrough();
|
||||
scope.products = [ { id: 13, permalink_live: "oranges" } ];
|
||||
httpBackend.expectGET('/admin/products/oranges/clone.json').respond(200, { product: { id: 17, name: "new_product", variants: [ { id: 3, name: "V1" } ] } } );
|
||||
httpBackend.expectGET('/admin/products/bulk_index.json?q[id_eq]=17').respond(200, [ { id: 17, name: "new_product", variants: [ { id: 3, name: "V1" } ] } ] );
|
||||
httpBackend.expectGET('/admin/products/oranges/clone.json').respond(200, { product: { id: 17, name: "new_product", supplier: { id: 6 }, variants: [ { id: 3, name: "V1" } ] } } );
|
||||
httpBackend.expectGET('/admin/products/bulk_index.json?q[id_eq]=17').respond(200, [ { id: 17, name: "new_product", supplier: { id: 6 }, variants: [ { id: 3, name: "V1" } ] } ] );
|
||||
scope.cloneProduct(scope.products[0]);
|
||||
httpBackend.flush();
|
||||
expect(scope.products).toEqual( [ { id: 13, permalink_live: "oranges" }, { id: 17, name: "new_product", variants: [ { id: 3, name: "V1" } ] } ] );
|
||||
expect(scope.matchSupplier).toHaveBeenCalledWith( { id: 17, name: "new_product", supplier: { id: 6 }, variants: [ { id: 3, name: "V1" } ] } );
|
||||
expect(scope.products).toEqual( [ { id: 13, permalink_live: "oranges" }, { id: 17, name: "new_product", supplier: { id: 6 }, variants: [ { id: 3, name: "V1" } ] } ] );
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user