From d3d6e9902c8b03fcd31df253cf395f06f757880a Mon Sep 17 00:00:00 2001 From: Andy Allan Date: Fri, 28 Oct 2016 13:43:13 +0100 Subject: [PATCH] Stub out requests to hostip.info during tests These are detecting the correct locale for showing terms during signup --- test/controllers/site_controller_test.rb | 2 ++ test/controllers/user_controller_test.rb | 4 ++++ test/integration/oauth_test.rb | 4 ++++ test/integration/page_locale_test.rb | 1 + test/integration/user_roles_test.rb | 4 ++++ test/integration/user_terms_seen_test.rb | 4 ++++ 6 files changed, 19 insertions(+) diff --git a/test/controllers/site_controller_test.rb b/test/controllers/site_controller_test.rb index 70eacb3aa..71ccc4e51 100644 --- a/test/controllers/site_controller_test.rb +++ b/test/controllers/site_controller_test.rb @@ -8,6 +8,8 @@ class SiteControllerTest < ActionController::TestCase def setup Object.const_set("ID_KEY", client_applications(:oauth_web_app).key) Object.const_set("POTLATCH2_KEY", client_applications(:oauth_web_app).key) + + stub_request(:get, "http://api.hostip.info/country.php?ip=0.0.0.0") end ## diff --git a/test/controllers/user_controller_test.rb b/test/controllers/user_controller_test.rb index 409a93b4e..cc8142b01 100644 --- a/test/controllers/user_controller_test.rb +++ b/test/controllers/user_controller_test.rb @@ -3,6 +3,10 @@ require "test_helper" class UserControllerTest < ActionController::TestCase api_fixtures + setup do + stub_request(:get, "http://api.hostip.info/country.php?ip=0.0.0.0") + end + ## # test all routes which lead to this controller def test_routes diff --git a/test/integration/oauth_test.rb b/test/integration/oauth_test.rb index 00a9ae06d..62eab0dee 100644 --- a/test/integration/oauth_test.rb +++ b/test/integration/oauth_test.rb @@ -6,6 +6,10 @@ class OAuthTest < ActionDispatch::IntegrationTest include OAuth::Helper + setup do + stub_request(:get, "http://api.hostip.info/country.php?ip=127.0.0.1") + end + def test_oauth10_web_app client = client_applications(:oauth_web_app) diff --git a/test/integration/page_locale_test.rb b/test/integration/page_locale_test.rb index 43810db99..60255f66c 100644 --- a/test/integration/page_locale_test.rb +++ b/test/integration/page_locale_test.rb @@ -5,6 +5,7 @@ class PageLocaleTest < ActionDispatch::IntegrationTest def setup I18n.locale = "en" + stub_request(:get, "http://api.hostip.info/country.php?ip=127.0.0.1") end def teardown diff --git a/test/integration/user_roles_test.rb b/test/integration/user_roles_test.rb index 573243025..e228489dd 100644 --- a/test/integration/user_roles_test.rb +++ b/test/integration/user_roles_test.rb @@ -3,6 +3,10 @@ require "test_helper" class UserRolesTest < ActionDispatch::IntegrationTest fixtures :users, :user_roles + setup do + stub_request(:get, "http://api.hostip.info/country.php?ip=127.0.0.1") + end + test "grant" do check_fail(:grant, :public_user, :moderator) check_fail(:grant, :moderator_user, :moderator) diff --git a/test/integration/user_terms_seen_test.rb b/test/integration/user_terms_seen_test.rb index a664feeb0..596cccc43 100644 --- a/test/integration/user_terms_seen_test.rb +++ b/test/integration/user_terms_seen_test.rb @@ -3,6 +3,10 @@ require "test_helper" class UserTermsSeenTest < ActionDispatch::IntegrationTest fixtures :users + setup do + stub_request(:get, "http://api.hostip.info/country.php?ip=127.0.0.1") + end + def test_api_blocked with_terms_seen(true) do user = users(:terms_not_seen_user) -- 2.43.2