diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2016-02-12 12:11:56 -0800 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2016-02-12 12:12:14 -0800 |
commit | 3d7892d4d586d0e128a613855e054625725594e5 (patch) | |
tree | dd0dc5bebfc0ff8b4a99ca953c6a392d2d517978 /actionview | |
parent | 914e2002d8bf86d1c7047f4f6280dcf7b0c8bd19 (diff) | |
download | rails-3d7892d4d586d0e128a613855e054625725594e5.tar.gz rails-3d7892d4d586d0e128a613855e054625725594e5.tar.bz2 rails-3d7892d4d586d0e128a613855e054625725594e5.zip |
use a real LookupContext in the digest tests
This will ensure that the digestor stays in parity with the
LookupContext object.
Diffstat (limited to 'actionview')
-rw-r--r-- | actionview/test/template/digestor_test.rb | 34 |
1 files changed, 6 insertions, 28 deletions
diff --git a/actionview/test/template/digestor_test.rb b/actionview/test/template/digestor_test.rb index ca13568e3a..dcc974c2d1 100644 --- a/actionview/test/template/digestor_test.rb +++ b/actionview/test/template/digestor_test.rb @@ -13,34 +13,12 @@ class FixtureTemplate end end -class FixtureFinder +class FixtureFinder < ActionView::LookupContext FIXTURES_DIR = "#{File.dirname(__FILE__)}/../fixtures/digestor" - attr_reader :details, :view_paths - attr_accessor :formats - attr_accessor :variants - - def initialize - @details = {} - @view_paths = ActionView::PathSet.new(['digestor']) - @formats = [] - @variants = [] - end - - def details_key - details.hash - end - - def find(name, prefixes = [], partial = false, keys = [], options = {}) - partial_name = partial ? name.gsub(%r|/([^/]+)$|, '/_\1') : name - format = @formats.first.to_s - format += "+#{@variants.first}" if @variants.any? - - FixtureTemplate.new("digestor/#{partial_name}.#{format}.erb") - end - - def disable_cache(&block) - yield + def initialize(details = {}) + prefixes = [FixtureFinder::FIXTURES_DIR] + super(ActionView::PathSet.new(['digestor']), details, prefixes) end end @@ -206,13 +184,14 @@ class TemplateDigestorTest < ActionView::TestCase def test_details_are_included_in_cache_key # Cache the template digest. + @finder = FixtureFinder.new({:formats => [:html]}) old_digest = digest("events/_event") # Change the template; the cached digest remains unchanged. change_template("events/_event") # The details are changed, so a new cache key is generated. - finder.details[:foo] = "bar" + @finder = FixtureFinder.new # The cache is busted. assert_not_equal old_digest, digest("events/_event") @@ -324,7 +303,6 @@ class TemplateDigestorTest < ActionView::TestCase def digest(template_name, options = {}) options = options.dup - finder.formats = [:html] finder.variants = options.delete(:variants) || [] ActionView::Digestor.digest({ name: template_name, finder: finder }.merge(options)) |