Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix TagList#concat with non-duplicates. #729

Merged
merged 1 commit into from
May 6, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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