X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/d3d6e9902c8b03fcd31df253cf395f06f757880a..73c95847a6680bea7f35fe5b3da6eb4e52757b9c:/test/integration/page_locale_test.rb diff --git a/test/integration/page_locale_test.rb b/test/integration/page_locale_test.rb index 60255f66c..2c4939b05 100644 --- a/test/integration/page_locale_test.rb +++ b/test/integration/page_locale_test.rb @@ -1,11 +1,8 @@ require "test_helper" class PageLocaleTest < ActionDispatch::IntegrationTest - fixtures :users - def setup I18n.locale = "en" - stub_request(:get, "http://api.hostip.info/country.php?ip=127.0.0.1") end def teardown @@ -13,34 +10,36 @@ class PageLocaleTest < ActionDispatch::IntegrationTest end def test_defaulting - user = users(:second_public_user) + user = create(:user, :languages => []) - post_via_redirect "/login", :username => user.email, :password => "test" + post "/login", :params => { :username => user.email, :password => "test" } + follow_redirect! - get "/diary/new", {} + get "/diary/new" assert_equal [], User.find(user.id).languages assert_select "html[lang=?]", "en" - get "/diary/new", {}, { "HTTP_ACCEPT_LANGUAGE" => "fr, en" } - assert_equal %w(fr en), User.find(user.id).languages + get "/diary/new", :headers => { "HTTP_ACCEPT_LANGUAGE" => "fr, en" } + assert_equal %w[fr en], User.find(user.id).languages assert_select "html[lang=?]", "fr" end def test_override - user = users(:german_user) + user = create(:user, :languages => ["de"]) get "/diary" assert_select "html[lang=?]", "en" - get "/diary", :locale => "es" + get "/diary", :params => { :locale => "es" } assert_select "html[lang=?]", "es" - post_via_redirect "/login", :username => user.email, :password => "test" + post "/login", :params => { :username => user.email, :password => "test" } + follow_redirect! get "/diary" assert_select "html[lang=?]", "de" - get "/diary", :locale => "fr" + get "/diary", :params => { :locale => "fr" } assert_select "html[lang=?]", "fr" end end