Merge pull request #2160 from coopdevs/fix-enterprise-filter-in-customers

Fix enterprise filter in customers
This commit is contained in:
Pau Pérez Fabregat
2018-03-23 08:25:21 +01:00
committed by GitHub
2 changed files with 8 additions and 7 deletions

View File

@@ -12,7 +12,7 @@ angular.module("admin.customers").controller "customersCtrl", ($scope, $q, $filt
$scope.$watch "shop_id", ->
if $scope.shop_id?
CurrentShop.shop = $filter('filter')($scope.shops, {id: $scope.shop_id})[0]
CurrentShop.shop = $filter('filter')($scope.shops, {id: parseInt($scope.shop_id)}, true)[0]
Customers.index({enterprise_id: $scope.shop_id}).then (data) ->
pendingChanges.removeAll()
$scope.customers_form.$setPristine()

View File

@@ -10,9 +10,10 @@ describe "CustomersCtrl", ->
null
shops = [
{ name: "Shop 1", id: 1 }
{ name: "Shop 2", id: 2 }
{ name: "Shop 3", id: 3 }
{ name: "Shop 1", id: 1 },
{ name: "Shop 2", id: 12 },
{ name: "Shop 3", id: 2 },
{ name: "Shop 4", id: 3 }
]
availableCountries = [
@@ -39,9 +40,9 @@ describe "CustomersCtrl", ->
beforeEach inject (pendingChanges) ->
spyOn(pendingChanges, "removeAll")
scope.customers_form = jasmine.createSpyObj('customers_form', ['$setPristine'])
http.expectGET('/admin/customers.json?enterprise_id=3').respond 200, customers
http.expectGET('/admin/customers.json?enterprise_id=2').respond 200, customers
scope.$apply ->
scope.shop_id = 3
scope.shop_id = "2"
http.flush()
it "sets the CurrentShop", inject (CurrentShop) ->
@@ -81,7 +82,7 @@ describe "CustomersCtrl", ->
{ text: 'three' }
]
beforeEach ->
http.expectGET('/admin/tag_rules/map_by_tag.json?enterprise_id=3').respond 200, tags
http.expectGET('/admin/tag_rules/map_by_tag.json?enterprise_id=2').respond 200, tags
it "retrieves the tag list", ->
promise = scope.findTags('')