mirror of
https://github.com/discourse/discourse.git
synced 2024-11-23 10:30:01 +08:00
TESTS: Integration tests for login_required
This commit is contained in:
parent
e63cdc50bb
commit
adea5b36a0
|
@ -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'); }
|
||||
|
|
|
@ -46,6 +46,10 @@ export default function() {
|
|||
this.post('/users', function() {
|
||||
return response({success: true});
|
||||
});
|
||||
|
||||
this.get('/login.html', function() {
|
||||
return [200, {}, 'LOGIN PAGE'];
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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`");
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue
Block a user