mirror of
https://github.com/discourse/discourse.git
synced 2025-03-15 20:35:50 +08:00
BUGFIX: clicking on the Logo generates a javascript error
This commit is contained in:
parent
eeb83adf71
commit
0dc0740408
@ -25,6 +25,19 @@ Discourse.ListController = Discourse.Controller.extend({
|
||||
});
|
||||
}.property("category"),
|
||||
|
||||
/**
|
||||
Refresh our current topic list
|
||||
@method refresh
|
||||
**/
|
||||
refresh: function() {
|
||||
debugger;
|
||||
var listTopicsController = this.get('controllers.listTopics');
|
||||
listTopicsController.set('model.loaded', false);
|
||||
this.load(this.get('filterMode')).then(function (topicList) {
|
||||
listTopicsController.set('model', topicList);
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
Load a list based on a filter
|
||||
|
||||
|
@ -20,7 +20,6 @@ Discourse.URL = Em.Object.createWithMixins({
|
||||
@param {String} path The path we are replacing our history state with.
|
||||
**/
|
||||
replaceState: function(path) {
|
||||
|
||||
if (window.history &&
|
||||
window.history.pushState &&
|
||||
window.history.replaceState &&
|
||||
@ -48,7 +47,6 @@ Discourse.URL = Em.Object.createWithMixins({
|
||||
@param {String} path The path we are routing to.
|
||||
**/
|
||||
routeTo: function(path) {
|
||||
|
||||
var oldPath = window.location.pathname;
|
||||
path = path.replace(/https?\:\/\/[^\/]+/, '');
|
||||
|
||||
@ -120,7 +118,6 @@ Discourse.URL = Em.Object.createWithMixins({
|
||||
@param {String} path the path we're navigating to
|
||||
**/
|
||||
navigatedToPost: function(oldPath, path) {
|
||||
|
||||
var newMatches = this.TOPIC_REGEXP.exec(path),
|
||||
newTopicId = newMatches ? newMatches[2] : null;
|
||||
|
||||
@ -168,7 +165,6 @@ Discourse.URL = Em.Object.createWithMixins({
|
||||
@param {String} path the path we're navigating to
|
||||
**/
|
||||
navigatedToHome: function(oldPath, path) {
|
||||
|
||||
var defaultFilter = "/" + Discourse.ListController.filters[0];
|
||||
|
||||
if (path === "/" && (oldPath === "/" || oldPath === defaultFilter)) {
|
||||
@ -217,5 +213,4 @@ Discourse.URL = Em.Object.createWithMixins({
|
||||
return Discourse.__container__.lookup('controller:' + name);
|
||||
}
|
||||
|
||||
|
||||
});
|
||||
|
18
test/javascripts/lib/url_test.js
Normal file
18
test/javascripts/lib/url_test.js
Normal file
@ -0,0 +1,18 @@
|
||||
module("Discourse.URL");
|
||||
|
||||
test("navigatedToHome", function() {
|
||||
var fakeListController = { refresh: function() { return true; } };
|
||||
var mock = sinon.mock(fakeListController);
|
||||
this.stub(Discourse.URL, "controllerFor").returns(fakeListController);
|
||||
|
||||
mock.expects("refresh").twice();
|
||||
ok(Discourse.URL.navigatedToHome("/", "/"));
|
||||
|
||||
var defaultFilter = "/" + Discourse.ListController.filters[0];
|
||||
ok(Discourse.URL.navigatedToHome(defaultFilter, "/"));
|
||||
|
||||
ok(!Discourse.URL.navigatedToHome("/old", "/new"));
|
||||
|
||||
// make sure we called the .refresh() method
|
||||
mock.verify();
|
||||
});
|
Loading…
x
Reference in New Issue
Block a user