fixing a crappy bug. next version will have simplified cms_blocks. less code crud
Oleg
committed Nov 09, 2010
commit 16e1c77d82c4b1b2ce9902845b0190a749cbecbd
Showing 7
changed files with
33 additions
and 5 deletions
app/models/cms_page.rb
+1
-0
| @@ | @@ -95,6 +95,7 @@ class CmsPage < ActiveRecord::Base |
| # Processing content will return rendered content and will populate | |
| # self.cms_tags with instances of CmsTag | |
| def content | |
| + | self.cms_tags = [] # resetting |
| cms_layout ? CmsTag.process_content(self, cms_layout.merged_content) : '' | |
| end | |
app/views/cms_admin/pages/_form_blocks.html.erb
+1
-1
| @@ | @@ -1,7 +1,7 @@ |
| <div id='form_blocks'> | |
| <%= fields_for :cms_blocks, :builder => ComfortableMexicanSofa::FormBuilder do |cms_blocks| %> | |
| <% @cms_page.cms_tags(true).each do |tag| %> | |
| - | <%= cms_blocks.send(tag.class.to_s.underscore.downcase.idify, tag)%> |
| + | <%= cms_blocks.send(tag.class.name.underscore.downcase.idify, tag)%> |
| <% end %> | |
| <% end %> | |
| </div> | |
| \ No newline at end of file | |
comfortable_mexican_sofa/form_builder.rb b/lib/comfortable_mexican_sofa/form_builder.rb
+1
-1
| @@ | @@ -42,7 +42,7 @@ class ComfortableMexicanSofa::FormBuilder < ActionView::Helpers::FormBuilder |
| # -- Tag Field Fields ----------------------------------------------------- | |
| def default_tag_field(tag, options = {}) | |
| label = options[:label] || tag.label.to_s.titleize | |
| - | css_class = options[:css_class] || tag.class.to_s.underscore.downcase.idify |
| + | css_class = options[:css_class] || tag.class.name.underscore.downcase.idify |
| options[:content_field_method] ||= :text_field_tag | |
| field = | |
tasks/comfortable_mexican_sofa.rake b/lib/tasks/comfortable_mexican_sofa.rake
+2
-2
| @@ | @@ -7,7 +7,7 @@ namespace :comfortable_mexican_sofa do |
| abort('ComfortableMexicanSofa.config.seed_data_path is not set. Where are those yaml files?') | |
| end | |
| if !(@site = CmsSite.find_by_hostname(args[:hostname])) | |
| - | abort("Can't find site with HOSTNAME '#{args[:site]}'") |
| + | abort("Can't find site with HOSTNAME '#{args[:hostname]}'") |
| end | |
| puts "Starting import into #{@site.label} (#{@site.hostname})..." | |
| end | |
| @@ | @@ -29,7 +29,7 @@ namespace :comfortable_mexican_sofa do |
| layout.parent = (parent rescue nil) | |
| should_write = true | |
| existing_layout = nil | |
| - | |
| + | |
| if existing_layout = @site.cms_layouts.find_by_slug(layout.slug) | |
| print "Found layout in database with slug: #{layout.slug}. Overwrite? (yN): " | |
| should_write = ($stdin.gets.to_s.strip.downcase == 'y') | |
test/fixtures/cms_pages.yml
+1
-1
| @@ | @@ -18,4 +18,4 @@ child: |
| slug: 'child-page' | |
| full_path: '/child-page' | |
| children_count: 0 | |
| - | position: 0 |
| \ No newline at end of file | |
| + | position: 0 |
test/functional/cms_admin/pages_controller_test.rb
+1
-0
| @@ | @@ -258,4 +258,5 @@ class CmsAdmin::PagesControllerTest < ActionController::TestCase |
| assert_equal 3, assigns(:cms_page).cms_tags.size | |
| assert_template :form_blocks | |
| end | |
| + | |
| end | |
| \ No newline at end of file | |
test/unit/cms_tag_test.rb
+26
-0
| @@ | @@ -202,4 +202,30 @@ class CmsTagTest < ActiveSupport::TestCase |
| ), page.content | |
| assert_equal 6, page.cms_tags.size | |
| end | |
| + | |
| + | def test_tag_initialization_for_existing_blocks_with_different_type |
| + | layout = cms_layouts(:default) |
| + | page = cms_pages(:default) |
| + | |
| + | assert page.content |
| + | assert_equal 4, page.cms_tags.size |
| + | assert tag = page.cms_tags.first |
| + | assert !tag.new_record? |
| + | assert_equal 'CmsTag::FieldText', tag.class.name |
| + | assert_equal 'CmsTag::FieldText', tag.type |
| + | assert_equal 'default_field_text', tag.label |
| + | assert_equal 'default_field_text_content', tag.content |
| + | |
| + | layout.update_attribute(:content, '{{cms:page:default_field_text:string}}') |
| + | page.reload |
| + | assert page.content |
| + | assert_equal 1, page.cms_tags.size |
| + | assert tag = page.cms_tags.first |
| + | assert !tag.new_record? |
| + | assert_equal 'CmsTag::FieldText', tag.class.name |
| + | assert_equal 'CmsTag::PageString', tag.type |
| + | assert_equal 'default_field_text', tag.label |
| + | assert_equal 'default_field_text_content', tag.content |
| + | end |
| + | |
| end | |