Sha256: d771f8d3573d1cc9e962f64d44af884aa8e5320d72e6205c423635a649cdeffc

Contents?: true

Size: 1.01 KB

Versions: 6

Compression:

Stored size: 1.01 KB

Contents

require File.join(File.dirname(__FILE__), 'test_helper.rb')

require 'cache_advance/active_record_sweeper'

class Article; end
class Publication; end

class ActiveRecordSweeperTest < Test::Unit::TestCase
  
  def setup
    @sweeper = CacheAdvance::ActiveRecordSweeper.instance
  end
  
  def test_should_call_observe_with_a_given_set_of_classes
    CacheAdvance::ActiveRecordSweeper.expects(:observe).with([:publication, :article])
    CacheAdvance::ActiveRecordSweeper.initialize_observed([:publication, :article])
  end
  
  def test_should_re_add_observers
    CacheAdvance::ActiveRecordSweeper.initialize_observed([:publication, :article])
    Article.expects(:add_observer).with(@sweeper)
    Publication.expects(:add_observer).with(@sweeper)
    @sweeper.reload_sweeper
  end
  
  def test_should_expire_caches_on_changes
    CacheAdvance.cache_set.expects(:expire_for_class).with(:publication).times(3)
    %w(after_create after_update after_destroy).each do |method|
      @sweeper.send(method, Publication.new)
    end
  end
end

Version data entries

6 entries across 6 versions & 2 rubygems

Version Path
aub-cache_advance-1.1.2 test/active_record_sweeper_test.rb
aub-cache_advance-1.1.3 test/active_record_sweeper_test.rb
cache_advance-2.0.1 test/active_record_sweeper_test.rb
cache_advance-2.0.0 test/active_record_sweeper_test.rb
cache_advance-1.1.5 test/active_record_sweeper_test.rb
cache_advance-1.1.4 test/active_record_sweeper_test.rb