From 182242c7fb8437212db414efcb03c14136e65358 Mon Sep 17 00:00:00 2001 From: Seth Call Date: Sat, 21 Dec 2013 15:12:25 +0000 Subject: [PATCH] * VRFS-856 - hopefully the fix --- admin/config/application.rb | 3 +++ web/Gemfile | 2 +- web/config/application.rb | 4 ++++ web/spec/spec_helper.rb | 10 ++++++++-- web/spec/support/utilities.rb | 31 +++++++++++++++++++++++++------ 5 files changed, 41 insertions(+), 9 deletions(-) diff --git a/admin/config/application.rb b/admin/config/application.rb index 5b76766e9..92b12cdd3 100644 --- a/admin/config/application.rb +++ b/admin/config/application.rb @@ -52,6 +52,9 @@ module JamAdmin # Enable escaping HTML in JSON. config.active_support.escape_html_entities_in_json = true + # suppress locale complaint: http://stackoverflow.com/questions/20361428/rails-i18n-validation-deprecation-warning + config.i18n.enforce_available_locales = false + # Use SQL instead of Active Record's schema dumper when creating the database. # This is necessary if your schema can't be completely dumped by the schema dumper, # like if you have constraints or database-specific column types diff --git a/web/Gemfile b/web/Gemfile index 8ba1f45e7..0f5f3066e 100644 --- a/web/Gemfile +++ b/web/Gemfile @@ -99,7 +99,7 @@ end gem 'rack-test' # gem 'rb-fsevent', '0.9.1', :require => false # gem 'growl', '1.0.3' - gem 'poltergeist' #, :path => '/Users/seth/workspace/poltergeist/' + gem 'poltergeist' end diff --git a/web/config/application.rb b/web/config/application.rb index 713ee2a1f..6d5e6d5ec 100644 --- a/web/config/application.rb +++ b/web/config/application.rb @@ -70,6 +70,9 @@ if defined?(Bundler) # Version of your assets, change this if you want to expire all your assets config.assets.version = '1.0' + # suppress locale complaint: http://stackoverflow.com/questions/20361428/rails-i18n-validation-deprecation-warning + config.i18n.enforce_available_locales = false + # Add the assets/fonts directory to assets.paths config.assets.paths << "#{Rails.root}/app/assets/fonts" @@ -159,5 +162,6 @@ if defined?(Bundler) config.ga_ua = 'UA-44184562-2' # google analytics config.ga_suppress_admin = true + end end diff --git a/web/spec/spec_helper.rb b/web/spec/spec_helper.rb index f04c6b6df..67d835ba3 100644 --- a/web/spec/spec_helper.rb +++ b/web/spec/spec_helper.rb @@ -112,12 +112,18 @@ Spork.prefork do end config.before(:each) do + + end + + config.append_after(:each) do + end config.after(:each) do + Capybara.reset_sessions! + reset_session_mapper + if example.metadata[:js] - Capybara.reset_sessions! - #sleep (ENV['SLEEP_JS'] || 0.2).to_i # necessary though otherwise intermittent failures: http://stackoverflow.com/questions/14265983/upgrading-capybara-from-1-0-1-to-1-1-4-makes-database-cleaner-break-my-specs end # dump response.body if an example fails diff --git a/web/spec/support/utilities.rb b/web/spec/support/utilities.rb index 38e2467e3..a067e81e6 100644 --- a/web/spec/support/utilities.rb +++ b/web/spec/support/utilities.rb @@ -1,16 +1,35 @@ include ApplicationHelper +# holds a single test's session name's, mapped to pooled session names +$capybara_session_mapper = {} + +# called in before (or after) test, to make sure each test run has it's own map of session names +def reset_session_mapper + $capybara_session_mapper.clear +end + +# manages the mapped session name +def mapped_session_name(session_name) + return :default if session_name == :default # special treatment for the built-in session + $capybara_session_mapper[session_name] ||= $capybara_session_mapper.length +end + +# in place of ever using Capybara.session_name directly, +# this utility is used to handle the mapping of session names in a way across all tests runs +def in_client(name) + session_name = name.class == JamRuby::User ? name.id : name + + Capybara.session_name = mapped_session_name(session_name) + + yield +end + + def cookie_jar Capybara.current_session.driver.browser.current_session.instance_variable_get(:@rack_mock_session).cookie_jar end -def in_client(name) # to assist multiple-client RSpec/Capybara testing - Capybara.session_name = name.class == JamRuby::User ? name.id : name - - yield -end - def sign_in(user) visit signin_path