-
Notifications
You must be signed in to change notification settings - Fork 10
Fix problem with reload not working correctly when auto is set for language #68
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,8 +26,28 @@ def test_reload_if_messages_are_not_latest | |
assert_equal custom_message_setting.updated_on.to_i.to_s, I18n.backend.send(:translations)[:en][:redmine_message_customize_timestamp] | ||
end | ||
|
||
def test_reload_if_user_language_is_auto_and_browser_language_messages_are_not_latest | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍🏼 |
||
# Reload based on the browser language if the language in User.current is ''(auto) | ||
User.find_by_login('admin').update(language: '') | ||
log_user('admin', 'admin') | ||
custom_message_setting = CustomMessageSetting.find_or_default | ||
|
||
custom_message_setting.update_with_custom_messages({'label_home' => 'Changed home'}, 'ja') | ||
assert_equal 'Home2', I18n.backend.send(:translations)[:ja][:label_home] | ||
assert_equal '1640995200', I18n.backend.send(:translations)[:ja][:redmine_message_customize_timestamp] | ||
with_settings :default_language => 'en' do | ||
dummy_http_headers = @request.env | ||
dummy_http_headers['HTTP_ACCEPT_LANGUAGE'] = 'ja' | ||
ActionDispatch::Request.any_instance.stubs(:env).returns(dummy_http_headers) | ||
|
||
get '/issues' | ||
end | ||
assert_equal 'Changed home', I18n.backend.send(:translations)[:ja][:label_home] | ||
assert_equal custom_message_setting.updated_on.to_i.to_s, I18n.backend.send(:translations)[:ja][:redmine_message_customize_timestamp] | ||
end | ||
|
||
def test_reload_if_user_language_is_auto_and_default_language_messages_are_not_latest | ||
# User.currentのlanguageが''(auto)でもSetting.default_languageを元に用語の最新化を行うこと | ||
# Reload based on the default language if the language in User.current is ''(auto) and request.env['HTTP_ACCEPT_LANGUAGE'] is nil | ||
User.find_by_login('admin').update(language: '') | ||
log_user('admin', 'admin') | ||
custom_message_setting = CustomMessageSetting.find_or_default | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This method is still being used in the following locations.
redmine_message_customize/app/controllers/custom_message_settings_controller.rb
Line 57 in f1761f3
As a result, when no message customization settings are registered, visiting the message customization settings screen (
/custom_message_settings/edit
) causes the following error:How about fixing it like this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@hidakatsuya
Thanks for the feedback.
You're right, that makes sense. I'll go with current_user_language as it's clearer and easier to maintain.
f8d6844 fixes this problem.