Permalink
Browse files

Merge pull request #801 from stefanpenner/unsetableProperties

Do not allow setting to essentially read-only setters
  • Loading branch information...
2 parents 36d2e2a + 7b88a92 commit 1032a75b10ea4aaa5568d5aa12b2dcb4ab9de5b2 @wycats wycats committed Mar 13, 2013
Showing with 14 additions and 1 deletion.
  1. +4 −1 packages/ember-data/lib/system/model/model.js
  2. +10 −0 packages/ember-data/tests/unit/model_test.js
@@ -5,7 +5,10 @@ var LoadPromise = DS.LoadPromise; // system/mixins/load_promise
var get = Ember.get, set = Ember.set, none = Ember.isNone, map = Ember.EnumerableUtils.map;
-var retrieveFromCurrentState = Ember.computed(function(key) {
+var retrieveFromCurrentState = Ember.computed(function(key, value) {
+ if (arguments.length > 1) {
+ throw new Error('Cannot Set: ' + key + ' on: ' + this.toString() );
+ }
return get(get(this, 'stateManager.currentState'), key);
}).property('stateManager.currentState');
@@ -328,3 +328,13 @@ test("a DS.Model can describe Date attributes", function() {
convertsWhenSet('date', date, dateString);
});
+test("don't allow setting", function(){
+ var store = DS.Store.create();
+
+ var Person = DS.Model.extend();
+ var record = store.createRecord(Person);
+
+ raises(function(){
+ record.set('isLoaded', true);
+ }, "raised error when trying to set an unsettable record");
+});

0 comments on commit 1032a75

Please sign in to comment.