diff --git a/Gemfile b/Gemfile index a156f0f2c3c..9428ae0a790 100644 --- a/Gemfile +++ b/Gemfile @@ -100,6 +100,7 @@ group :test, :development do gem 'guard-jshint-on-rails', require: false gem 'certified', require: false gem 'fabrication', require: false + gem 'qunit-rails' gem 'guard-jasmine', require: false gem 'guard-rspec', require: false gem 'guard-spork', require: false diff --git a/Gemfile.lock b/Gemfile.lock index d6a591407b8..e6aba121f0b 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -317,6 +317,8 @@ GEM pry (~> 0.9.10) pry-rails (0.2.2) pry (>= 0.9.10) + qunit-rails (0.0.3) + railties (>= 3.2.3) rack (1.4.5) rack-cache (1.2) rack (>= 0.4) @@ -531,6 +533,7 @@ DEPENDENCIES pg pry-nav pry-rails + qunit-rails rack-cache rack-cors rack-mini-profiler diff --git a/app/assets/javascripts/discourse/controllers/list_controller.js b/app/assets/javascripts/discourse/controllers/list_controller.js index 021fa582dc4..e23f95513c6 100644 --- a/app/assets/javascripts/discourse/controllers/list_controller.js +++ b/app/assets/javascripts/discourse/controllers/list_controller.js @@ -15,6 +15,7 @@ Discourse.ListController = Discourse.Controller.extend({ availableNavItems: function() { var summary = this.get('filterSummary'); var loggedOn = !!Discourse.User.current(); + return Discourse.SiteSettings.top_menu.split("|").map(function(i) { return Discourse.NavItem.fromText(i, { loggedOn: loggedOn diff --git a/app/assets/javascripts/discourse/routes/application_routes.js b/app/assets/javascripts/discourse/routes/application_routes.js index c7b2d6c5ec3..97a4345b54c 100644 --- a/app/assets/javascripts/discourse/routes/application_routes.js +++ b/app/assets/javascripts/discourse/routes/application_routes.js @@ -30,7 +30,8 @@ Discourse.Route.buildRoutes(function() { }); // the homepage is the first item of the 'top_menu' site setting - var homepage = PreloadStore.get('siteSettings').top_menu.split("|")[0].split(",")[0]; + var settings = Discourse.SiteSettings || PreloadStore.get('siteSettings') + var homepage = settings.top_menu.split("|")[0].split(",")[0]; this.route(homepage, { path: '/' }); this.route('categories', { path: '/categories' }); diff --git a/test/javascripts/integration/header_test.js b/test/javascripts/integration/header_test.js new file mode 100644 index 00000000000..dca99a727a9 --- /dev/null +++ b/test/javascripts/integration/header_test.js @@ -0,0 +1,23 @@ +module("Header", { + setup: function() { + Ember.run(Discourse, Discourse.advanceReadiness); + }, + + teardown: function() { + $('#discourse-modal').modal('hide') + $('#discourse-modal').remove() + Discourse.reset(); + } +}); + +test("/", function() { + expect(2); + + visit("/").then(function() { + ok(exists("header"), "The header was rendered"); + ok(exists("#site-logo"), "The logo was shown"); + }); + +}); + + diff --git a/test/javascripts/test_helper.js b/test/javascripts/test_helper.js new file mode 100644 index 00000000000..b318c3192bc --- /dev/null +++ b/test/javascripts/test_helper.js @@ -0,0 +1,52 @@ + +//= require env + +//= require ../../app/assets/javascripts/preload_store.js + +// probe framework first +//= require ../../app/assets/javascripts/discourse/components/probes.js + +// Externals we need to load first +//= require ../../app/assets/javascripts/external/jquery-1.9.1.js +//= require ../../app/assets/javascripts/external/jquery.ui.widget.js +//= require ../../app/assets/javascripts/external/handlebars-1.0.rc.4.js +//= require ../../app/assets/javascripts/external_development/ember.js +//= require ../../app/assets/javascripts/external_development/group-helper.js + +//= require ../../app/assets/javascripts/locales/i18n +//= require ../../app/assets/javascripts/locales/date_locales.js +//= require ../../app/assets/javascripts/discourse/helpers/i18n_helpers +//= require ../../app/assets/javascripts/locales/en +// +// Pagedown customizations +//= require ../../app/assets/javascripts/pagedown_custom.js + +// The rest of the externals +//= require_tree ../../app/assets/javascripts/external + +// Stuff we need to load first +//= require main_include +//= require admin +//= require_tree ../../app/assets/javascripts/defer + +//= require main_include +//= require_tree . +//= require_self + +document.write('