From 332bf345ab4109b8a8194e0b2d6fcdd0b387d759 Mon Sep 17 00:00:00 2001 From: Miguel Camba Date: Mon, 27 Apr 2015 22:50:41 +0100 Subject: [PATCH] Fix assertion to make sure doesn't affect old CP syntax --- packages/ember-metal/lib/computed.js | 2 +- packages/ember-metal/tests/computed_test.js | 10 ++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/packages/ember-metal/lib/computed.js b/packages/ember-metal/lib/computed.js index 1987ace3f42..3cf7870054e 100644 --- a/packages/ember-metal/lib/computed.js +++ b/packages/ember-metal/lib/computed.js @@ -218,7 +218,7 @@ ComputedPropertyPrototype.volatile = function() { ComputedPropertyPrototype.readOnly = function(readOnly) { Ember.deprecate('Passing arguments to ComputedProperty.readOnly() is deprecated.', arguments.length === 0); this._readOnly = readOnly === undefined || !!readOnly; // Force to true once this deprecation is gone - Ember.assert("Computed properties that define a setter cannot be read-only", !(this._readOnly && this._setter)); + Ember.assert("Computed properties that define a setter using the new syntax cannot be read-only", !(this._readOnly && this._setter && this._setter !== this._getter)); return this; }; diff --git a/packages/ember-metal/tests/computed_test.js b/packages/ember-metal/tests/computed_test.js index 5cb070817cc..ce6985ecb5d 100644 --- a/packages/ember-metal/tests/computed_test.js +++ b/packages/ember-metal/tests/computed_test.js @@ -900,13 +900,19 @@ QUnit.test('is chainable', function() { ok(cp instanceof ComputedProperty); }); -QUnit.test('throws assertion if called over a CP with a setter', function() { +QUnit.test('throws assertion if called over a CP with a setter defined with the new syntax', function() { expectAssertion(function() { computed({ get: function() { }, set: function() { } }).readOnly(); - }, /Computed properties that define a setter cannot be read-only/); + }, /Computed properties that define a setter using the new syntax cannot be read-only/); +}); + +QUnit.test('doesn\'t throws assertion if called over a CP with a setter defined with the old syntax', function() { + expectDeprecation(function() { + computed(function(key, value) {}).readOnly(); + }, /same function as getter and setter/); }); testBoth('protects against setting', function(get, set) {