3 class PageLocaleTest < ActionDispatch::IntegrationTest
13 user = create(:user, :languages => [])
17 post "/login", :params => { :username => user.email, :password => "test" }
21 assert_empty User.find(user.id).languages
22 assert_select "html[lang=?]", "en"
24 get "/diary/new", :headers => { "HTTP_ACCEPT_LANGUAGE" => "fr, en" }
25 assert_equal %w[fr en], User.find(user.id).languages
26 assert_select "html[lang=?]", "fr"
30 user = create(:user, :languages => ["de"])
33 assert_select "html[lang=?]", "en"
35 get "/diary", :params => { :locale => "es" }
36 assert_select "html[lang=?]", "es"
40 post "/login", :params => { :username => user.email, :password => "test" }
44 assert_select "html[lang=?]", "de"
46 get "/diary", :params => { :locale => "fr" }
47 assert_select "html[lang=?]", "fr"