diff --git a/app/assets/javascripts/discourse.js b/app/assets/javascripts/discourse.js index d0d8e3859..6f9a1b9b7 100644 --- a/app/assets/javascripts/discourse.js +++ b/app/assets/javascripts/discourse.js @@ -94,7 +94,7 @@ window.Discourse = Ember.Application.createWithMixins(Discourse.Ajax, { loginRequired: function() { return Discourse.SiteSettings.login_required && !Discourse.User.current(); - }.property(), + }.property().volatile(), redirectIfLoginRequired: function(route) { if(this.get('loginRequired')) { route.transitionTo('login'); } diff --git a/test/javascripts/helpers/create-pretender.js.es6 b/test/javascripts/helpers/create-pretender.js.es6 index 74dfcc331..3b6d5f68d 100644 --- a/test/javascripts/helpers/create-pretender.js.es6 +++ b/test/javascripts/helpers/create-pretender.js.es6 @@ -46,6 +46,10 @@ export default function() { this.post('/users', function() { return response({success: true}); }); + + this.get('/login.html', function() { + return [200, {}, 'LOGIN PAGE']; + }); }); diff --git a/test/javascripts/helpers/qunit_helpers.js b/test/javascripts/helpers/qunit_helpers.js index cb5aa1b7f..b64508074 100644 --- a/test/javascripts/helpers/qunit_helpers.js +++ b/test/javascripts/helpers/qunit_helpers.js @@ -1,22 +1,28 @@ /* global asyncTest */ /* exported integration, testController, controllerFor, asyncTestDiscourse, fixture */ -function integration(name, lifecycle) { +function integration(name, options) { module("Integration: " + name, { setup: function() { Ember.run(Discourse, Discourse.advanceReadiness); - if (lifecycle && lifecycle.setup) { - lifecycle.setup.call(this); - } + if (options) { + if (options.setup) { + options.setup.call(this); + } - if (lifecycle && lifecycle.user) { - Discourse.User.resetCurrent(Discourse.User.create(lifecycle.user)); + if (options.user) { + Discourse.User.resetCurrent(Discourse.User.create(options.user)); + } + + if (options.settings) { + Discourse.SiteSettings = jQuery.extend(true, Discourse.SiteSettings, options.settings); + } } Discourse.reset(); }, teardown: function() { - if (lifecycle && lifecycle.teardown) { - lifecycle.teardown.call(this); + if (options && options.teardown) { + options.teardown.call(this); } Discourse.reset(); diff --git a/test/javascripts/integration/static-test.js.es6 b/test/javascripts/integration/static-test.js.es6 index a0c6884d5..6eaa2fb08 100644 --- a/test/javascripts/integration/static-test.js.es6 +++ b/test/javascripts/integration/static-test.js.es6 @@ -1,21 +1,28 @@ integration("Static"); test("Static Pages", function() { - expect(4); visit("/faq"); andThen(function() { ok(exists(".body-page"), "The content is present"); }); + visit("/guidelines"); andThen(function() { ok(exists(".body-page"), "The content is present"); }); + visit("/tos"); andThen(function() { ok(exists(".body-page"), "The content is present"); }); + visit("/privacy"); andThen(function() { ok(exists(".body-page"), "The content is present"); }); + + visit("/login"); + andThen(function() { + equal(currentPath(), "discovery.latest", "it redirects them to latest unless `login_required`"); + }); });