From e96d21ed7d2fce1d07fc381200d31919a2d93299 Mon Sep 17 00:00:00 2001 From: Azul Date: Thu, 6 Feb 2014 12:08:15 +0100 Subject: integration test with en-EN language Tests fail on machines that default to other available languages. Also move setting capybara driver to be javascript driver into the BrowserIntegrationTest. --- billing/test/integration/subscription_test.rb | 6 ++---- test/integration/os_detection_test.rb | 8 ++------ test/test_helper.rb | 5 +++++ users/test/integration/browser/account_test.rb | 4 ---- users/test/integration/browser/session_test.rb | 1 - 5 files changed, 9 insertions(+), 15 deletions(-) diff --git a/billing/test/integration/subscription_test.rb b/billing/test/integration/subscription_test.rb index b95bfac..9d150e0 100644 --- a/billing/test/integration/subscription_test.rb +++ b/billing/test/integration/subscription_test.rb @@ -2,9 +2,8 @@ require 'test_helper' require 'fake_braintree' require 'capybara/rails' -class SubscriptionTest < ActionDispatch::IntegrationTest +class SubscriptionTest < BrowserIntegrationTest include Warden::Test::Helpers - include Capybara::DSL include CustomerTestHelper include StubRecordHelper @@ -17,7 +16,6 @@ class SubscriptionTest < ActionDispatch::IntegrationTest payment_method_token: @braintree_customer.credit_cards.first.token, price: '10' @subscription = response.subscription - Capybara.current_driver = Capybara.javascript_driver end teardown do @@ -30,9 +28,9 @@ class SubscriptionTest < ActionDispatch::IntegrationTest @customer.stubs(:subscriptions).returns([@subscription]) @subscription.stubs(:balance).returns 0 visit user_subscriptions_path(@customer.user_id, :locale => nil) + page.save_screenshot('/tmp/subscriptions.png') assert page.has_content?("Subscriptions") assert page.has_content?("Status: Active") - page.save_screenshot('/tmp/subscriptions.png') end # test "user cannot see all subscriptions for other user" do diff --git a/test/integration/os_detection_test.rb b/test/integration/os_detection_test.rb index cb254aa..6d9a648 100644 --- a/test/integration/os_detection_test.rb +++ b/test/integration/os_detection_test.rb @@ -2,19 +2,15 @@ require 'test_helper' class OsDetectionTest < BrowserIntegrationTest - setup do - Capybara.current_driver = Capybara.javascript_driver - end - test "old windows shows deactivated download" do - page.driver.headers = { "User-Agent" => "Win98" } + page.driver.add_headers "User-Agent" => "Win98" visit '/' assert_selector "html.oldwin" assert has_text? "not available" end test "android shows android download" do - page.driver.headers = { "User-Agent" => "Android" } + page.driver.add_headers "User-Agent" => "Android" visit '/' assert_selector "html.android" assert has_no_text? "not available" diff --git a/test/test_helper.rb b/test/test_helper.rb index 3e301e7..1dff80a 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -43,6 +43,11 @@ class BrowserIntegrationTest < ActionDispatch::IntegrationTest include Capybara::DSL include IntegrationTestHelper + setup do + Capybara.current_driver = Capybara.javascript_driver + page.driver.add_headers 'ACCEPT-LANGUAGE' => 'en-EN' + end + teardown do Capybara.reset_sessions! # Forget the (simulated) browser state Capybara.use_default_driver # Revert Capybara.current_driver to Capybara.default_driver diff --git a/users/test/integration/browser/account_test.rb b/users/test/integration/browser/account_test.rb index 3785b72..a5677ad 100644 --- a/users/test/integration/browser/account_test.rb +++ b/users/test/integration/browser/account_test.rb @@ -2,10 +2,6 @@ require 'test_helper' class AccountTest < BrowserIntegrationTest - setup do - Capybara.current_driver = Capybara.javascript_driver - end - teardown do Identity.destroy_all_disabled end diff --git a/users/test/integration/browser/session_test.rb b/users/test/integration/browser/session_test.rb index bb4e8c9..3a41b3a 100644 --- a/users/test/integration/browser/session_test.rb +++ b/users/test/integration/browser/session_test.rb @@ -3,7 +3,6 @@ require 'test_helper' class SessionTest < BrowserIntegrationTest setup do - Capybara.current_driver = Capybara.javascript_driver @username, password = submit_signup end -- cgit v1.2.3