X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/63e4a89323f4b0dba5e64b227f3e8508c94373b6..b3e13eb7525daa3e3adf2ee55bd8956595545e01:/test/integration/page_locale_test.rb?ds=sidebyside diff --git a/test/integration/page_locale_test.rb b/test/integration/page_locale_test.rb index c8e5026d4..6f6d7779f 100644 --- a/test/integration/page_locale_test.rb +++ b/test/integration/page_locale_test.rb @@ -2,40 +2,44 @@ require "test_helper" class PageLocaleTest < ActionDispatch::IntegrationTest def test_defaulting - user = create(:user, :languages => []) - - get "/login" - follow_redirect! - post "/login", :params => { :username => user.email, :password => "test" } - follow_redirect! - - get "/diary/new" - assert_empty User.find(user.id).languages - assert_select "html[lang=?]", "en" - - get "/diary/new", :headers => { "HTTP_ACCEPT_LANGUAGE" => "fr, en" } - assert_equal %w[fr en], User.find(user.id).languages - assert_select "html[lang=?]", "fr" + I18n.with_locale "en" do + user = create(:user, :languages => []) + + get "/login" + follow_redirect! + post "/login", :params => { :username => user.email, :password => "test" } + follow_redirect! + + get "/diary/new" + assert_empty User.find(user.id).languages + assert_select "html[lang=?]", "en" + + 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 end def test_override - user = create(:user, :languages => ["de"]) + I18n.with_locale "en" do + user = create(:user, :languages => ["de"]) - get "/diary" - assert_select "html[lang=?]", "en" + get "/diary" + assert_select "html[lang=?]", "en" - get "/diary", :params => { :locale => "es" } - assert_select "html[lang=?]", "es" + get "/diary", :params => { :locale => "es" } + assert_select "html[lang=?]", "es" - get "/login" - follow_redirect! - post "/login", :params => { :username => user.email, :password => "test" } - follow_redirect! + get "/login" + follow_redirect! + post "/login", :params => { :username => user.email, :password => "test" } + follow_redirect! - get "/diary" - assert_select "html[lang=?]", "de" + get "/diary" + assert_select "html[lang=?]", "de" - get "/diary", :params => { :locale => "fr" } - assert_select "html[lang=?]", "fr" + get "/diary", :params => { :locale => "fr" } + assert_select "html[lang=?]", "fr" + end end end