Skip to content
This repository has been archived by the owner on Mar 19, 2021. It is now read-only.

Commit

Permalink
Merge pull request mbleigh#748 from keerthisiv/master
Browse files Browse the repository at this point in the history
fix issue with custom delimiter
  • Loading branch information
seuros committed Jul 1, 2016
2 parents cf5409d + 9424d09 commit 12e9968
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/acts_as_taggable_on/taggable/cache.rb
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def save_cached_tag_list
tag_types.map(&:to_s).each do |tag_type|
if self.class.send("caching_#{tag_type.singularize}_list?")
if tag_list_cache_set_on(tag_type)
list = tag_list_cache_on(tag_type).to_a.flatten.compact.join(', ')
list = tag_list_cache_on(tag_type).to_a.flatten.compact.join("#{ActsAsTaggableOn.delimiter} ")
self["cached_#{tag_type.singularize}_list"] = list
end
end
Expand Down
22 changes: 22 additions & 0 deletions spec/acts_as_taggable_on/caching_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,28 @@
end
end

describe 'with a custom delimiter' do
before(:each) do
@taggable = CachedModel.new(name: 'Bob Jones')
@another_taggable = OtherCachedModel.new(name: 'John Smith')
ActsAsTaggableOn.delimiter = ';'
end

after(:all) do
ActsAsTaggableOn.delimiter = ','
end

it 'should cache tags with custom delimiter' do
@taggable.update_attributes(tag_list: 'awesome; epic')
expect(@taggable.tag_list).to eq(['awesome', 'epic'])
expect(@taggable.cached_tag_list).to eq('awesome; epic')

@taggable = CachedModel.find_by_name('Bob Jones')
expect(@taggable.tag_list).to eq(['awesome', 'epic'])
expect(@taggable.cached_tag_list).to eq('awesome; epic')
end
end

describe 'CachingWithArray' do
pending '#TODO'
end
Expand Down

0 comments on commit 12e9968

Please sign in to comment.