diff --git a/lib/acts_as_taggable_on/tag_list.rb b/lib/acts_as_taggable_on/tag_list.rb index bbd9ca427..a79031429 100644 --- a/lib/acts_as_taggable_on/tag_list.rb +++ b/lib/acts_as_taggable_on/tag_list.rb @@ -41,6 +41,7 @@ def +(other_tag_list) # Appends the elements of +other_tag_list+ to +self+. def concat(other_tag_list) super(other_tag_list).send(:clean!) + self end ## diff --git a/spec/acts_as_taggable_on/tag_list_spec.rb b/spec/acts_as_taggable_on/tag_list_spec.rb index 7959b84cc..d8dcc0612 100644 --- a/spec/acts_as_taggable_on/tag_list_spec.rb +++ b/spec/acts_as_taggable_on/tag_list_spec.rb @@ -83,6 +83,18 @@ new_tag_list = tag_list.concat(another_tag_list) expect(new_tag_list.class).to eq(ActsAsTaggableOn::TagList) end + + context 'without duplicates' do + let(:arr) { ['crazy', 'alien'] } + let(:another_tag_list) { ActsAsTaggableOn::TagList.new(*arr) } + it 'adds other list' do + expect(tag_list.concat(another_tag_list)).to eq(%w[awesome radical crazy alien]) + end + + it 'adds other array' do + expect(tag_list.concat(arr)).to eq(%w[awesome radical crazy alien]) + end + end end describe '#to_s' do