render :cms_page uses seed data now

Oleg committed Oct 27, 2010
commit ced9c6543b07707ce8268c13d20532903da3f498
Showing 3 changed files with 19 additions and 4 deletions
comfortable_mexican_sofa.gemspec +1 -1
@@ @@ -5,7 +5,7 @@
Gem::Specification.new do |s|
s.name = %q{comfortable_mexican_sofa}
- s.version = "1.0.7"
+ s.version = "1.0.8"
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.authors = ["Oleg Khabarov", "The Working Group Inc"]
comfortable_mexican_sofa/controller_methods.rb b/lib/comfortable_mexican_sofa/controller_methods.rb +3 -1
@@ @@ -23,11 +23,13 @@ module ComfortableMexicanSofa::ControllerMethods
def render_with_cms(options = {}, locals = {}, &block)
if path = options.delete(:cms_page)
site = CmsSite.find_by_hostname(request.host.downcase)
- page = site && site.cms_pages.find_by_full_path(path)
+ page = CmsPage.load_from_file(site, path) if site && ComfortableMexicanSofa.configuration.seed_data_path
+ page ||= site && site.cms_pages.find_by_full_path(path)
if page
cms_app_layout = page.cms_layout.try(:app_layout)
options[:layout] ||= cms_app_layout.blank?? nil : cms_app_layout
options[:inline] = page.content
+ @cms_page = page
render_without_cms(options, locals, &block)
else
raise ActionView::MissingTemplate.new([path], path, "CMS page not found", nil)
test/integration/render_cms_test.rb +15 -2
@@ @@ -4,8 +4,9 @@ class RenderCmsTest < ActionDispatch::IntegrationTest
def setup
Rails.application.routes.draw do
- get '/render-implicit' => 'render_test#implicit'
- get '/render-explicit' => 'render_test#explicit'
+ get '/render-implicit' => 'render_test#implicit'
+ get '/render-explicit' => 'render_test#explicit'
+ get '/seed_data_page' => 'render_test#seed_data_page'
end
super
end
@@ @@ -21,6 +22,9 @@ class RenderCmsTest < ActionDispatch::IntegrationTest
def explicit
render :cms_page => '/render-explicit-page'
end
+ def seed_data_page
+ render :cms_page => '/'
+ end
end
def test_get_with_no_template
@@ @@ -54,4 +58,13 @@ class RenderCmsTest < ActionDispatch::IntegrationTest
end
end
+ def test_get_seed_data_page
+ ComfortableMexicanSofa.configuration.seed_data_path = File.expand_path('../cms_seeds', File.dirname(__FILE__))
+
+ get '/seed_data_page'
+ assert_response :success
+ assert assigns(:cms_page)
+ assert assigns(:cms_page).new_record?
+ end
+
end
\ No newline at end of file