]> git.openstreetmap.org Git - rails.git/commitdiff
Extract the hostip.info stubbing into a common method.
authorAndy Allan <git@gravitystorm.co.uk>
Wed, 9 Nov 2016 16:00:47 +0000 (16:00 +0000)
committerAndy Allan <git@gravitystorm.co.uk>
Wed, 9 Nov 2016 16:00:47 +0000 (16:00 +0000)
There doesn't appear to be any before(:suite) equivalent for Minitest
so this is the least-surprising way to do this.

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
test/test_helper.rb

index 71ccc4e515fb7fdd9b77be24a8cd39755d7ae978..afa50a35696a2acfee56caceca4ab64b1dbdb08b 100644 (file)
@@ -9,7 +9,7 @@ class SiteControllerTest < ActionController::TestCase
     Object.const_set("ID_KEY", client_applications(:oauth_web_app).key)
     Object.const_set("POTLATCH2_KEY", client_applications(:oauth_web_app).key)
 
     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")
+    stub_signup_requests
   end
 
   ##
   end
 
   ##
index eb57e2689c7c059f5b88742a7c6c3104ca9ebc1d..1b9ada83b9f264e913272cd9198665627f34cff1 100644 (file)
@@ -4,7 +4,7 @@ class UserControllerTest < ActionController::TestCase
   api_fixtures
 
   setup do
   api_fixtures
 
   setup do
-    stub_request(:get, "http://api.hostip.info/country.php?ip=0.0.0.0")
+    stub_signup_requests
   end
 
   ##
   end
 
   ##
index 62eab0deed18d95b291a09b1d1148fa206f6d4a3..e3ca535206749b860cb7e1d4890aef9580b5629d 100644 (file)
@@ -7,7 +7,7 @@ class OAuthTest < ActionDispatch::IntegrationTest
   include OAuth::Helper
 
   setup do
   include OAuth::Helper
 
   setup do
-    stub_request(:get, "http://api.hostip.info/country.php?ip=127.0.0.1")
+    stub_signup_requests
   end
 
   def test_oauth10_web_app
   end
 
   def test_oauth10_web_app
index 60255f66c3849f8bfb2d9c09f316bd05c8f2f6e1..ee1f89afa23cc4918e5cde3023c99f179643ce52 100644 (file)
@@ -5,7 +5,7 @@ class PageLocaleTest < ActionDispatch::IntegrationTest
 
   def setup
     I18n.locale = "en"
 
   def setup
     I18n.locale = "en"
-    stub_request(:get, "http://api.hostip.info/country.php?ip=127.0.0.1")
+    stub_signup_requests
   end
 
   def teardown
   end
 
   def teardown
index e228489dd1d2cd06e1f10105da4cb32c03bbf3bd..2613c402cea5988611b970423c8a111ed738d99b 100644 (file)
@@ -4,7 +4,7 @@ class UserRolesTest < ActionDispatch::IntegrationTest
   fixtures :users, :user_roles
 
   setup do
   fixtures :users, :user_roles
 
   setup do
-    stub_request(:get, "http://api.hostip.info/country.php?ip=127.0.0.1")
+    stub_signup_requests
   end
 
   test "grant" do
   end
 
   test "grant" do
index 596cccc43d79ed9222343898e1376a6bcc23a413..d4d7450fb545eeb994203917741cb70091d623b8 100644 (file)
@@ -4,7 +4,7 @@ class UserTermsSeenTest < ActionDispatch::IntegrationTest
   fixtures :users
 
   setup do
   fixtures :users
 
   setup do
-    stub_request(:get, "http://api.hostip.info/country.php?ip=127.0.0.1")
+    stub_signup_requests
   end
 
   def test_api_blocked
   end
 
   def test_api_blocked
index c45331f2062ce3ea995f571c4fc380ce894cb720..420512e741e075d894c8ec1fb78a1f1eba860b3e 100644 (file)
@@ -174,5 +174,11 @@ module ActiveSupport
       url = "https://www.gravatar.com/avatar/#{hash}?d=404"
       stub_request(:get, url).and_return(:status => status, :body => body)
     end
       url = "https://www.gravatar.com/avatar/#{hash}?d=404"
       stub_request(:get, url).and_return(:status => status, :body => body)
     end
+
+    def stub_signup_requests
+      # Controller tests and integration tests use different IPs
+      stub_request(:get, "http://api.hostip.info/country.php?ip=0.0.0.0")
+      stub_request(:get, "http://api.hostip.info/country.php?ip=127.0.0.1")
+    end
   end
 end
   end
 end