Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUGFIX beta] Fix assertion to make sure doesn't affect old CP syntax #10968

Merged
merged 1 commit into from
Apr 28, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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