Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fix footer failing to render when there are multiple cells

  • Loading branch information...
commit 9616c7442e6a4d327f2ba446c243cfead9248277 1 parent 8acf7d3
Richard Luther authored obrie committed
View
1  CHANGELOG.rdoc
@@ -1,5 +1,6 @@
== master
+* Fix footer failing to render when there are multiple cells [Richard Luther]
* Fix TableHelper::RowBuilder failing on Ruby 1.9.1
* Release gems via rake-gemcutter instead of rubyforge
View
2  lib/table_helper/footer.rb
@@ -27,7 +27,7 @@ def initialize(table) #:nodoc:
def html #:nodoc:
# Force the last cell to span the remaining columns
cells = row.cells.values
- colspan = table.header.columns.length - cells[0..-2].inject(0) {|count, (name, cell)| count += (cell[:colspan] || 1).to_i}
+ colspan = table.header.columns.length - cells[0..-2].inject(0) {|count, cell| count += (cell[:colspan] || 1).to_i}
cells.last[:colspan] ||= colspan if colspan > 1
html_options = @html_options.dup
View
17 test/unit/footer_test.rb
@@ -76,6 +76,23 @@ def test_should_include_colspan_if_more_headers_than_footers
end_str
assert_html_equal expected, @footer.html
end
+
+ def test_should_include_colspan_on_last_cell_if_more_headers_than_footers
+ @table.header :title, :name, :description, :value, :created_at, :updated_at
+ @footer.cell :average, 5, :colspan => 2
+ @footer.cell :stdev, 1
+
+ expected = <<-end_str
+ <tfoot>
+ <tr>
+ <td class="object-total">20</td>
+ <td class="object-average" colspan="2">5</td>
+ <td class="object-stdev" colspan="3">1</td>
+ </tr>
+ </tfoot>
+ end_str
+ assert_html_equal expected, @footer.html
+ end
end
class FooterWithEmptyCollectionTest < Test::Unit::TestCase
Please sign in to comment.
Something went wrong with that request. Please try again.