Stub out requests to hostip.info during tests
authorAndy Allan <git@gravitystorm.co.uk>
Fri, 28 Oct 2016 12:43:13 +0000 (13:43 +0100)
committerAndy Allan <git@gravitystorm.co.uk>
Sun, 30 Oct 2016 09:28:46 +0000 (10:28 +0100)
These are detecting the correct locale for showing terms during signup

test/controllers/site_controller_test.rb
test/controllers/user_controller_test.rb
test/integration/oauth_test.rb
test/integration/page_locale_test.rb
test/integration/user_roles_test.rb
test/integration/user_terms_seen_test.rb

index 70eacb3aa9bbb6868b57e8528658fa7201e97874..71ccc4e515fb7fdd9b77be24a8cd39755d7ae978 100644 (file)
@@ -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
 
   ##
index 409a93b4e26b61b52ea56e99f18b18713b6173f1..cc8142b01dec42e1ee2f0a00a984c0fe62bd111d 100644 (file)
@@ -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
index 00a9ae06d50a0e40b6722966f36206a44fb7092c..62eab0deed18d95b291a09b1d1148fa206f6d4a3 100644 (file)
@@ -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)
 
index 43810db997885e1815ab20d2d668869649bc322c..60255f66c3849f8bfb2d9c09f316bd05c8f2f6e1 100644 (file)
@@ -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
index 5732430255d8b1703f1e1bfb35e13ca33475607f..e228489dd1d2cd06e1f10105da4cb32c03bbf3bd 100644 (file)
@@ -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)
index a664feeb0aa13bca045bb7d438aa4dea4a0ad021..596cccc43d79ed9222343898e1376a6bcc23a413 100644 (file)
@@ -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)