Stub out requests to hostip.info during tests

These are detecting the correct locale for showing terms during signup
This commit is contained in:
Andy Allan 2016-10-28 13:43:13 +01:00
parent 6bc488a983
commit d3d6e9902c
6 changed files with 19 additions and 0 deletions

View 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
##

View 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

View 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)

View 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

View 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)

View 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)