3 class PageLocaleTest < ActionDispatch::IntegrationTest
5 user = create(:user, :languages => [])
9 post "/login", :params => { :username => user.email, :password => "test" }
13 assert_empty User.find(user.id).languages
14 assert_select "html[lang=?]", "en"
16 get "/diary/new", :headers => { "HTTP_ACCEPT_LANGUAGE" => "fr, en" }
17 assert_equal %w[fr en], User.find(user.id).languages
18 assert_select "html[lang=?]", "fr"
22 user = create(:user, :languages => ["de"])
25 assert_select "html[lang=?]", "en"
27 get "/diary", :params => { :locale => "es" }
28 assert_select "html[lang=?]", "es"
32 post "/login", :params => { :username => user.email, :password => "test" }
36 assert_select "html[lang=?]", "de"
38 get "/diary", :params => { :locale => "fr" }
39 assert_select "html[lang=?]", "fr"