Skip to content

Commit

Permalink
No commit message
Browse files Browse the repository at this point in the history
  • Loading branch information
jviney committed Oct 11, 2007
1 parent d6a43be commit 5f4053c
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG
@@ -1,6 +1,10 @@
[11 October 2007]

* Make tag_counts work correctly with STI.

[3 October 2007]

# Improve documentation.
* Improve documentation.

* Fix TagsHelper and test.

Expand Down
6 changes: 5 additions & 1 deletion lib/acts_as_taggable.rb
Expand Up @@ -96,7 +96,11 @@ def find_options_for_tag_counts(options = {})
scope && scope[:conditions],
start_at,
end_at
].compact.join(' AND ')
]

conditions << type_condition unless descends_from_active_record?
conditions.compact!
conditions = conditions.join(' AND ')

joins = ["LEFT OUTER JOIN #{Tagging.table_name} ON #{Tag.table_name}.id = #{Tagging.table_name}.tag_id"]
joins << "LEFT OUTER JOIN #{table_name} ON #{table_name}.#{primary_key} = #{Tagging.table_name}.taggable_id"
Expand Down
8 changes: 7 additions & 1 deletion test/acts_as_taggable_test.rb
Expand Up @@ -266,13 +266,19 @@ def test_clearing_cached_tag_list
assert_equal "", posts(:jonathan_sky).cached_tag_list
end

def test_basic_functionalty_with_sti
def test_find_tagged_with_using_sti
special_post = SpecialPost.create!(:text => "Test", :tag_list => "Random")

assert_equal [special_post], SpecialPost.find_tagged_with("Random")
assert Post.find_tagged_with("Random").include?(special_post)
end

def test_tag_counts_using_sti
SpecialPost.create!(:text => "Test", :tag_list => "Nature")

assert_tag_counts SpecialPost.tag_counts, :nature => 1
end

def test_case_insensitivity
assert_difference "Tag.count", 1 do
Post.create!(:text => "Test", :tag_list => "one")
Expand Down

0 comments on commit 5f4053c

Please sign in to comment.