From d0b811f0151524d63850c3295be25eafcc95cc46 Mon Sep 17 00:00:00 2001 From: Thomas von Deyen Date: Sun, 11 Nov 2018 23:25:41 +0100 Subject: [PATCH] Remove cells from template tracker We do not have cells anymore to track templates for. --- lib/alchemy/cache_digests/template_tracker.rb | 27 +++---------------- spec/libraries/template_tracker_spec.rb | 17 ------------ 2 files changed, 4 insertions(+), 40 deletions(-) diff --git a/lib/alchemy/cache_digests/template_tracker.rb b/lib/alchemy/cache_digests/template_tracker.rb index a0533b4f1f..d6a99cb46b 100644 --- a/lib/alchemy/cache_digests/template_tracker.rb +++ b/lib/alchemy/cache_digests/template_tracker.rb @@ -14,13 +14,10 @@ def initialize(name, template) def dependencies case @name.to_s when /^alchemy\/pages\/show/ - PageLayout.all.collect { |p| "alchemy/page_layouts/_#{p['name']}" } + PageLayout.all.map { |p| "alchemy/page_layouts/_#{p['name']}" } when /^alchemy\/page_layouts\/_(.+)/ - page_layout = page_layout($1) - element_templates(page_layout) + - page_layout.fetch('cells', []).map { |name| "alchemy/cells/_#{name}" } - when /^alchemy\/cells\/_(.+)/ - element_templates cell_definition($1) + page_layout = PageLayout.get($1) + page_layout.fetch('elements', []).map { |name| "alchemy/elements/_#{name}_view" } when /alchemy\/elements\/_(.+)_view/ essences = essence_types($1) essences.map { |name| "alchemy/essences/_#{name.underscore}_view" }.uniq @@ -31,24 +28,8 @@ def dependencies private - def element_templates(collection) - collection.fetch('elements', []).map { |name| "alchemy/elements/_#{name}_view" } - end - - def page_layout(name) - PageLayout.get(name) - end - - def cell_definition(name) - Cell.definition_for(name) - end - - def element_definition(name) - Element.definitions.detect { |e| e['name'] == name } - end - def essence_types(name) - element = element_definition(name) + element = Element.definitions.detect { |e| e['name'] == name } return [] unless element element.fetch('contents', []).collect { |c| c['type'] } end diff --git a/spec/libraries/template_tracker_spec.rb b/spec/libraries/template_tracker_spec.rb index c07d361fef..baa08749d4 100644 --- a/spec/libraries/template_tracker_spec.rb +++ b/spec/libraries/template_tracker_spec.rb @@ -25,23 +25,6 @@ module CacheDigests it "returns all element layout view partial names for that layout" do is_expected.to include('alchemy/elements/_text_view') end - - context 'and page layout having cells' do - let(:page_layout) { {'name' => 'intro', 'elements' => ['text'], 'cells' => ['header']} } - - it "returns all cell view partial names for that layout" do - is_expected.to include('alchemy/cells/_header') - end - end - end - - context 'with a cell given as template name' do - let(:name) { 'alchemy/cells/_header' } - before { allow(Cell).to receive(:definition_for).and_return({'name' => 'header', 'elements' => ['text']}) } - - it "returns all element layout view partial names for that cell" do - is_expected.to include('alchemy/elements/_text_view') - end end context 'with an element given as name' do