From bb13ec0e02e5988bfd14bd0141d1c8c03bf920a2 Mon Sep 17 00:00:00 2001 From: Rohan Mitchell Date: Fri, 11 Jan 2013 10:40:56 +1100 Subject: [PATCH] Rename methods --- .../javascripts/admin/order_cycle.js.erb | 20 ++++++------ app/views/admin/order_cycles/_form.html.haml | 2 +- .../unit/order_cycle_spec.js.coffee | 32 +++++++++---------- 3 files changed, 27 insertions(+), 27 deletions(-) diff --git a/app/assets/javascripts/admin/order_cycle.js.erb b/app/assets/javascripts/admin/order_cycle.js.erb index 06ef6757ea..e481777568 100644 --- a/app/assets/javascripts/admin/order_cycle.js.erb +++ b/app/assets/javascripts/admin/order_cycle.js.erb @@ -3,12 +3,12 @@ function AdminCreateOrderCycleCtrl($scope, OrderCycle, Enterprise) { $scope.order_cycle = OrderCycle.order_cycle; - $scope.exchangeVariantsSelected = function(exchange) { - return OrderCycle.exchangeVariantsSelected(exchange); + $scope.exchangeSelectedVariants = function(exchange) { + return OrderCycle.exchangeSelectedVariants(exchange); }; - $scope.enterpriseVariantsTotal = function(enterprise) { - return OrderCycle.enterpriseVariantsTotal(enterprise); + $scope.enterpriseTotalVariants = function(enterprise) { + return OrderCycle.enterpriseTotalVariants(enterprise); }; $scope.toggleProducts = function($event, exchange) { @@ -33,12 +33,12 @@ function AdminEditOrderCycleCtrl($scope, $location, OrderCycle, Enterprise) { var order_cycle_id = $location.absUrl().match(/\/admin\/order_cycles\/(\d+)/)[1]; $scope.order_cycle = OrderCycle.load(order_cycle_id); - $scope.exchangeVariantsSelected = function(exchange) { - return OrderCycle.exchangeVariantsSelected(exchange); + $scope.exchangeSelectedVariants = function(exchange) { + return OrderCycle.exchangeSelectedVariants(exchange); }; - $scope.enterpriseVariantsTotal = function(enterprise) { - return OrderCycle.enterpriseVariantsTotal(enterprise); + $scope.enterpriseTotalVariants = function(enterprise) { + return OrderCycle.enterpriseTotalVariants(enterprise); }; $scope.toggleProducts = function($event, exchange) { @@ -72,7 +72,7 @@ angular.module('order_cycle', ['ngResource']). order_cycle: {incoming_exchanges: [], outgoing_exchanges: []}, - exchangeVariantsSelected: function(exchange) { + exchangeSelectedVariants: function(exchange) { var numActiveVariants = 0; angular.forEach(exchange.variants, function(active, id) { @@ -84,7 +84,7 @@ angular.module('order_cycle', ['ngResource']). return numActiveVariants; }, - enterpriseVariantsTotal: function(enterprise) { + enterpriseTotalVariants: function(enterprise) { var numVariants = 0; angular.forEach(enterprise.supplied_products, function(product) { diff --git a/app/views/admin/order_cycles/_form.html.haml b/app/views/admin/order_cycles/_form.html.haml index c04f7e2c21..e0bbf6e7c4 100644 --- a/app/views/admin/order_cycles/_form.html.haml +++ b/app/views/admin/order_cycles/_form.html.haml @@ -24,7 +24,7 @@ %td.supplier_name {{ enterprises[exchange.enterprise_id].name }} %td.products = f.submit 'Products', 'ng-click' => 'toggleProducts($event, exchange)' - {{ exchangeVariantsSelected(exchange) }} / {{ enterpriseVariantsTotal(enterprises[exchange.enterprise_id]) }} selected + {{ exchangeSelectedVariants(exchange) }} / {{ enterpriseTotalVariants(enterprises[exchange.enterprise_id]) }} selected %tr.products{'ng-show' => 'exchange.showProducts'} %td{:colspan => 3} = render 'exchange_product_form' diff --git a/spec/javascripts/unit/order_cycle_spec.js.coffee b/spec/javascripts/unit/order_cycle_spec.js.coffee index 8121a3422e..5c946ac69c 100644 --- a/spec/javascripts/unit/order_cycle_spec.js.coffee +++ b/spec/javascripts/unit/order_cycle_spec.js.coffee @@ -13,8 +13,8 @@ describe 'OrderCycle controllers', -> preventDefault: jasmine.createSpy('preventDefault') OrderCycle = order_cycle: 'my order cycle' - exchangeVariantsSelected: jasmine.createSpy('exchangeVariantsSelected').andReturn('variants selected') - enterpriseVariantsTotal: jasmine.createSpy('enterpriseVariantsTotal').andReturn('variants total') + exchangeSelectedVariants: jasmine.createSpy('exchangeSelectedVariants').andReturn('variants selected') + enterpriseTotalVariants: jasmine.createSpy('enterpriseTotalVariants').andReturn('variants total') toggleProducts: jasmine.createSpy('toggleProducts') addSupplier: jasmine.createSpy('addSupplier') create: jasmine.createSpy('create') @@ -29,11 +29,11 @@ describe 'OrderCycle controllers', -> it 'Loads order cycles', -> expect(scope.order_cycle).toEqual('my order cycle') - it 'Delegates exchangeVariantsSelected and enterpriseVariantsTotal to OrderCycle', -> - expect(scope.exchangeVariantsSelected('exchange')).toEqual('variants selected') - expect(OrderCycle.exchangeVariantsSelected).toHaveBeenCalledWith('exchange') - expect(scope.enterpriseVariantsTotal('enterprise')).toEqual('variants total') - expect(OrderCycle.enterpriseVariantsTotal).toHaveBeenCalledWith('enterprise') + it 'Delegates exchangeSelectedVariants and enterpriseTotalVariants to OrderCycle', -> + expect(scope.exchangeSelectedVariants('exchange')).toEqual('variants selected') + expect(OrderCycle.exchangeSelectedVariants).toHaveBeenCalledWith('exchange') + expect(scope.enterpriseTotalVariants('enterprise')).toEqual('variants total') + expect(OrderCycle.enterpriseTotalVariants).toHaveBeenCalledWith('enterprise') it 'Delegates toggleProducts to OrderCycle', -> scope.toggleProducts(event, 'exchange') @@ -67,8 +67,8 @@ describe 'OrderCycle controllers', -> 'example.com/admin/order_cycles/27/edit' OrderCycle = load: jasmine.createSpy('load') - exchangeVariantsSelected: jasmine.createSpy('exchangeVariantsSelected').andReturn('variants selected') - enterpriseVariantsTotal: jasmine.createSpy('enterpriseVariantsTotal').andReturn('variants total') + exchangeSelectedVariants: jasmine.createSpy('exchangeSelectedVariants').andReturn('variants selected') + enterpriseTotalVariants: jasmine.createSpy('enterpriseTotalVariants').andReturn('variants total') toggleProducts: jasmine.createSpy('toggleProducts') addSupplier: jasmine.createSpy('addSupplier') update: jasmine.createSpy('update') @@ -83,11 +83,11 @@ describe 'OrderCycle controllers', -> it 'Loads order cycles', -> expect(OrderCycle.load).toHaveBeenCalledWith('27') - it 'Delegates exchangeVariantsSelected and enterpriseVariantsTotal to OrderCycle', -> - expect(scope.exchangeVariantsSelected('exchange')).toEqual('variants selected') - expect(OrderCycle.exchangeVariantsSelected).toHaveBeenCalledWith('exchange') - expect(scope.enterpriseVariantsTotal('enterprise')).toEqual('variants total') - expect(OrderCycle.enterpriseVariantsTotal).toHaveBeenCalledWith('enterprise') + it 'Delegates exchangeSelectedVariants and enterpriseTotalVariants to OrderCycle', -> + expect(scope.exchangeSelectedVariants('exchange')).toEqual('variants selected') + expect(OrderCycle.exchangeSelectedVariants).toHaveBeenCalledWith('exchange') + expect(scope.enterpriseTotalVariants('enterprise')).toEqual('variants total') + expect(OrderCycle.enterpriseTotalVariants).toHaveBeenCalledWith('enterprise') it 'Delegates toggleProducts to OrderCycle', -> scope.toggleProducts(event, 'exchange') @@ -161,7 +161,7 @@ describe 'OrderCycle services', -> describe 'counting variants', -> it 'counts selected variants in an exchange', -> - result = OrderCycle.exchangeVariantsSelected({variants: {1: true, 2: false, 3: true}}) + result = OrderCycle.exchangeSelectedVariants({variants: {1: true, 2: false, 3: true}}) expect(result).toEqual(2) it 'counts total variants supplied by an enterprise', -> @@ -172,7 +172,7 @@ describe 'OrderCycle services', -> {variants: [{}, {}, {}]} ] - expect(OrderCycle.enterpriseVariantsTotal(enterprise)).toEqual(5) + expect(OrderCycle.enterpriseTotalVariants(enterprise)).toEqual(5) describe 'toggling products', -> exchange = null