From 8d08391ff552e70b6cf80a66d082660a2add1c3e Mon Sep 17 00:00:00 2001 From: Robin Ward Date: Fri, 2 Aug 2013 18:48:02 -0400 Subject: [PATCH] FIX: Allow `Discourse.Session.current()` API to update to 0 --- app/assets/javascripts/discourse/models/session.js | 4 ++-- app/assets/javascripts/discourse/models/user.js | 2 +- test/javascripts/models/session_test.js | 2 ++ 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/app/assets/javascripts/discourse/models/session.js b/app/assets/javascripts/discourse/models/session.js index 2af3681b2..0025ba5b6 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 646403805..0d679f99e 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 93f634178..612ad6f40 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() {