Skip to content
This repository has been archived by the owner on Dec 21, 2019. It is now read-only.

Commit

Permalink
No commit message
Browse files Browse the repository at this point in the history
  • Loading branch information
jviney committed Oct 22, 2007
1 parent cab29c1 commit b98ac11
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
4 changes: 4 additions & 0 deletions 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.
Expand Down
2 changes: 2 additions & 0 deletions 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|
Expand Down
8 changes: 7 additions & 1 deletion test/tags_helper_test.rb
Expand Up @@ -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

Expand All @@ -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

0 comments on commit b98ac11

Please sign in to comment.