Skip to content

Commit

Permalink
Merge pull request #10968 from cibernox/fix_breaking_assertion_on_cps
Browse files Browse the repository at this point in the history
[BUGFIX beta] Fix assertion to make sure doesn't affect old CP syntax
  • Loading branch information
rwjblue committed Apr 28, 2015
2 parents 20d9700 + 332bf34 commit 9e91371
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion packages/ember-metal/lib/computed.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};

Expand Down
10 changes: 8 additions & 2 deletions packages/ember-metal/tests/computed_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 9e91371

Please sign in to comment.