Skip to content

Commit

Permalink
Fixed: Export CSV - Custom field true/false not using translation (#1…
Browse files Browse the repository at this point in the history
…6081).

git-svn-id: http://svn.redmine.org/redmine/trunk@12896 e93f8b46-1217-0410-a6f0-8f06a7374b81
  • Loading branch information
jplang committed Feb 15, 2014
1 parent 88568da commit 1114bf5
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 0 deletions.
4 changes: 4 additions & 0 deletions app/helpers/queries_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,10 @@ def csv_value(column, issue, value)
when 'IssueRelation'
other = value.other_issue(issue)
l(value.label_for(issue)) + " ##{other.id}"
when 'TrueClass'
l(:general_text_Yes)
when 'FalseClass'
l(:general_text_No)
else
value.to_s
end
Expand Down
8 changes: 8 additions & 0 deletions test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,14 @@ def with_current_user(user, &block)
User.current = saved_user
end

def with_locale(locale, &block)
saved_localed = ::I18n.locale
::I18n.locale = locale
yield
ensure
::I18n.locale = saved_localed
end

def change_user_password(login, new_password)
user = User.where(:login => login).first
user.password, user.password_confirmation = new_password, new_password
Expand Down
14 changes: 14 additions & 0 deletions test/unit/helpers/queries_helper_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,18 @@ def test_filters_options_has_empty_item
assert_equal filter_count + 1, fo.size
assert_equal [], fo[0]
end

def test_query_to_csv_should_translate_boolean_custom_field_values
f = IssueCustomField.generate!(:field_format => 'bool', :name => 'Boolean', :is_for_all => true, :trackers => Tracker.all)
issues = [
Issue.generate!(:project_id => 1, :tracker_id => 1, :custom_field_values => {f.id.to_s => '0'}),
Issue.generate!(:project_id => 1, :tracker_id => 1, :custom_field_values => {f.id.to_s => '1'})
]

with_locale 'fr' do
csv = query_to_csv(issues, IssueQuery.new, :columns => 'all')
assert_include "Oui", csv
assert_include "Non", csv
end
end
end

0 comments on commit 1114bf5

Please sign in to comment.