Fix broken tests

This commit is contained in:
Sam 2014-06-05 21:16:27 +10:00
parent 17dbc568c8
commit a4de1f25c1
2 changed files with 11 additions and 4 deletions

View File

@ -20,7 +20,10 @@ Discourse.HeaderView = Discourse.View.extend({
$html = $('html'), $html = $('html'),
self = this; self = this;
self.set('controller.visibleDropdown', elementId); var controller = self.get('controller');
if(controller && !controller.isDestroyed){
controller.set('visibleDropdown', elementId);
}
// we need to ensure we are rendered, // we need to ensure we are rendered,
// this optimises the speed of the initial render // this optimises the speed of the initial render
var render = $target.data('render'); var render = $target.data('render');
@ -38,7 +41,10 @@ Discourse.HeaderView = Discourse.View.extend({
$dropdown.fadeOut('fast'); $dropdown.fadeOut('fast');
$li.removeClass('active'); $li.removeClass('active');
$html.data('hide-dropdown', null); $html.data('hide-dropdown', null);
self.set('controller.visibleDropdown', null); var controller = self.get('controller');
if(controller && !controller.isDestroyed){
controller.set('visibleDropdown', null);
}
return $html.off('click.d-dropdown'); return $html.off('click.d-dropdown');
}; };

View File

@ -90,10 +90,11 @@ test("sitemap dropdown", function() {
Discourse.SiteSettings.faq_url = "faq-url"; Discourse.SiteSettings.faq_url = "faq-url";
Discourse.SiteSettings.enable_mobile_theme = true; Discourse.SiteSettings.enable_mobile_theme = true;
Discourse.User.current.returns({ Discourse.User.current.returns(Ember.Object.create({
username: 'test',
staff: true, staff: true,
site_flagged_posts_count: 1 site_flagged_posts_count: 1
}); }));
Discourse.Category.list.returns([ Discourse.Category.list.returns([
Discourse.Category.create({ Discourse.Category.create({