mirror of
https://github.com/codeninjasllc/discourse.git
synced 2025-04-30 07:53:57 -04:00
TESTS: Integration tests for login_required
This commit is contained in:
parent
e63cdc50bb
commit
adea5b36a0
4 changed files with 27 additions and 10 deletions
app/assets/javascripts
test/javascripts
|
@ -94,7 +94,7 @@ window.Discourse = Ember.Application.createWithMixins(Discourse.Ajax, {
|
||||||
|
|
||||||
loginRequired: function() {
|
loginRequired: function() {
|
||||||
return Discourse.SiteSettings.login_required && !Discourse.User.current();
|
return Discourse.SiteSettings.login_required && !Discourse.User.current();
|
||||||
}.property(),
|
}.property().volatile(),
|
||||||
|
|
||||||
redirectIfLoginRequired: function(route) {
|
redirectIfLoginRequired: function(route) {
|
||||||
if(this.get('loginRequired')) { route.transitionTo('login'); }
|
if(this.get('loginRequired')) { route.transitionTo('login'); }
|
||||||
|
|
|
@ -46,6 +46,10 @@ export default function() {
|
||||||
this.post('/users', function() {
|
this.post('/users', function() {
|
||||||
return response({success: true});
|
return response({success: true});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
this.get('/login.html', function() {
|
||||||
|
return [200, {}, 'LOGIN PAGE'];
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,22 +1,28 @@
|
||||||
/* global asyncTest */
|
/* global asyncTest */
|
||||||
/* exported integration, testController, controllerFor, asyncTestDiscourse, fixture */
|
/* exported integration, testController, controllerFor, asyncTestDiscourse, fixture */
|
||||||
function integration(name, lifecycle) {
|
function integration(name, options) {
|
||||||
module("Integration: " + name, {
|
module("Integration: " + name, {
|
||||||
setup: function() {
|
setup: function() {
|
||||||
Ember.run(Discourse, Discourse.advanceReadiness);
|
Ember.run(Discourse, Discourse.advanceReadiness);
|
||||||
if (lifecycle && lifecycle.setup) {
|
if (options) {
|
||||||
lifecycle.setup.call(this);
|
if (options.setup) {
|
||||||
}
|
options.setup.call(this);
|
||||||
|
}
|
||||||
|
|
||||||
if (lifecycle && lifecycle.user) {
|
if (options.user) {
|
||||||
Discourse.User.resetCurrent(Discourse.User.create(lifecycle.user));
|
Discourse.User.resetCurrent(Discourse.User.create(options.user));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (options.settings) {
|
||||||
|
Discourse.SiteSettings = jQuery.extend(true, Discourse.SiteSettings, options.settings);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Discourse.reset();
|
Discourse.reset();
|
||||||
},
|
},
|
||||||
|
|
||||||
teardown: function() {
|
teardown: function() {
|
||||||
if (lifecycle && lifecycle.teardown) {
|
if (options && options.teardown) {
|
||||||
lifecycle.teardown.call(this);
|
options.teardown.call(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
Discourse.reset();
|
Discourse.reset();
|
||||||
|
|
|
@ -1,21 +1,28 @@
|
||||||
integration("Static");
|
integration("Static");
|
||||||
|
|
||||||
test("Static Pages", function() {
|
test("Static Pages", function() {
|
||||||
expect(4);
|
|
||||||
visit("/faq");
|
visit("/faq");
|
||||||
andThen(function() {
|
andThen(function() {
|
||||||
ok(exists(".body-page"), "The content is present");
|
ok(exists(".body-page"), "The content is present");
|
||||||
});
|
});
|
||||||
|
|
||||||
visit("/guidelines");
|
visit("/guidelines");
|
||||||
andThen(function() {
|
andThen(function() {
|
||||||
ok(exists(".body-page"), "The content is present");
|
ok(exists(".body-page"), "The content is present");
|
||||||
});
|
});
|
||||||
|
|
||||||
visit("/tos");
|
visit("/tos");
|
||||||
andThen(function() {
|
andThen(function() {
|
||||||
ok(exists(".body-page"), "The content is present");
|
ok(exists(".body-page"), "The content is present");
|
||||||
});
|
});
|
||||||
|
|
||||||
visit("/privacy");
|
visit("/privacy");
|
||||||
andThen(function() {
|
andThen(function() {
|
||||||
ok(exists(".body-page"), "The content is present");
|
ok(exists(".body-page"), "The content is present");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
visit("/login");
|
||||||
|
andThen(function() {
|
||||||
|
equal(currentPath(), "discovery.latest", "it redirects them to latest unless `login_required`");
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue