我想升级Ember CLI应用程序以使用简单验证1.0。我的验收测试不再有效。我将测试套件配置为针对Rails服务器运行,该服务器是我的API的副本。登录我是这样做的:Ember Simple验证测试1.0在验收测试
visit("/")
fillIn(".identification-field", "[email protected]");
fillIn(".password-field", "testpassword");
click(".btn.login-submit");
andThen(function(){
equal(currentSession(application).get('user_email'), "[email protected]");
});
这与simple-auth 0.7.3,但没有与1.0.0。
_populateCurrentUser: function() {
var user_id = this.get('session.data.user_id');
var user_email = this.get('session.data.user_email');
var _this = this;
return this.store.find('user', user_id).then(function(user){
_this.get('currentUser').set('content', user);
// Below is for backward-compatibility
_this.get('session').set('currentUser', user);
_this.get('session').set('user_id', user_id);
_this.get('session').set('user_email', user_email);
user;
});
}
sessionAuthenticated: function(){
this._populateCurrentUser();
this._super();
}
beforeModel: function() {
if (this.get('session.isAuthenticated')) {
return this._populateCurrentUser();
}
}
这是基于以下指南:http://miguelcamba.com/blog/2015/06/18/how-to-inject-the-current-user-using-ember-simple-auth/
这工作完全当我运行的应用程序,但打破我的测试套件,我已经增加如下额外的方法我的应用程序路径设置会话。现在,当我登录会话似乎没有填充 - _populateCurrentUser方法失败,因为this.get('session.data.user_id')是未定义的。
任何人都可以帮忙吗?也许这是由于在1.0中自动使用临时会话存储,但如果是这样,我不知道如何解决这个问题?
非常感谢
辉煌,谢谢!我一定在文档中错过了这个,感谢您的快速回复 – AdamP