diff --git a/lib/table_cloth/actions.rb b/lib/table_cloth/actions.rb index 8b7ad79..5e5da1a 100644 --- a/lib/table_cloth/actions.rb +++ b/lib/table_cloth/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 diff --git a/spec/lib/presenters/default_spec.rb b/spec/lib/presenters/default_spec.rb index 1fa9dfd..251cd31 100644 --- a/spec/lib/presenters/default_spec.rb +++ b/spec/lib/presenters/default_spec.rb @@ -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 diff --git a/spec/support/dummy_table_with_actions.rb b/spec/support/dummy_table_with_actions.rb new file mode 100644 index 0000000..9d77a03 --- /dev/null +++ b/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 \ No newline at end of file