Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

No commit message

  • Loading branch information...
commit b98ac11508c98b2179586cdac25ae014734eaa90 1 parent cab29c1
@jviney jviney authored
Showing with 13 additions and 1 deletion.
  1. +4 โˆ’0 CHANGELOG
  2. +2 โˆ’0  lib/tags_helper.rb
  3. +7 โˆ’1 test/tags_helper_test.rb
View
4 CHANGELOG
@@ -1,3 +1,7 @@
+[23 October 2007]
+
+* Fix tag_cloud when no tags are present.
+
[22 October 2007]
* Fix find_tagged_with using :match_all and :include.
View
2  lib/tags_helper.rb
@@ -1,6 +1,8 @@
module TagsHelper
# See the README for an example using tag_cloud.
def tag_cloud(tags, classes)
+ return if tags.empty?
+
max_count = tags.sort_by(&:count).last.count.to_f
tags.each do |tag|
View
8 test/tags_helper_test.rb
@@ -8,7 +8,7 @@ class TagsHelperTest < Test::Unit::TestCase
def test_tag_cloud
cloud_elements = []
- tag_cloud(Post.tag_counts, %w(css1 css2 css3 css4)) do |tag, css_class|
+ tag_cloud Post.tag_counts, %w(css1 css2 css3 css4) do |tag, css_class|
cloud_elements << [tag, css_class]
end
@@ -19,4 +19,10 @@ def test_tag_cloud
[tags(:question), "css1"]
], cloud_elements
end
+
+ def test_tag_cloud_when_no_tags
+ tag_cloud SpecialPost.tag_counts, %w(css1) do
+ assert false, "tag_cloud should not yield"
+ end
+ end
end
Please sign in to comment.
Something went wrong with that request. Please try again.