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('
'); +document.write(''); + +Discourse.rootElement = '#ember-testing'; +Discourse.setupForTesting(); +Discourse.injectTestHelpers(); + + +Discourse.SiteSettings = {"title":"Discourse Meta","logo_url":"/assets/logo.png","logo_small_url":"/assets/logo-single.png","traditional_markdown_linebreaks":false,"top_menu":"latest|new|unread|read|favorited|categories","post_menu":"like|edit|flag|delete|share|bookmark|reply","share_links":"twitter|facebook|google+|email","track_external_right_clicks":false,"must_approve_users":false,"ga_tracking_code":"UA-33736483-2","ga_domain_name":"","enable_long_polling":true,"polling_interval":3000,"anon_polling_interval":30000,"min_post_length":20,"max_post_length":16000,"min_topic_title_length":15,"max_topic_title_length":255,"min_private_message_title_length":2,"allow_uncategorized_topics":true,"min_search_term_length":3,"flush_timings_secs":5,"supress_reply_directly_below":true,"email_domains_blacklist":"mailinator.com","email_domains_whitelist":null,"version_checks":true,"min_title_similar_length":10,"min_body_similar_length":15,"category_colors":"BF1E2E|F1592A|F7941D|9EB83B|3AB54A|12A89D|25AAE2|0E76BD|652D90|92278F|ED207B|8C6238|231F20|808281|B3B5B4|283890","max_upload_size_kb":1024,"category_featured_topics":6,"favicon_url":"/assets/favicon.ico","dynamic_favicon":false,"uncategorized_name":"uncategorized","uncategorized_color":"AB9364","uncategorized_text_color":"FFFFFF","invite_only":false,"login_required":false,"enable_local_logins":true,"enable_local_account_create":true,"enable_google_logins":true,"enable_yahoo_logins":true,"enable_twitter_logins":true,"enable_facebook_logins":true,"enable_cas_logins":false,"enable_github_logins":true,"enable_persona_logins":true,"educate_until_posts":2,"topic_views_heat_low":1000,"topic_views_heat_medium":2000,"topic_views_heat_high":5000}; + +Discourse.Router.map(function() { + return Discourse.routeBuilder.call(this); +}); + +function exists(selector) { + return !!find(selector).length; +} \ No newline at end of file diff --git a/test/stylesheets/test_helper.css b/test/stylesheets/test_helper.css new file mode 100644 index 00000000000..424b07f8025 --- /dev/null +++ b/test/stylesheets/test_helper.css @@ -0,0 +1,4 @@ +/* + *= require application + *= require_tree . +*/