Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Render site layout with block #2038

Merged
merged 2 commits into from
Mar 5, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions app/helpers/alchemy/pages_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ def render_page_layout
#
# renders +app/views/alchemy/site_layouts/_default_site.html.erb+ for the site named "Default Site".
#
def render_site_layout
render current_alchemy_site
def render_site_layout(&block)
render current_alchemy_site, &block
rescue ActionView::MissingTemplate
warning("Site layout for #{current_alchemy_site.try(:name)} not found. Please run `rails g alchemy:site_layouts`")
""
Expand Down
11 changes: 11 additions & 0 deletions spec/helpers/alchemy/pages_helper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,17 @@ module Alchemy
helper.render_site_layout
end

context "when block is given" do
it "passes it on to the render method" do
expect(helper).to receive(:current_alchemy_site).and_return(default_site)
expect(helper)
.to receive(:render)
.with(default_site) { |&block| expect(block).to be }

helper.render_site_layout { true }
end
end

context "with missing partial" do
it "returns empty string and logges warning" do
expect(helper).to receive(:current_alchemy_site).twice.and_return(default_site)
Expand Down