3 class PageLocaleTest < ActionDispatch::IntegrationTest
5 I18n.with_locale "en" do
6 user = create(:user, :languages => [])
10 post "/login", :params => { :username => user.email, :password => "test" }
14 assert_empty User.find(user.id).languages
15 assert_select "html[lang=?]", "en"
17 get "/diary/new", :headers => { "HTTP_ACCEPT_LANGUAGE" => "fr, en" }
18 assert_equal %w[fr en], User.find(user.id).languages
19 assert_select "html[lang=?]", "fr"
24 I18n.with_locale "en" do
25 user = create(:user, :languages => ["de"])
28 assert_select "html[lang=?]", "en"
30 get "/diary", :params => { :locale => "es" }
31 assert_select "html[lang=?]", "es"
35 post "/login", :params => { :username => user.email, :password => "test" }
39 assert_select "html[lang=?]", "de"
41 get "/diary", :params => { :locale => "fr" }
42 assert_select "html[lang=?]", "fr"