diff --git a/app/models/query.rb b/app/models/query.rb index a4d34d1..755c41d 100644 --- a/app/models/query.rb +++ b/app/models/query.rb @@ -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 diff --git a/test/unit/query_test.rb b/test/unit/query_test.rb index c9c6693..bf3dcd5 100644 --- a/test/unit/query_test.rb +++ b/test/unit/query_test.rb @@ -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