Skip to content

Commit

Permalink
Remove cells from template tracker
Browse files Browse the repository at this point in the history
We do not have cells anymore to track templates for.
  • Loading branch information
tvdeyen committed Nov 11, 2018
1 parent f09c725 commit d0b811f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 40 deletions.
27 changes: 4 additions & 23 deletions lib/alchemy/cache_digests/template_tracker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
17 changes: 0 additions & 17 deletions spec/libraries/template_tracker_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit d0b811f

Please sign in to comment.