- user = create(:user, :languages => [])
-
- post "/login", :params => { :username => user.email, :password => "test" }
- follow_redirect!
-
- get "/diary/new"
- assert_equal [], 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