From 567de7e0a7b3a79abb1b9902771eb1fac3e01afa Mon Sep 17 00:00:00 2001 From: Robert Jackson Date: Sat, 8 Aug 2015 14:15:01 -0400 Subject: [PATCH] Fix tests for newly deprecated things. * `TrackedArray` and `SubArray` are still used by the RC/AC implementation in 1.13.x, but it should not trigger a `TrackedArray` deprecation. * Fix a few tests that were using `{{with}}` and `controller=`. --- packages/ember-htmlbars/tests/helpers/with_test.js | 4 ++++ .../tests/helpers/element_action_test.js | 2 ++ packages/ember-runtime/lib/computed/reduce_computed.js | 2 +- .../ember-runtime/lib/computed/reduce_computed_macros.js | 2 +- packages/ember-runtime/lib/system/subarray.js | 6 +++--- packages/ember-runtime/lib/system/tracked_array.js | 4 ++-- 6 files changed, 13 insertions(+), 7 deletions(-) diff --git a/packages/ember-htmlbars/tests/helpers/with_test.js b/packages/ember-htmlbars/tests/helpers/with_test.js index 9a14f368f40..827e07b6c5e 100644 --- a/packages/ember-htmlbars/tests/helpers/with_test.js +++ b/packages/ember-htmlbars/tests/helpers/with_test.js @@ -249,6 +249,8 @@ QUnit.test("it should wrap context with object controller [DEPRECATED]", functio name: 'Bob Loblaw' }); + expectDeprecation(/Using the {{with}} helper with a `controller` specified/); + view = EmberView.create({ container: container, template: compile('{{#with view.person controller="person"}}{{controllerName}}{{/with}}'), @@ -379,6 +381,8 @@ QUnit.test("it should wrap keyword with object controller [DEPRECATED]", functio }); QUnit.test("destroys the controller generated with {{with foo controller='blah'}} [DEPRECATED]", function() { + expectDeprecation(/Using the {{with}} helper with a `controller` specified/); + var destroyed = false; var Controller = EmberController.extend({ willDestroy() { diff --git a/packages/ember-routing-htmlbars/tests/helpers/element_action_test.js b/packages/ember-routing-htmlbars/tests/helpers/element_action_test.js index c7bce884760..f0b0002a100 100644 --- a/packages/ember-routing-htmlbars/tests/helpers/element_action_test.js +++ b/packages/ember-routing-htmlbars/tests/helpers/element_action_test.js @@ -166,6 +166,8 @@ QUnit.test("should target the current controller inside an {{each}} loop [DEPREC QUnit.test("should target the with-controller inside an {{#with controller='person'}} [DEPRECATED]", function() { var registeredTarget; + expectDeprecation(/Using the {{with}} helper with a `controller` specified/); + ActionHelper.registerAction = function({ node }) { registeredTarget = node.state.target; }; diff --git a/packages/ember-runtime/lib/computed/reduce_computed.js b/packages/ember-runtime/lib/computed/reduce_computed.js index 8ef22b10087..fafcaac782b 100644 --- a/packages/ember-runtime/lib/computed/reduce_computed.js +++ b/packages/ember-runtime/lib/computed/reduce_computed.js @@ -203,7 +203,7 @@ DependentArraysObserver.prototype = { }, resetTransformations(dependentKey, observerContexts) { - this.trackedArraysByGuid[dependentKey] = new TrackedArray(observerContexts); + this.trackedArraysByGuid[dependentKey] = new TrackedArray(observerContexts, true); }, trackAdd(dependentKey, index, newItems) { diff --git a/packages/ember-runtime/lib/computed/reduce_computed_macros.js b/packages/ember-runtime/lib/computed/reduce_computed_macros.js index 0674667dba0..38fc7cebe60 100644 --- a/packages/ember-runtime/lib/computed/reduce_computed_macros.js +++ b/packages/ember-runtime/lib/computed/reduce_computed_macros.js @@ -291,7 +291,7 @@ export function filter(dependentKey, callback) { _suppressDeprecation: true, initialize(array, changeMeta, instanceMeta) { - instanceMeta.filteredArrayIndexes = new SubArray(); + instanceMeta.filteredArrayIndexes = new SubArray(undefined, true); }, addedItem(array, item, changeMeta, instanceMeta) { diff --git a/packages/ember-runtime/lib/system/subarray.js b/packages/ember-runtime/lib/system/subarray.js index 624e41ff94f..2b88c9489eb 100644 --- a/packages/ember-runtime/lib/system/subarray.js +++ b/packages/ember-runtime/lib/system/subarray.js @@ -21,14 +21,14 @@ export default SubArray; @namespace Ember @private */ -function SubArray(length) { +function SubArray(length, _suppressDeprecation) { Ember.deprecate( 'Ember.SubArray will be removed in 2.0.0.', - false, + _suppressDeprecation, { id: 'ember-metal.sub-array', until: '2.0.0' } ); - if (arguments.length < 1) { length = 0; } + if (length === undefined) { length = 0; } if (length > 0) { this._operations = [new Operation(RETAIN, length)]; diff --git a/packages/ember-runtime/lib/system/tracked_array.js b/packages/ember-runtime/lib/system/tracked_array.js index d4252706604..3e4e0b495c7 100644 --- a/packages/ember-runtime/lib/system/tracked_array.js +++ b/packages/ember-runtime/lib/system/tracked_array.js @@ -19,10 +19,10 @@ export default TrackedArray; the initial items for the starting state of retain:n. @private */ -function TrackedArray(items) { +function TrackedArray(items, _suppressDeprecation) { Ember.deprecate( 'Ember.TrackedArray will be removed in 2.0.0.', - false, + _suppressDeprecation, { id: 'ember-metal.tracked-array', until: '2.0.0' } );