Sha256: f73b75c2aa9a95fc81db042276c3a3829a59cff0396cfa184215595977531709

Contents?: true

Size: 1.09 KB

Versions: 3

Compression:

Stored size: 1.09 KB

Contents

require File.dirname(__FILE__) + '/../test_helper'

class BaseTest < Test::Unit::TestCase
  fixtures :authors

  def test_should_have_cache
    assert_equal RAILS_CACHE, ActiveRecord::Base.rails_cache if defined? Rails
    assert_kind_of ActiveSupport::Cache::Store, ActiveRecord::Base.rails_cache
  end
  
  def test_should_wrap_rails_cache
    assert_equal RAILS_CACHE, Post.new.send(:rails_cache) if defined? Rails
    assert_kind_of ActiveSupport::Cache::Store, Post.new.send(:rails_cache)
  end
  
  def test_reflection_cache_key
    author = authors(:luca)
    actual = author.send(:reflection_cache_key, Author.reflections[:cached_posts])
    assert_equal "#{author.cache_key}/cached_posts", actual
  end
  
  def test_cached_association
    author = authors(:luca)
    assert_equal({}, author.send(:cached_associations))
    
    author.cached_posts # force cache loading
    assert_equal({:cached_posts => true}, author.send(:cached_associations))
    
    author.send(:cache_delete, Author.reflections[:cached_posts])
    assert_equal({:cached_posts => false}, author.send(:cached_associations))
  end
end

Version data entries

3 entries across 3 versions & 2 rubygems

Version Path
jodosha-cached-models-0.0.3 test/active_record/base_test.rb
cached-models-0.0.3 test/active_record/base_test.rb
cached-models-0.0.2 test/active_record/base_test.rb