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 Jul 8, 2007
1 parent 23ddde9 commit 72fdf04
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG
Original file line number Original file line Diff line number Diff line change
@@ -1,3 +1,7 @@
[8 July 2007]

* find_options_for_tagged_with should not alter its arguments

[1 July 2007] [1 July 2007]


* Fix incorrect tagging when the case of the tag list is changed. * Fix incorrect tagging when the case of the tag list is changed.
Expand Down
7 changes: 6 additions & 1 deletion lib/acts_as_taggable.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -37,7 +37,12 @@ module SingletonMethods
# :match_all - Find models that match all of the gievn tags, not just one # :match_all - Find models that match all of the gievn tags, not just one
# :conditions - A piece of SQL conditions to add to the query # :conditions - A piece of SQL conditions to add to the query
def find_options_for_tagged_with(tags, options = {}) def find_options_for_tagged_with(tags, options = {})
tags = TagList.from(tags).names if tags.is_a?(String) tags = if tags.is_a?(String)
TagList.from(tags).names
else
tags.dup
end

tags.compact! tags.compact!
tags.map!(&:to_s) tags.map!(&:to_s)


Expand Down
6 changes: 6 additions & 0 deletions test/acts_as_taggable_test.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@ def test_find_options_for_tagged_with_no_tags_returns_empty_hash
assert_equal Hash.new, Post.find_options_for_tagged_with([nil]) assert_equal Hash.new, Post.find_options_for_tagged_with([nil])
end end


def test_find_options_for_tagged_with_leavs_arguments_unchanged
original_tags = photos(:jonathan_questioning_dog).tags.dup
Photo.find_options_for_tagged_with(photos(:jonathan_questioning_dog).tags)
assert_equal original_tags, photos(:jonathan_questioning_dog).tags
end

def test_include_tags_on_find_tagged_with def test_include_tags_on_find_tagged_with
assert_nothing_raised do assert_nothing_raised do
Photo.find_tagged_with('Nature', :include => :tags) Photo.find_tagged_with('Nature', :include => :tags)
Expand Down

0 comments on commit 72fdf04

Please sign in to comment.