From 383c377aff94b409d6addf36116dca03763cafc1 Mon Sep 17 00:00:00 2001 From: Kazuhiro NISHIYAMA Date: Wed, 8 Jan 2014 14:24:26 +0900 Subject: [PATCH 1/2] fix as_8bit_ascii changes argument's encoding --- lib/acts_as_taggable_on/tag.rb | 2 +- spec/acts_as_taggable_on/tag_spec.rb | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/acts_as_taggable_on/tag.rb b/lib/acts_as_taggable_on/tag.rb index b3727dbf7..d30a0a8fe 100644 --- a/lib/acts_as_taggable_on/tag.rb +++ b/lib/acts_as_taggable_on/tag.rb @@ -113,7 +113,7 @@ def binary def as_8bit_ascii(string) if defined?(Encoding) - string.to_s.force_encoding('BINARY') + string.to_s.dup.force_encoding('BINARY') else string.to_s.mb_chars end diff --git a/spec/acts_as_taggable_on/tag_spec.rb b/spec/acts_as_taggable_on/tag_spec.rb index 01a7df289..cac682507 100644 --- a/spec/acts_as_taggable_on/tag_spec.rb +++ b/spec/acts_as_taggable_on/tag_spec.rb @@ -194,6 +194,13 @@ ActsAsTaggableOn::Tag.named('cool').should include(@tag) ActsAsTaggableOn::Tag.named('cool').should_not include(uppercase_tag) end + + it "should not change enconding" do + name = "\u3042" + original_encoding = name.encoding + ActsAsTaggableOn::Tag.find_or_create_with_like_by_name(name) + name.encoding.should == original_encoding + end end describe "name uniqeness validation" do From 5a3e4772971643a8a6fa9d02e31e26c881b37d0e Mon Sep 17 00:00:00 2001 From: Kazuhiro NISHIYAMA Date: Thu, 9 Jan 2014 09:23:26 +0900 Subject: [PATCH 2/2] update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 12c7c4cd2..cb987d50f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ As such, a _Feature_ would map to either major or minor. A _bug fix_ to a patch. * Breaking Changes * Features * Fixes + * [Fix breaking encoding of tag](https://github.com/mbleigh/acts-as-taggable-on/pull/456) * Misc ### [3.0.0 / 2014-01-01](https://github.com/mbleigh/acts-as-taggable-on/compare/v2.4.1...v3.0.0)