From d844623a1e8894976378233a86698f66ed46250c Mon Sep 17 00:00:00 2001 From: Foxandxss Date: Sat, 24 Oct 2015 00:41:06 +0200 Subject: [PATCH] feat(rating): remove deprecated code BREAKING CHANGE: Remove deprecated non-prefixed directives Closes #4723 --- src/rating/rating.js | 38 ------------------------------ src/rating/test/rating.spec.js | 43 ++++------------------------------ 2 files changed, 5 insertions(+), 76 deletions(-) diff --git a/src/rating/rating.js b/src/rating/rating.js index b32a1a371f..e348c66d45 100644 --- a/src/rating/rating.js +++ b/src/rating/rating.js @@ -97,41 +97,3 @@ angular.module('ui.bootstrap.rating', []) } }; }); - -/* Deprecated rating below */ - -angular.module('ui.bootstrap.rating') - -.value('$ratingSuppressWarning', false) - -.controller('RatingController', ['$scope', '$attrs', '$controller', '$log', '$ratingSuppressWarning', function($scope, $attrs, $controller, $log, $ratingSuppressWarning) { - if (!$ratingSuppressWarning) { - $log.warn('RatingController is now deprecated. Use UibRatingController instead.'); - } - - angular.extend(this, $controller('UibRatingController', { - $scope: $scope, - $attrs: $attrs - })); -}]) - -.directive('rating', ['$log', '$ratingSuppressWarning', function($log, $ratingSuppressWarning) { - return { - require: ['rating', 'ngModel'], - scope: { - readonly: '=?', - onHover: '&', - onLeave: '&' - }, - controller: 'RatingController', - templateUrl: 'template/rating/rating.html', - replace: true, - link: function(scope, element, attrs, ctrls) { - if (!$ratingSuppressWarning) { - $log.warn('rating is now deprecated. Use uib-rating instead.'); - } - var ratingCtrl = ctrls[0], ngModelCtrl = ctrls[1]; - ratingCtrl.init(ngModelCtrl); - } - }; -}]); diff --git a/src/rating/test/rating.spec.js b/src/rating/test/rating.spec.js index e51bc69e47..99b27df885 100644 --- a/src/rating/test/rating.spec.js +++ b/src/rating/test/rating.spec.js @@ -33,7 +33,7 @@ describe('rating directive', function() { return angular.element(star).attr('title'); }); } - + function triggerKeyDown(keyCode) { var e = $.Event('keydown'); e.which = keyCode; @@ -280,13 +280,13 @@ describe('rating directive', function() { expect(getState('on', 'off')).toEqual([true, true, true, true, true, false, false, false, false, false]); }); }); - + describe('Default title', function() { it('should return the default title for each star', function() { expect(getTitles()).toEqual(['one', 'two', 'three', 'four', 'five']); }); }); - + describe('shows different title when `max` attribute is greater than the titles array ', function() { var originalConfig = {}; beforeEach(inject(function(uibRatingConfig) { @@ -300,12 +300,12 @@ describe('rating directive', function() { // return it to the original state angular.extend(uibRatingConfig, originalConfig); })); - + it('should return the default title for each star', function() { expect(getTitles()).toEqual(['one', 'two', 'three', 'four', 'five', '6', '7', '8', '9', '10']); }); }); - + describe('shows custom titles ', function() { it('should return the custom title for each star', function() { $rootScope.titles = [44,45,46]; @@ -326,36 +326,3 @@ describe('rating directive', function() { }); }); }); - -/* Deprecation tests below */ - -describe('rating deprecation', function() { - beforeEach(module('ui.bootstrap.rating')); - beforeEach(module('template/rating/rating.html')); - - it('should suppress warning', function() { - module(function($provide) { - $provide.value('$ratingSuppressWarning', true); - }); - - inject(function($compile, $log, $rootScope) { - spyOn($log, 'warn'); - - var element = $compile('')($rootScope); - $rootScope.$digest(); - - expect($log.warn.calls.count()).toBe(0); - }); - }); - - it('should give warning by default', inject(function($compile, $log, $rootScope) { - spyOn($log, 'warn'); - - var element = $compile('')($rootScope); - $rootScope.$digest(); - - expect($log.warn.calls.count()).toBe(2); - expect($log.warn.calls.argsFor(0)).toEqual(['RatingController is now deprecated. Use UibRatingController instead.']); - expect($log.warn.calls.argsFor(1)).toEqual(['rating is now deprecated. Use uib-rating instead.']); - })); -});