我正在使用ember-cli-simple-auth
和ember-cli-simple-auth-devise
在一个ember-cli
项目中。
我还Session
通过初始化程序自定义 simple-auth:
// app/initializers/custom-session.js
import Ember from 'ember';
import Session from 'simple-auth/session';
export default {
name: 'custom-session',
before: 'simple-auth',
initialize: function(container, application) {
Session.reopen({
setCurrentUser: function() {
var id = this.get('user_id'),
self = this;
if (!Ember.isEmpty(id)) {
return container.lookup('store:main').find('user', id)
.then(function(user) {
self.set('currentUser', user);
});
}
}.observes('user_id')
});
}
};
在一个简单的验收测试(一个简单的调用ok(1)
)中,我收到以下错误
Error: Assertion Failed: calling set on destroyed object
Source:
at Adapter.extend.exception (localhost:4900/assets/vendor.js:57907:19)
at apply (http://localhost:4900/assets/vendor.js:21143:27)
at superWrapper [as exception] (localhost:4900/assets/vendor.js:20721:15)
at RSVP.onerrorDefault (localhost:4900/assets/vendor.js:59827:26)
at Object.__exports__.default.trigger (localhost:4900/assets/vendor.js:22673:13)
at Promise._onerror (localhost:4900/assets/vendor.js:23397:16)
at publishRejection (localhost:4900/assets/vendor.js:23804:17)
at http://localhost:4900/assets/vendor.js:29217:9
如果我注释掉该self.set('currentUser', user);
行,错误就会消失。
处理此问题的适当方法是什么?有没有办法在测试中忽略这个初始化程序?
我也收到此日志消息:
没有为 Ember 简单身份验证配置授权工厂 - 如果需要授权后端请求,请指定一个。