Skip to content

Commit

Permalink
Bugfix TagList#concat with non-duplicates.
Browse files Browse the repository at this point in the history
`uniq!` behaves differently depending on whether duplicates are found or
not: if they are, the de-duped list is returned, otherwise `nil` is
returned.
  • Loading branch information
lukeasrodgers authored and seuros committed Jul 10, 2016
1 parent 49c208d commit 2c6214f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/acts_as_taggable_on/tag_list.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

##
Expand Down
12 changes: 12 additions & 0 deletions spec/acts_as_taggable_on/tag_list_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 2c6214f

Please sign in to comment.