diff --git a/app/assets/javascripts/discourse/models/session.js b/app/assets/javascripts/discourse/models/session.js index 2af3681b2ae..0025ba5b617 100644 --- a/app/assets/javascripts/discourse/models/session.js +++ b/app/assets/javascripts/discourse/models/session.js @@ -27,8 +27,8 @@ Discourse.Session.reopenClass({ } // If we found the current session - if (property) { - if (value) { + if (typeof property !== "undefined") { + if (typeof value !== "undefined") { this.currentSession.set(property, value); } else { return this.currentSession.get(property); diff --git a/app/assets/javascripts/discourse/models/user.js b/app/assets/javascripts/discourse/models/user.js index 64640380584..0d679f99ecc 100644 --- a/app/assets/javascripts/discourse/models/user.js +++ b/app/assets/javascripts/discourse/models/user.js @@ -301,7 +301,7 @@ Discourse.User.reopenClass({ } // If we found the current user - if (this.currentUser && property) { + if (this.currentUser && (typeof property !== "undefined")) { return this.currentUser.get(property); } diff --git a/test/javascripts/models/session_test.js b/test/javascripts/models/session_test.js index 93f6341781c..612ad6f40eb 100644 --- a/test/javascripts/models/session_test.js +++ b/test/javascripts/models/session_test.js @@ -13,6 +13,8 @@ test('current', function(){ Discourse.Session.current('orange', 'juice'); equal(session.get('orange'), "juice", "it can be updated"); + Discourse.Session.current('zero', 0); + equal(session.get('zero'), 0); }); test('highestSeenByTopic', function() {