Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Throw arror on attribute types that can't be resolved into an object

  • Loading branch information...
commit e4d29c5ba202a3d7b4d49bae3eb86b2fac81fb81 1 parent 5cff8b6
@drogus drogus authored wagenet committed
View
2  frameworks/datastore/models/record_attribute.js
@@ -170,7 +170,7 @@ SC.RecordAttribute = SC.Object.extend(
*/
typeClass: function() {
var ret = this.get('type');
- if (SC.typeOf(ret) === SC.T_STRING) ret = SC.objectForPropertyPath(ret);
+ if (SC.typeOf(ret) === SC.T_STRING) ret = SC.requiredObjectForPropertyPath(ret);
return ret ;
}.property('type').cacheable(),
View
17 frameworks/datastore/tests/models/record_attribute.js
@@ -17,7 +17,7 @@ module("SC.RecordAttribute core methods", {
// stick it to the window object so that objectForPropertyPath works
window.MyApp = MyApp;
-
+
MyApp.Foo = SC.Record.extend({
// test simple reading of a pass-through prop
@@ -264,3 +264,18 @@ test("writing an attribute should make many relationship aggregate dirty and add
ok(store.changelog.contains(rec.get('storeKey')), "foo1 should be in the store's changelog");
ok(store.changelog.contains(rec2.get('storeKey')), "foo2 should be in the store's changelog");
});
+
+test("adding attribute with non existing class should throw error", function() {
+ MyApp.InvalidModel = SC.Record.extend({
+ foo: SC.Record.attr("SomethingSomethingSomething")
+ });
+
+ var message;
+ try {
+ MyApp.InvalidModel.prototype.foo.typeClass();
+ } catch (x) {
+ message = x;
+ }
+
+ same(message, 'SomethingSomethingSomething could not be found');
+});
Please sign in to comment.
Something went wrong with that request. Please try again.