2013-12-20 01:54:24 +08:00
|
|
|
module("Discourse.HasCurrentUser");
|
2013-10-01 03:46:42 +08:00
|
|
|
|
|
|
|
test("adds `currentUser` property to an object and ensures it is not cached", function() {
|
2014-06-20 04:00:01 +08:00
|
|
|
this.stub(Discourse.User, "current");
|
2013-10-01 03:46:42 +08:00
|
|
|
var testObj = Ember.Object.createWithMixins(Discourse.HasCurrentUser, {});
|
|
|
|
|
|
|
|
Discourse.User.current.returns("first user");
|
|
|
|
equal(testObj.get("currentUser"), "first user", "on the first call property returns initial user");
|
|
|
|
|
|
|
|
Discourse.User.current.returns("second user");
|
|
|
|
equal(testObj.get("currentUser"), "second user", "if the user changes, on the second call property returns changed user");
|
|
|
|
});
|