Skip to content

Commit

Permalink
Update clean! method to use case insensitive uniq! when strict_case_m…
Browse files Browse the repository at this point in the history
…atch is false
  • Loading branch information
Mark Jacobs committed Jan 11, 2016
1 parent c393f86 commit 90c8699
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/acts_as_taggable_on/tag_list.rb
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def clean!
map! { |tag| tag.mb_chars.downcase.to_s } if ActsAsTaggableOn.force_lowercase
map!(&:parameterize) if ActsAsTaggableOn.force_parameterize

uniq!
ActsAsTaggableOn.strict_case_match ? uniq! : uniq!{ |tag| tag.downcase }
end


Expand Down
14 changes: 14 additions & 0 deletions spec/acts_as_taggable_on/tag_list_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,20 @@

ActsAsTaggableOn.force_lowercase = false
end

it 'should ignore case when removing duplicates if strict_case_match is false' do
tag_list = ActsAsTaggableOn::TagList.new('Junglist', 'JUNGLIST', 'Junglist', 'Massive', 'MASSIVE', 'MASSIVE')

expect(tag_list.to_s).to eq('Junglist, Massive')
end

it 'should not ignore case when removing duplicates if strict_case_match is true' do
ActsAsTaggableOn.strict_case_match = true
tag_list = ActsAsTaggableOn::TagList.new('Junglist', 'JUNGLIST', 'Junglist', 'Massive', 'MASSIVE', 'MASSIVE')

expect(tag_list.to_s).to eq('Junglist, JUNGLIST, Massive, MASSIVE')
ActsAsTaggableOn.strict_case_match = false
end
end

describe 'custom parser' do
Expand Down

0 comments on commit 90c8699

Please sign in to comment.