Commit 24b5794f authored by jplang's avatar jplang

Don't change Setting.default_language in tests.

git-svn-id: https://svn.redmine.org/redmine/trunk@13924 e93f8b46-1217-0410-a6f0-8f06a7374b81
parent f731ea06
......@@ -236,7 +236,6 @@ class TimeEntryReportsControllerTest < ActionController::TestCase
end
def test_csv_big_5
Setting.default_language = "zh-TW"
str_utf8 = "\xe4\xb8\x80\xe6\x9c\x88".force_encoding('UTF-8')
str_big5 = "\xa4@\xa4\xeb".force_encoding('Big5')
user = User.find_by_id(3)
......@@ -256,9 +255,11 @@ class TimeEntryReportsControllerTest < ActionController::TestCase
assert_equal 7.3, te2.hours
assert_equal 3, te2.user_id
get :report, :project_id => 1, :columns => 'day',
:from => "2011-11-11", :to => "2011-11-11",
:criteria => ["user"], :format => "csv"
with_settings :default_language => "zh-TW" do
get :report, :project_id => 1, :columns => 'day',
:from => "2011-11-11", :to => "2011-11-11",
:criteria => ["user"], :format => "csv"
end
assert_response :success
assert_equal 'text/csv; header=present', @response.content_type
lines = @response.body.chomp.split("\n")
......@@ -278,7 +279,6 @@ class TimeEntryReportsControllerTest < ActionController::TestCase
end
def test_csv_cannot_convert_should_be_replaced_big_5
Setting.default_language = "zh-TW"
str_utf8 = "\xe4\xbb\xa5\xe5\x86\x85".force_encoding('UTF-8')
user = User.find_by_id(3)
user.firstname = str_utf8
......@@ -297,9 +297,11 @@ class TimeEntryReportsControllerTest < ActionController::TestCase
assert_equal 7.3, te2.hours
assert_equal 3, te2.user_id
get :report, :project_id => 1, :columns => 'day',
:from => "2011-11-11", :to => "2011-11-11",
:criteria => ["user"], :format => "csv"
with_settings :default_language => "zh-TW" do
get :report, :project_id => 1, :columns => 'day',
:from => "2011-11-11", :to => "2011-11-11",
:criteria => ["user"], :format => "csv"
end
assert_response :success
assert_equal 'text/csv; header=present', @response.content_type
lines = @response.body.chomp.split("\n")
......
......@@ -21,6 +21,7 @@ class WelcomeControllerTest < ActionController::TestCase
fixtures :projects, :news, :users, :members
def setup
Setting.default_language = 'en'
User.current = nil
end
......@@ -34,28 +35,24 @@ class WelcomeControllerTest < ActionController::TestCase
end
def test_browser_language
Setting.default_language = 'en'
@request.env['HTTP_ACCEPT_LANGUAGE'] = 'fr,fr-fr;q=0.8,en-us;q=0.5,en;q=0.3'
get :index
assert_equal :fr, @controller.current_language
end
def test_browser_language_alternate
Setting.default_language = 'en'
@request.env['HTTP_ACCEPT_LANGUAGE'] = 'zh-TW'
get :index
assert_equal :"zh-TW", @controller.current_language
end
def test_browser_language_alternate_not_valid
Setting.default_language = 'en'
@request.env['HTTP_ACCEPT_LANGUAGE'] = 'fr-CA'
get :index
assert_equal :fr, @controller.current_language
end
def test_browser_language_should_be_ignored_with_force_default_language_for_anonymous
Setting.default_language = 'en'
@request.env['HTTP_ACCEPT_LANGUAGE'] = 'fr,fr-fr;q=0.8,en-us;q=0.5,en;q=0.3'
with_settings :force_default_language_for_anonymous => '1' do
get :index
......@@ -64,20 +61,20 @@ class WelcomeControllerTest < ActionController::TestCase
end
def test_user_language_should_be_used
Setting.default_language = 'fi'
user = User.find(2).update_attribute :language, 'it'
@request.session[:user_id] = 2
@request.env['HTTP_ACCEPT_LANGUAGE'] = 'fr,fr-fr;q=0.8,en-us;q=0.5,en;q=0.3'
get :index
assert_equal :it, @controller.current_language
with_settings :default_language => 'fi' do
get :index
assert_equal :it, @controller.current_language
end
end
def test_user_language_should_be_ignored_if_force_default_language_for_loggedin
Setting.default_language = 'fi'
user = User.find(2).update_attribute :language, 'it'
@request.session[:user_id] = 2
@request.env['HTTP_ACCEPT_LANGUAGE'] = 'fr,fr-fr;q=0.8,en-us;q=0.5,en;q=0.3'
with_settings :force_default_language_for_loggedin => '1' do
with_settings :force_default_language_for_loggedin => '1', :default_language => 'fi' do
get :index
assert_equal :fi, @controller.current_language
end
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment