diff options
author | Eugen Rochko <eugen@zeonfederated.com> | 2019-07-29 20:40:21 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-07-29 20:40:21 +0200 |
commit | e136112ab76a37cbde5c1bcfeb562c8e0a5b5116 (patch) | |
tree | db91ad2e6b5579c6682b4cab0c3488bad506595d /spec/models | |
parent | aefeb65656605f3e32021acbc78c8e21307921fd (diff) |
Fix tag normalization and migration not removing duplicate tags (#11441)
Fix #11428
Diffstat (limited to 'spec/models')
-rw-r--r-- | spec/models/tag_spec.rb | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/spec/models/tag_spec.rb b/spec/models/tag_spec.rb index 9a30ceaa5..5f07fd618 100644 --- a/spec/models/tag_spec.rb +++ b/spec/models/tag_spec.rb @@ -82,6 +82,40 @@ RSpec.describe Tag, type: :model do end end + describe '.find_normalized' do + it 'returns tag for a multibyte case-insensitive name' do + upcase_string = 'abcABCabcABCやゆよ' + downcase_string = 'abcabcabcabcやゆよ'; + + tag = Fabricate(:tag, name: downcase_string) + expect(Tag.find_normalized(upcase_string)).to eq tag + end + end + + describe '.matching_name' do + it 'returns tags for multibyte case-insensitive names' do + upcase_string = 'abcABCabcABCやゆよ' + downcase_string = 'abcabcabcabcやゆよ'; + + tag = Fabricate(:tag, name: downcase_string) + expect(Tag.matching_name(upcase_string)).to eq [tag] + end + end + + describe '.find_or_create_by_names' do + it 'runs a passed block once per tag regardless of duplicates' do + upcase_string = 'abcABCabcABCやゆよ' + downcase_string = 'abcabcabcabcやゆよ'; + count = 0 + + Tag.find_or_create_by_names([upcase_string, downcase_string]) do |tag| + count += 1 + end + + expect(count).to eq 1 + end + end + describe '.search_for' do it 'finds tag records with matching names' do tag = Fabricate(:tag, name: "match") |