Permalink
Browse files

3rd argument for column block

  • Loading branch information...
1 parent 570c956 commit 3f1453595913c24bb7d88c5330d6cb7bcacf5e44 @bogdan committed Mar 3, 2014
Showing with 20 additions and 1 deletion.
  1. +1 −1 lib/datagrid/columns/column.rb
  2. +19 −0 spec/datagrid/columns_spec.rb
View
2 lib/datagrid/columns/column.rb
@@ -138,7 +138,7 @@ def block
def generic_value(model, grid)
if self.data_block.arity >= 1
- Datagrid::Utils.apply_args(model, grid, &data_block)
+ Datagrid::Utils.apply_args(model, grid, grid.data_row(model), &data_block)
else
model.instance_eval(&self.data_block)
end
View
19 spec/datagrid/columns_spec.rb
@@ -228,4 +228,23 @@
}.should raise_error
end
end
+
+ describe "column value" do
+ it "should support conversion" do
+ group = Group.create!
+ Entry.create(:group => group)
+ Entry.create(:group => group)
+ grid = test_report do
+ scope { Group }
+ column(:entries_count) do |g|
+ g.entries.count
+ end
+ column(:odd_entries) do |_, _, row|
+ row.entries_count.odd?
+ end
+ end
+
+ grid.row_for(group).should == [2, false]
+ end
+ end
end

0 comments on commit 3f14535

Please sign in to comment.