From 56975352b893f0dd5ee5ed8e081c487b94521092 Mon Sep 17 00:00:00 2001 From: Ben Tillman Date: Wed, 7 Jan 2015 10:19:19 +1300 Subject: [PATCH] clears column cache on reset_column_information resolves #621 --- lib/acts_as_taggable_on/taggable/cache.rb | 4 ++++ spec/acts_as_taggable_on/caching_spec.rb | 6 ++++++ 2 files changed, 10 insertions(+) diff --git a/lib/acts_as_taggable_on/taggable/cache.rb b/lib/acts_as_taggable_on/taggable/cache.rb index faaa5c8a3..72c4d715d 100644 --- a/lib/acts_as_taggable_on/taggable/cache.rb +++ b/lib/acts_as_taggable_on/taggable/cache.rb @@ -40,6 +40,10 @@ def columns end end + def reset_column_information + super + @acts_as_taggable_on_cache_columns = nil + end end end diff --git a/spec/acts_as_taggable_on/caching_spec.rb b/spec/acts_as_taggable_on/caching_spec.rb index 57c7953e0..d80675929 100644 --- a/spec/acts_as_taggable_on/caching_spec.rb +++ b/spec/acts_as_taggable_on/caching_spec.rb @@ -69,6 +69,12 @@ @taggable.save! expect(@taggable.tag_list.sort).to eq(%w(awesome epic).sort) end + + it 'should clear the cache on reset_column_information' do + CachedModel.column_names + CachedModel.reset_column_information + expect(CachedModel.instance_variable_get(:@acts_as_taggable_on_cache_columns)).to eql(nil) + end end describe 'CachingWithArray' do