Skip to content

Commit

Permalink
Merge pull request #456 from znz/fix-as_8bit_ascii-breaks-arguments-e…
Browse files Browse the repository at this point in the history
…ncoding

[Fix] as_8bit_ascii changes argument's encoding
  • Loading branch information
bf4 committed Jan 9, 2014
2 parents 9b3f87d + 5a3e477 commit feedade
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
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 feedade

Please sign in to comment.