don't use context.registers[:site] in a section because it's not decorated
Didier Lafforgue
committed May 24, 2018
commit 29455e5e59dce976a511d6e9a80bd10a1501cdd7
Showing 2
changed files with
10 additions
and 9 deletions
locomotive/steam/liquid/tags/section.rb b/lib/locomotive/steam/liquid/tags/section.rb
+1
-1
| @@ | @@ -20,7 +20,7 @@ module Locomotive |
| section = find_section(context) | |
| # 3. since it's considered as static, get the content from the current site. | |
| - | section_content = context.registers[:site]&.sections_content&.fetch(@section_type, nil) |
| + | section_content = context['site']&.sections_content&.fetch(@section_type, nil) |
| # 4. enhance the context by setting the "section" variable | |
| context['section'] = Locomotive::Steam::Liquid::Drops::Section.new( | |
spec/unit/middlewares/section_spec.rb
+9
-8
| @@ | @@ -7,16 +7,17 @@ require_relative '../../../lib/locomotive/steam/middlewares/section' |
| describe Locomotive::Steam::Middlewares::Section do | |
| - | let(:app) { ->(env) { [200, env, 'app'] }} |
| - | let(:url) { 'http://example.com/_sections/header' } |
| - | let(:env) { env_for(url, 'steam.site' => site) } |
| + | let(:app) { ->(env) { [200, env, 'app'] }} |
| + | let(:url) { 'http://example.com/_sections/header' } |
| + | let(:env) { env_for(url, 'steam.site' => site) } |
| - | let(:site) { instance_double('Site', default_locale: 'en', locales: ['en'], sections_content: {}, to_liquid: '') } |
| - | let(:section) { instance_double('Section', type: 'fancy_section', definition: {}, liquid_source: 'Here some HTML') } |
| - | let(:section_finder) { instance_double('SectionFinderService') } |
| - | let(:repositories) { instance_double('Repositories')} |
| + | let(:drop) { liquid_instance_double('SiteDrop', sections_content: {}) } |
| + | let(:site) { instance_double('Site', default_locale: 'en', locales: ['en'], to_liquid: drop) } |
| + | let(:section) { instance_double('Section', type: 'fancy_section', definition: {}, liquid_source: 'Here some HTML') } |
| + | let(:section_finder) { instance_double('SectionFinderService') } |
| + | let(:repositories) { instance_double('Repositories')} |
| - | let(:services) { instance_double( |
| + | let(:services) { instance_double( |
| 'Services', | |
| section_finder: section_finder, | |
| repositories: repositories, | |