Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

No commit message

  • Loading branch information...
commit 23ddde91f961b621d0eeaf33467ad8f4eb00812a 1 parent 9eed5a9
@jviney authored
View
6 CHANGELOG
@@ -1,3 +1,9 @@
+[1 July 2007]
+
+* Fix incorrect tagging when the case of the tag list is changed.
+
+* Fix deprecated Tag.delimiter accessor.
+
[23 June 2007]
* Add validation to Tag model.
View
4 lib/acts_as_taggable.rb
@@ -130,11 +130,11 @@ def save_tags
old_tags = tags.reject { |tag| @tag_list.names.include?(tag.name) }
self.class.transaction do
+ tags.delete(*old_tags) if old_tags.any?
+
new_tag_names.each do |new_tag_name|
tags << Tag.find_or_create_by_name(new_tag_name)
end
-
- tags.delete(*old_tags) if old_tags.any?
end
true
end
View
2  lib/tag.rb
@@ -5,7 +5,7 @@ class Tag < ActiveRecord::Base
validates_uniqueness_of :name
class << self
- delegate :delimiter, :delimeter=, :to => TagList
+ delegate :delimiter, :delimiter=, :to => TagList
end
def ==(object)
View
9 test/acts_as_taggable_test.rb
@@ -114,6 +114,15 @@ def test_remove_tag
assert_equivalent ["Nature"], posts(:jonathan_sky).tag_list.names
end
+ def test_change_case_of_tags
+ original_tag_names = photos(:jonathan_questioning_dog).tag_list.names
+ photos(:jonathan_questioning_dog).update_attributes!(:tag_list => photos(:jonathan_questioning_dog).tag_list.to_s.upcase)
+
+ # The new tag list is not uppercase becuase the AR finders are not case-sensitive
+ # and find the old tags when re-tagging with the uppercase tags.
+ assert_equivalent original_tag_names, photos(:jonathan_questioning_dog).reload.tag_list.names
+ end
+
def test_remove_and_add_tag
assert_equivalent ["Very good", "Nature"], posts(:jonathan_sky).tag_list.names
posts(:jonathan_sky).update_attributes!(:tag_list => "Nature, Beautiful")
View
8 test/tag_test.rb
@@ -31,4 +31,12 @@ def test_equality
assert_equal Tag.new(:name => 'A'), Tag.new(:name => 'A')
assert_not_equal Tag.new(:name => 'A'), Tag.new(:name => 'B')
end
+
+ def test_deprecated_delimiter
+ original_delimiter = Tag.delimiter
+ Tag.delimiter = ":"
+ assert_equal ":", TagList.delimiter
+ ensure
+ TagList.delimiter = original_delimiter
+ end
end
Please sign in to comment.
Something went wrong with that request. Please try again.