Sha256: 481611b0fd6b670d07119ceac1e7b46c080afd9d02c8ba8c47e3f3384931f6ce
Contents?: true
Size: 1.76 KB
Versions: 1
Compression:
Stored size: 1.76 KB
Contents
require 'test_helper' class CachingTest < ActiveSupport::TestCase fixtures :all def test_can_cache cache = ActiveSupport::Cache::MemoryStore.new projects = Project.all assembler = ProjectPreloadIncludedAssembler.new(projects, cache: cache) # warming cache expected_data = nil assert_queries 3 do expected_data = assembler.data end projects = Project.all assembler = ProjectPreloadIncludedAssembler.new(projects, cache: cache) data = nil assert_queries 1 do data = assembler.data end assert_equal expected_data, data end def test_can_force_cache_clear cache = ActiveSupport::Cache::MemoryStore.new projects = Project.all assembler = ProjectPreloadIncludedAssembler.new(projects, cache: cache) # warming cache expected_data = nil assert_queries 3 do expected_data = assembler.data end projects = Project.all assembler = ProjectPreloadIncludedAssembler.new(projects, cache: cache, force_reload: true) data = nil assert_queries 3 do data = assembler.data end assert_equal expected_data, data end def test_cache_key_contains_associations cache = ActiveSupport::Cache::MemoryStore.new projects = Project.all assembler = ProjectPreloadIncludedAssembler.new(projects, cache: cache) cache_key_with_associations = assembler.send(:serializer_cache_key) saved_associations = assembler.serializer._associations assembler.serializer._associations = {} assembler.remove_instance_variable(:@serializer_cache_key) cache_key_without_associations = assembler.send(:serializer_cache_key) assembler.serializer._associations = saved_associations assert_not_equal cache_key_with_associations, cache_key_without_associations end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
autobots-0.2.3 | test/caching_test.rb |