@@ -33,7 +33,14 class QueryColumn | |||
|
33 | 33 | end |
|
34 | 34 | |
|
35 | 35 | def caption |
|
36 | @caption_key.is_a?(Symbol) ? l(@caption_key) : @caption_key | |
|
36 | case @caption_key | |
|
37 | when Symbol | |
|
38 | l(@caption_key) | |
|
39 | when Proc | |
|
40 | @caption_key.call | |
|
41 | else | |
|
42 | @caption_key | |
|
43 | end | |
|
37 | 44 | end |
|
38 | 45 | |
|
39 | 46 | # Returns true if the column is sortable, otherwise false |
@@ -1415,4 +1415,14 class QueryTest < ActiveSupport::TestCase | |||
|
1415 | 1415 | end |
|
1416 | 1416 | end |
|
1417 | 1417 | end |
|
1418 | ||
|
1419 | def test_query_column_should_accept_a_symbol_as_caption | |
|
1420 | c = QueryColumn.new('foo', :caption => :general_text_Yes) | |
|
1421 | assert_equal 'Yes', c.caption | |
|
1422 | end | |
|
1423 | ||
|
1424 | def test_query_column_should_accept_a_proc_as_caption | |
|
1425 | c = QueryColumn.new('foo', :caption => lambda {'Foo'}) | |
|
1426 | assert_equal 'Foo', c.caption | |
|
1427 | end | |
|
1418 | 1428 | end |
General Comments 0
You need to be logged in to leave comments.
Login now