all three public instance varaibles are assigned, even with render method
Oleg
committed Sep 21, 2011
commit 6388c94d0f0b46ca359b7236acbc4321b080dfc6
Showing 4
changed files with
18 additions
and 9 deletions
app/controllers/cms_content_controller.rb
+2
-2
| @@ | @@ -11,8 +11,8 @@ class CmsContentController < ApplicationController |
| :only => [:render_css, :render_js] | |
| def render_html(status = 200) | |
| - | if layout = @cms_page.layout |
| - | app_layout = (layout.app_layout.blank? || request.xhr?) ? false : layout.app_layout |
| + | if @cms_layout = @cms_page.layout |
| + | app_layout = (@cms_layout.app_layout.blank? || request.xhr?) ? false : @cms_layout.app_layout |
| render :inline => @cms_page.content, :layout => app_layout, :status => status | |
| else | |
| render :text => I18n.t('cms.content.layout_not_found'), :status => 404 | |
comfortable_mexican_sofa/controller_methods.rb b/lib/comfortable_mexican_sofa/controller_methods.rb
+6
-6
| @@ | @@ -20,13 +20,13 @@ module ComfortableMexicanSofa::ControllerMethods |
| # by the cms page and/or layout) | |
| def render(options = {}, locals = {}, &block) | |
| if options.is_a?(Hash) && path = options.delete(:cms_page) | |
| - | site = Cms::Site.find_site(request.host.downcase, request.fullpath) |
| - | page = site && site.pages.find_by_full_path(path) |
| - | if page |
| - | cms_app_layout = page.layout.try(:app_layout) |
| + | @cms_site = Cms::Site.find_site(request.host.downcase, request.fullpath) |
| + | @cms_page = @cms_site && @cms_site.pages.find_by_full_path(path) |
| + | if @cms_page |
| + | @cms_layout = @cms_page.layout |
| + | cms_app_layout = @cms_layout.try(:app_layout) |
| options[:layout] ||= cms_app_layout.blank?? nil : cms_app_layout | |
| - | options[:inline] = page.content |
| - | @cms_page = page |
| + | options[:inline] = @cms_page.content |
| super(options, locals, &block) | |
| else | |
| raise ComfortableMexicanSofa::MissingPage.new(path) | |
test/functional/cms_content_controller_test.rb
+4
-1
| @@ | @@ -4,7 +4,10 @@ class CmsContentControllerTest < ActionController::TestCase |
| def test_render_page | |
| get :render_html, :cms_path => '' | |
| - | assert_equal assigns(:cms_page), cms_pages(:default) |
| + | assert_equal cms_sites(:default), assigns(:cms_site) |
| + | assert_equal cms_layouts(:default), assigns(:cms_layout) |
| + | assert_equal cms_pages(:default), assigns(:cms_page) |
| + | |
| assert_response :success | |
| assert_equal rendered_content_formatter( | |
| ' | |
test/integration/render_cms_test.rb
+6
-0
| @@ | @@ -45,6 +45,9 @@ class RenderCmsTest < ActionDispatch::IntegrationTest |
| page.save! | |
| get '/render-implicit' | |
| assert_response :success | |
| + | assert assigns(:cms_site) |
| + | assert assigns(:cms_layout) |
| + | assert assigns(:cms_page) |
| end | |
| def test_get_with_explicit_cms_template | |
| @@ | @@ -53,6 +56,9 @@ class RenderCmsTest < ActionDispatch::IntegrationTest |
| page.save! | |
| get '/render-explicit' | |
| assert_response :success | |
| + | assert assigns(:cms_site) |
| + | assert assigns(:cms_layout) |
| + | assert assigns(:cms_page) |
| end | |
| def test_get_with_explicit_cms_template_failure | |