cannot use visit("/anything") on any route that uses a store
Closed this issue · 2 comments
so visit("/") for a route with a model/no store etc works.
visit("/component-test") works.. since again, that really doesn't do anything.
if I modify the index-test.js in my app to:
var App;
module('Acceptances - Index', {
setup: function(){
App = startApp();
},
teardown: function() {
Ember.run(App, 'destroy');
}
});
test('index renders', function(){
expect(3);
visit('/dashboards').then(function(){
var title = find('h2#title');
var list = find('ul#indexList li');
equal(title.text(), 'Sample Index Page');
equal(list.length, 3);
equal(list.text(), 'redyellowblue');
});
});
I expect this to run, but fail because clearly my /dashboards route doesn't look anything like the index route ;)
But, if I do this (or try to visit any route, of any kind, anywhere in my app) I get this error from testem:
TypeError: Attempting to configurable attribute of unconfigurable property. at h
ttp://localhost:7359/vendor/ember/ember.js, line 3933
This app has 0 jshint errors or warnings, and has worked in production for awhile. So I know the app/routes etc is okay.
I tried with ember 1.4.x and 1.5.x... only the line # changes.
I changed ember.js to look like this:
try {
o_defineProperty(obj, keyName, {
configurable: true,
enumerable: obj.propertyIsEnumerable(keyName),
set: Ember.MANDATORY_SETTER_FUNCTION,
get: Ember.DEFAULT_GETTER_FUNCTION(keyName)
});
} catch(err) {
console.log("keyName: " + keyName);
console.log("meta:");
console.debug(meta);
console.log("obj:");
console.debug(obj);
}
All I get is
key: stack
meta:
obj:
(sadly no more output hah)
So.. some more debugging.
(related to the other issue I created I guess).
If I change my routes model, to not use a store, then the error goes away.
So clearly, something in my store configuration is the culprint.
development.js:
// Put your development configuration here.
//
// This is useful when using a separate API
// endpoint in development than in production.
//
// window.ENV.public_key = '123456'
window.ENV.prependHost = 'http://localhost:8080';
window.ENV.RESTAdapter = function() {
DS.RESTAdapter.reopen({
host: window.ENV.prependHost,
namespace: 'odin-server/v1',
ajax: function(url, method, hash) {
hash = hash || {}; // hash may be undefined
hash.crossDomain = true;
//hash.xhrFields = {withCredentials: true};
return this._super(url, method, hash);
}
});
}
adapters/application.js:
window.ENV.RESTAdapter();
var ApplicationAdapter = DS.RESTAdapter.extend({
updateRecord: function(store, type, record) {
var data = {};
var serializer = store.serializerFor(type.typeKey);
serializer.serializeIntoHash(data, type, record);
var id = Ember.get(record, 'id');
var url = this.buildURL(type.typeKey, id);
Ember.Logger.debug('url for ApplicationAdapter: ' + url);
return this.ajax(url, "POST", { data: data });
},
deleteRecord: function(store, type, record) {
var data = {};
var serializer = store.serializerFor(type.typeKey);
serializer.serializeIntoHash(data, type, record);
var id = Ember.get(record, 'id');
var url = this.buildURL(type.typeKey, id);
Ember.Logger.debug('url for deleteRecord: ' + url);
return this.ajax(url, "DELETE", { data: data });
}
});
export default ApplicationAdapter;
serializers/dashboard.js:
export default DS.ActiveModelSerializer.extend(DS.EmbeddedRecordsMixin, {
attrs: {
widgets : {embedded: 'always'}
},
normalizeHash: {
widgets: function(hash) {
return this._super(hash);
}
},
normalizePayload: function(type, payload) {
return this._super(type, payload);
},
serialize: function(value) {
return this._super(value);
},
keyForAttribute: function(attr) {
return Ember.String.camelize(attr);
},
serializeIntoHash: function(data, type, record, options) {
//eg., to use underscores:
//var root = Ember.String.decamelize(type.typeKey);
//data[root] = this.serialize(record, options);
//this._super(data, type, record, options);
//we want NO root
Ember.merge(data, this.serialize(record, options));
}
});
NOTE - commenting all these things out, doesn't remove the error / fix the test. But just in case i'm posting them