Permalink
Browse files

Options get passed to column object with actions block.

  • Loading branch information...
bobbytables committed Oct 31, 2012
1 parent 02910b4 commit 5ddd64ea8d0412f1f9229b1c4f59159e0647716e
Showing with 21 additions and 2 deletions.
  1. +1 −1 lib/table_cloth/actions.rb
  2. +13 −1 spec/lib/presenters/default_spec.rb
  3. +7 −0 spec/support/dummy_table_with_actions.rb
@@ -4,7 +4,7 @@ class Actions
def initialize(options={}, &block)
@options = options
- @column = Columns::Action.new(:actions)
+ @column = Columns::Action.new(:actions, options)
block.arity > 0 ? block.call(self) : instance_eval(&block)
end
@@ -139,16 +139,28 @@
end
context 'specific configuration' do
- let(:doc) { Nokogiri::HTML(subject.render_table) }
let(:dummy_table) do
Class.new(TableCloth::Base) do
column :email, td_options: { class: 'email_column' }
end
end
+ let(:dummy_table_with_actions) { Class.new(DummyTableWithActions) }
+
it 'td has a class set' do
+ doc = Nokogiri::HTML(subject.render_table)
doc.at_xpath('//td')[:class].should include 'email_column'
end
+
+ context 'actions column' do
+ let(:dummy_table) { Class.new(DummyTableWithActions) }
+
+ it 'actions column has a class set' do
+ doc = Nokogiri::HTML(subject.render_table)
+ td = doc.at_css('td:last')
+ td[:class].should include "actions"
+ end
+ end
end
context 'table configuration' do
@@ -0,0 +1,7 @@
+class DummyTableWithActions < TableCloth::Base
+ column :name
+
+ actions(td_options: {class: 'actions'}) do
+ action {|object| link_to "Edit", "/#{object.id}/edit" }
+ end
+end

0 comments on commit 5ddd64e

Please sign in to comment.