mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-23 23:58:31 -05:00
Using Discourse.XYZ
in templates is deprecated. This fixes that, plus
adds some more integration tests to make sure login required is working.
This commit is contained in:
parent
4907053cc4
commit
4bec839d9d
8 changed files with 37 additions and 13 deletions
|
@ -98,14 +98,6 @@ window.Discourse = Ember.Application.createWithMixins(Discourse.Ajax, {
|
|||
return loginController.authenticationComplete(options);
|
||||
},
|
||||
|
||||
loginRequired: function() {
|
||||
return Discourse.SiteSettings.login_required && !Discourse.User.current();
|
||||
}.property().volatile(),
|
||||
|
||||
redirectIfLoginRequired: function(route) {
|
||||
if(this.get('loginRequired')) { route.transitionTo('login'); }
|
||||
},
|
||||
|
||||
/**
|
||||
Start up the Discourse application by running all the initializers we've defined.
|
||||
|
||||
|
|
|
@ -6,4 +6,9 @@ export default Ember.Controller.extend({
|
|||
Discourse.SiteSettings.allow_new_registrations &&
|
||||
!Discourse.SiteSettings.enable_sso;
|
||||
}.property(),
|
||||
|
||||
loginRequired: function() {
|
||||
return Discourse.SiteSettings.login_required && !Discourse.User.current();
|
||||
}.property()
|
||||
|
||||
});
|
||||
|
|
|
@ -7,6 +7,7 @@ export default DiscourseController.extend({
|
|||
loadingNotifications: false,
|
||||
needs: ['application'],
|
||||
|
||||
loginRequired: Em.computed.alias('controllers.application.loginRequired'),
|
||||
canSignUp: Em.computed.alias('controllers.application.canSignUp'),
|
||||
|
||||
showSignUpButton: function() {
|
||||
|
|
|
@ -21,6 +21,13 @@ Discourse.Route = Em.Route.extend({
|
|||
Em.run.scheduleOnce('afterRender', Discourse.Route, 'cleanDOM');
|
||||
},
|
||||
|
||||
redirectIfLoginRequired: function() {
|
||||
var app = this.controllerFor('application');
|
||||
if (app.get('loginRequired')) {
|
||||
this.replaceWith('login');
|
||||
}
|
||||
},
|
||||
|
||||
openTopicDraft: function(model){
|
||||
// If there's a draft, open the create topic composer
|
||||
if (model.draft) {
|
||||
|
|
|
@ -8,8 +8,7 @@
|
|||
@module Discourse
|
||||
**/
|
||||
Discourse.DiscoveryRoute = Discourse.Route.extend(Discourse.ScrollTop, Discourse.OpenComposer, {
|
||||
|
||||
redirect: function() { Discourse.redirectIfLoginRequired(this); },
|
||||
redirect: function() { return this.redirectIfLoginRequired(); },
|
||||
|
||||
beforeModel: function(transition) {
|
||||
if (transition.targetName.indexOf("discovery.top") === -1 &&
|
||||
|
|
|
@ -4,7 +4,7 @@ var isTransitioning = false,
|
|||
SCROLL_DELAY = 500;
|
||||
|
||||
Discourse.TopicRoute = Discourse.Route.extend({
|
||||
redirect: function() { Discourse.redirectIfLoginRequired(this); },
|
||||
redirect: function() { return this.redirectIfLoginRequired(); },
|
||||
|
||||
queryParams: {
|
||||
filter: { replace: true },
|
||||
|
|
|
@ -65,7 +65,7 @@
|
|||
</li>
|
||||
{{/if}}
|
||||
<li>
|
||||
{{#if Discourse.loginRequired}}
|
||||
{{#if loginRequired}}
|
||||
<a id='search-button' class='icon expand' href='#' aria-hidden="true" {{action showLogin}}>
|
||||
{{icon search}}
|
||||
</a>
|
||||
|
@ -80,7 +80,7 @@
|
|||
{{/if}}
|
||||
</li>
|
||||
<li class='categories dropdown'>
|
||||
{{#if Discourse.loginRequired}}
|
||||
{{#if loginRequired}}
|
||||
<a class='icon'
|
||||
href="#"
|
||||
aria-hidden="true"
|
||||
|
|
|
@ -19,4 +19,24 @@ test("redirect", function() {
|
|||
andThen(function() {
|
||||
ok(exists('.login-modal'), "they can still access the login modal");
|
||||
});
|
||||
|
||||
click('.modal-header .close');
|
||||
andThen(function() {
|
||||
ok(!exists('.login-modal'), "it closes the login modal");
|
||||
});
|
||||
|
||||
click('#search-button');
|
||||
andThen(function() {
|
||||
ok(exists('.login-modal'), "clicking search opens the login modal");
|
||||
});
|
||||
|
||||
click('.modal-header .close');
|
||||
andThen(function() {
|
||||
ok(!exists('.login-modal'), "it closes the login modal");
|
||||
});
|
||||
|
||||
click('#site-map');
|
||||
andThen(function() {
|
||||
ok(exists('.login-modal'), "site map opens the login modal");
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue