Skip to content

Commit

Permalink
fix as_8bit_ascii changes argument's encoding
Browse files Browse the repository at this point in the history
  • Loading branch information
znz committed Jan 8, 2014
1 parent 9b3f87d commit 383c377
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/acts_as_taggable_on/tag.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 7 additions & 0 deletions spec/acts_as_taggable_on/tag_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 383c377

Please sign in to comment.