Skip to content

Commit

Permalink
Options get passed to column object with actions block.
Browse files Browse the repository at this point in the history
  • Loading branch information
bobbytables committed Oct 31, 2012
1 parent 02910b4 commit 5ddd64e
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/table_cloth/actions.rb
Expand Up @@ -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
Expand Down
14 changes: 13 additions & 1 deletion spec/lib/presenters/default_spec.rb
Expand Up @@ -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
Expand Down
7 changes: 7 additions & 0 deletions spec/support/dummy_table_with_actions.rb
@@ -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.