Permalink
Browse files

Fix ability to pass options to #to_csv method

  • Loading branch information...
1 parent 2b74101 commit e4e07b18f427518e8f6cf9ee6266b4898ad04863 @bogdan committed Jan 29, 2013
Showing with 12 additions and 1 deletion.
  1. +8 −1 lib/datagrid/columns.rb
  2. +4 −0 spec/datagrid/columns_spec.rb
View
@@ -101,8 +101,15 @@ def data_hash
end
end
+ # Returns a CSV representation of the data in the table
+ #
+ # Example:
+ #
+ # grid.to_csv
+ # grid.to_csv(:id, :name)
+ # grid.to_csv(:col_sep => ';')
def to_csv(*column_names)
- options = columns.extract_options!
+ options = column_names.extract_options!
klass = if RUBY_VERSION >= "1.9"
require 'csv'
CSV
@@ -53,6 +53,10 @@
it "should support csv export of particular columns" do
subject.to_csv(:name).should == "Name\nStar\n"
end
+
+ it "should support csv export options" do
+ subject.to_csv(:col_sep => ";").should == "Group;Name;Access level;Pet\nPop;Star;admin;ROTTWEILER\n"
+ end
end
it "should support columns with model and report arguments" do

0 comments on commit e4e07b1

Please sign in to comment.