1
0
mirror of https://github.com/meineerde/redmine.git synced 2026-01-01 13:19:39 +00:00

Let QueryColumn accept a Proc as caption (#18276).

git-svn-id: http://svn.redmine.org/redmine/trunk@13558 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang 2014-11-04 21:00:59 +00:00
parent 4cd67587ce
commit bc3bd8aff2
2 changed files with 18 additions and 1 deletions

View File

@ -33,7 +33,14 @@ class QueryColumn
end
def caption
@caption_key.is_a?(Symbol) ? l(@caption_key) : @caption_key
case @caption_key
when Symbol
l(@caption_key)
when Proc
@caption_key.call
else
@caption_key
end
end
# Returns true if the column is sortable, otherwise false

View File

@ -1415,4 +1415,14 @@ class QueryTest < ActiveSupport::TestCase
end
end
end
def test_query_column_should_accept_a_symbol_as_caption
c = QueryColumn.new('foo', :caption => :general_text_Yes)
assert_equal 'Yes', c.caption
end
def test_query_column_should_accept_a_proc_as_caption
c = QueryColumn.new('foo', :caption => lambda {'Foo'})
assert_equal 'Foo', c.caption
end
end