3 class PageLocaleTest < ActionDispatch::IntegrationTest
13 user = create(:user, :languages => [])
15 post "/login", :params => { :username => user.email, :password => "test" }
19 assert_equal [], User.find(user.id).languages
20 assert_select "html[lang=?]", "en"
22 get "/diary/new", :headers => { "HTTP_ACCEPT_LANGUAGE" => "fr, en" }
23 assert_equal %w[fr en], User.find(user.id).languages
24 assert_select "html[lang=?]", "fr"
28 user = create(:user, :languages => ["de"])
31 assert_select "html[lang=?]", "en"
33 get "/diary", :params => { :locale => "es" }
34 assert_select "html[lang=?]", "es"
36 post "/login", :params => { :username => user.email, :password => "test" }
40 assert_select "html[lang=?]", "de"
42 get "/diary", :params => { :locale => "fr" }
43 assert_select "html[lang=?]", "fr"