layouts have identifiers, not slugs
Oleg
committed Dec 03, 2011
commit 2dc1f0daccd1ae8a6aba87415280f80caf9a5f01
Showing 21
changed files with
87 additions
and 84 deletions
app/controllers/cms_content_controller.rb
+1
-1
| @@ | @@ -65,7 +65,7 @@ protected |
| end | |
| def load_cms_layout | |
| - | @cms_layout = @cms_site.layouts.find_by_slug!(params[:layout_slug]) |
| + | @cms_layout = @cms_site.layouts.find_by_identifier!(params[:identifier]) |
| rescue ActiveRecord::RecordNotFound | |
| render :nothing => true, :status => 404 | |
| end | |
app/models/cms/layout.rb
+2
-2
| @@ | @@ -23,7 +23,7 @@ class Cms::Layout < ActiveRecord::Base |
| :presence => true | |
| validates :label, | |
| :presence => true | |
| - | validates :slug, |
| + | validates :identifier, |
| :presence => true, | |
| :uniqueness => { :scope => :site_id }, | |
| :format => { :with => /^\w[a-z0-9_-]*$/i } | |
| @@ | @@ -73,7 +73,7 @@ class Cms::Layout < ActiveRecord::Base |
| protected | |
| def assign_label | |
| - | self.label = self.label.blank?? self.slug.try(:titleize) : self.label |
| + | self.label = self.label.blank?? self.identifier.try(:titleize) : self.label |
| end | |
| def assign_position | |
app/views/cms_admin/layouts/_form.html.erb
+1
-1
| @@ | @@ -3,7 +3,7 @@ |
| <% end %> | |
| <%= form.text_field :label, :id => (@layout.new_record?? 'slugify' : nil)%> | |
| - | <%= form.text_field :slug, :id => 'slug' %> |
| + | <%= form.text_field :identifier, :id => 'slug' %> |
| <% if (options = Cms::Layout.options_for_select(@site, @layout)).present? %> | |
| <%= form.select :parent_id, [["---- #{t('.select_parent_layout')} ----", nil]] + options %> | |
| <% end %> | |
app/views/cms_admin/layouts/_index_branch.html.erb
+1
-1
| @@ | @@ -15,7 +15,7 @@ |
| <div class='label'> | |
| <%= link_to layout.label, edit_cms_admin_site_layout_path(@site, layout) %> | |
| <div class='sublabel'> | |
| - | <%= link_to layout.slug, edit_cms_admin_site_layout_path(@site, layout) %> |
| + | <%= link_to layout.identifier, edit_cms_admin_site_layout_path(@site, layout) %> |
| </div> | |
| </div> | |
| </div> | |
app/views/cms_admin/revisions/show.html.erb
+1
-1
| @@ | @@ -1,5 +1,5 @@ |
| <h1> <%= t('.title') %> <%= @record.class.to_s.demodulize %></h1> | |
| - | <h2> <%= @record.is_a?(Cms::Page) ? "#{t('.full_path')}: #{@record.full_path}" : "#{t('.slug')}: #{@record.slug}" %> </h2> |
| + | <h2> <%= @record.is_a?(Cms::Page) ? "#{t('.full_path')}: #{@record.full_path}" : "#{t('.slug')}: #{@record.identifier}" %> </h2> |
| <% content_for :right_column do %> | |
| <h2><%= pluralize(@record.revisions.count, t('.revision')) %></h2> | |
config/routes.rb
+2
-2
| @@ | @@ -31,8 +31,8 @@ Rails.application.routes.draw do |
| end unless ComfortableMexicanSofa.config.admin_route_prefix.blank? | |
| scope :controller => :cms_content do | |
| - | get 'cms-css/:site_id/:layout_slug' => :render_css, :as => 'cms_css' |
| - | get 'cms-js/:site_id/:layout_slug' => :render_js, :as => 'cms_js' |
| + | get 'cms-css/:site_id/:identifier' => :render_css, :as => 'cms_css' |
| + | get 'cms-js/:site_id/:identifier' => :render_js, :as => 'cms_js' |
| get '/' => :render_html, :as => 'cms_html', :path => "(*cms_path)" | |
| end | |
migrate/01_create_cms.rb b/db/migrate/01_create_cms.rb
+6
-6
| @@ | @@ -14,20 +14,20 @@ class CreateCms < ActiveRecord::Migration |
| # -- Layouts ------------------------------------------------------------ | |
| create_table :cms_layouts do |t| | |
| - | t.integer :site_id |
| + | t.integer :site_id, :null => false |
| t.integer :parent_id | |
| t.string :app_layout | |
| - | t.string :label |
| - | t.string :slug |
| + | t.string :label, :null => false |
| + | t.string :identifier, :null => false |
| t.text :content | |
| t.text :css | |
| t.text :js | |
| - | t.integer :position, :null => false, :default => 0 |
| - | t.boolean :is_shared, :null => false, :default => false |
| + | t.integer :position, :null => false, :default => 0 |
| + | t.boolean :is_shared, :null => false, :default => false |
| t.timestamps | |
| end | |
| add_index :cms_layouts, [:parent_id, :position] | |
| - | add_index :cms_layouts, [:site_id, :slug], :unique => true |
| + | add_index :cms_layouts, [:site_id, :identifier], :unique => true |
| # -- Pages -------------------------------------------------------------- | |
| create_table :cms_pages do |t| | |
comfortable_mexican_sofa/error.rb b/lib/comfortable_mexican_sofa/error.rb
+2
-2
| @@ | @@ -10,8 +10,8 @@ module ComfortableMexicanSofa |
| end | |
| class MissingLayout < ComfortableMexicanSofa::Error | |
| - | def initialize(slug) |
| - | super "Cannot find CMS Layout with slug: #{slug}" |
| + | def initialize(identifier) |
| + | super "Cannot find CMS Layout with identifier: #{identifier}" |
| end | |
| end | |
comfortable_mexican_sofa/extensions/is_mirrored.rb b/lib/comfortable_mexican_sofa/extensions/is_mirrored.rb
+5
-5
| @@ | @@ -22,7 +22,7 @@ module ComfortableMexicanSofa::IsMirrored |
| return [] unless self.site.is_mirrored? | |
| (Cms::Site.mirrored - [self.site]).collect do |site| | |
| case self | |
| - | when Cms::Layout then site.layouts.find_by_slug(self.slug) |
| + | when Cms::Layout then site.layouts.find_by_identifier(self.identifier) |
| when Cms::Page then site.pages.find_by_full_path(self.full_path) | |
| when Cms::Snippet then site.snippets.find_by_slug(self.slug) | |
| end | |
| @@ | @@ -38,10 +38,10 @@ module ComfortableMexicanSofa::IsMirrored |
| (Cms::Site.mirrored - [self.site]).each do |site| | |
| mirror = case self | |
| when Cms::Layout | |
| - | m = site.layouts.find_by_slug(self.slug_was || self.slug) || site.layouts.new |
| + | m = site.layouts.find_by_identifier(self.identifier_was || self.identifier) || site.layouts.new |
| m.attributes = { | |
| - | :slug => self.slug, |
| - | :parent_id => site.layouts.find_by_slug(self.parent.try(:slug)).try(:id) |
| + | :identifier => self.identifier, |
| + | :parent_id => site.layouts.find_by_identifier(self.parent.try(:identifier)).try(:id) |
| } | |
| m | |
| when Cms::Page | |
| @@ | @@ -50,7 +50,7 @@ module ComfortableMexicanSofa::IsMirrored |
| :slug => self.slug, | |
| :label => self.slug.blank?? self.label : m.label, | |
| :parent_id => site.pages.find_by_full_path(self.parent.try(:full_path)).try(:id), | |
| - | :layout => site.layouts.find_by_slug(self.layout.slug) |
| + | :layout => site.layouts.find_by_identifier(self.layout.identifier) |
| } | |
| m | |
| when Cms::Snippet | |
comfortable_mexican_sofa/fixtures.rb b/lib/comfortable_mexican_sofa/fixtures.rb
+9
-9
| @@ | @@ -20,11 +20,11 @@ module ComfortableMexicanSofa::Fixtures |
| end | |
| Dir.glob("#{path}/*").select{|f| File.directory?(f)}.each do |path| | |
| - | slug = path.split('/').last |
| - | layout = site.layouts.find_by_slug(slug) || site.layouts.new(:slug => slug) |
| + | identifier = path.split('/').last |
| + | layout = site.layouts.find_by_identifier(identifier) || site.layouts.new(:identifier => identifier) |
| # updating attributes | |
| - | if File.exists?(file_path = File.join(path, "_#{slug}.yml")) |
| + | if File.exists?(file_path = File.join(path, "_#{identifier}.yml")) |
| if layout.new_record? || File.mtime(file_path) > layout.updated_at | |
| attributes = YAML.load_file(file_path).symbolize_keys! | |
| layout.label = attributes[:label] || slug.titleize | |
| @@ | @@ -56,7 +56,7 @@ module ComfortableMexicanSofa::Fixtures |
| layout.parent = parent | |
| if layout.changed? | |
| layout.save! | |
| - | Rails.logger.debug "[Fixtures] Saved Layout {#{layout.slug}}" |
| + | Rails.logger.debug "[Fixtures] Saved Layout {#{layout.identifier}}" |
| end | |
| layout_ids << layout.id | |
| @@ | @@ -94,7 +94,7 @@ module ComfortableMexicanSofa::Fixtures |
| if page.new_record? || File.mtime(file_path) > page.updated_at | |
| attributes = YAML.load_file(file_path).symbolize_keys! | |
| page.label = attributes[:label] || slug.titleize | |
| - | page.layout = site.layouts.find_by_slug(attributes[:layout]) || parent.try(:layout) |
| + | page.layout = site.layouts.find_by_identifier(attributes[:layout]) || parent.try(:layout) |
| page.target_page = site.pages.find_by_full_path(attributes[:target_page]) | |
| page.is_published = attributes[:is_published].present?? attributes[:is_published] : true | |
| end | |
| @@ | @@ -186,14 +186,14 @@ module ComfortableMexicanSofa::Fixtures |
| FileUtils.mkdir_p(path) | |
| site.layouts.each do |layout| | |
| - | layout_path = File.join(path, layout.ancestors.reverse.collect{|l| l.slug}, layout.slug) |
| + | layout_path = File.join(path, layout.ancestors.reverse.collect{|l| l.identifier}, layout.identifier) |
| FileUtils.mkdir_p(layout_path) | |
| - | open(File.join(layout_path, "_#{layout.slug}.yml"), 'w') do |f| |
| + | open(File.join(layout_path, "_#{layout.identifier}.yml"), 'w') do |f| |
| f.write({ | |
| 'label' => layout.label, | |
| 'app_layout' => layout.app_layout, | |
| - | 'parent' => layout.parent.try(:slug) |
| + | 'parent' => layout.parent.try(:identifier) |
| }.to_yaml) | |
| end | |
| open(File.join(layout_path, 'content.html'), 'w') do |f| | |
| @@ | @@ -222,7 +222,7 @@ module ComfortableMexicanSofa::Fixtures |
| open(File.join(page_path, "_#{page.slug}.yml"), 'w') do |f| | |
| f.write({ | |
| 'label' => page.label, | |
| - | 'layout' => page.layout.try(:slug), |
| + | 'layout' => page.layout.try(:identifier), |
| 'parent' => page.parent && (page.parent.slug.present?? page.parent.slug : 'index'), | |
| 'target_page' => page.target_page.try(:slug), | |
| 'is_published' => page.is_published | |
comfortable_mexican_sofa/render_methods.rb b/lib/comfortable_mexican_sofa/render_methods.rb
+3
-3
| @@ | @@ -55,9 +55,9 @@ module ComfortableMexicanSofa::RenderMethods |
| raise ComfortableMexicanSofa::MissingPage.new(path) | |
| end | |
| - | elsif options.is_a?(Hash) && slug = options.delete(:cms_layout) |
| + | elsif options.is_a?(Hash) && identifier = options.delete(:cms_layout) |
| @cms_site ||= Cms::Site.find_site(request.host.downcase, request.fullpath) | |
| - | if @cms_layout = @cms_site && @cms_site.layouts.find_by_slug(slug) |
| + | if @cms_layout = @cms_site && @cms_site.layouts.find_by_identifier(identifier) |
| cms_app_layout = @cms_layout.try(:app_layout) | |
| cms_page = @cms_site.pages.build(:layout => @cms_layout) | |
| cms_blocks = options.delete(:cms_blocks) || { :content => render_to_string(:layout => false)} | |
| @@ | @@ -73,7 +73,7 @@ module ComfortableMexicanSofa::RenderMethods |
| options[:inline] = cms_page.content(true) | |
| super(options, locals, &block) | |
| else | |
| - | raise ComfortableMexicanSofa::MissingLayout.new(slug) |
| + | raise ComfortableMexicanSofa::MissingLayout.new(identifier) |
| end | |
| else | |
comfortable_mexican_sofa/tags/asset.rb b/lib/comfortable_mexican_sofa/tags/asset.rb
+1
-1
| @@ | @@ -7,7 +7,7 @@ class ComfortableMexicanSofa::Tag::Asset |
| end | |
| def content | |
| - | return unless (layout = Cms::Layout.find_by_slug(label)) |
| + | return unless (layout = Cms::Layout.find_by_identifier(label)) |
| type = params[0] | |
| format = params[1] | |
test/fixtures/cms/layouts.yml
+3
-3
| @@ | @@ -1,7 +1,7 @@ |
| default: | |
| site: default | |
| label: Default Layout | |
| - | slug: default |
| + | identifier: default |
| parent: | |
| content: |- | |
| {{cms:field:default_field_text:text}} | |
| @@ | @@ -17,7 +17,7 @@ default: |
| nested: | |
| site: default | |
| label: Nested Layout | |
| - | slug: nested |
| + | identifier: nested |
| parent: | |
| content: |- | |
| {{cms:page:header}} | |
| @@ | @@ -29,7 +29,7 @@ nested: |
| child: | |
| site: default | |
| label: Child Layout | |
| - | slug: child |
| + | identifier: child |
| parent: nested | |
| content: |- | |
| {{cms:page:left_column}} | |
test/functional/cms_admin/layouts_controller_test.rb
+7
-7
| @@ | @@ -46,9 +46,9 @@ class CmsAdmin::LayoutsControllerTest < ActionController::TestCase |
| def test_creation | |
| assert_difference 'Cms::Layout.count' do | |
| post :create, :site_id => cms_sites(:default), :layout => { | |
| - | :label => 'Test Layout', |
| - | :slug => 'test', |
| - | :content => 'Test {{cms:page:content}}' |
| + | :label => 'Test Layout', |
| + | :identifier => 'test', |
| + | :content => 'Test {{cms:page:content}}' |
| } | |
| assert_response :redirect | |
| layout = Cms::Layout.last | |
| @@ | @@ -84,12 +84,12 @@ class CmsAdmin::LayoutsControllerTest < ActionController::TestCase |
| def test_update_failure | |
| layout = cms_layouts(:default) | |
| put :update, :site_id => cms_sites(:default), :id => layout, :layout => { | |
| - | :slug => '' |
| + | :identifier => '' |
| } | |
| assert_response :success | |
| assert_template :edit | |
| layout.reload | |
| - | assert_not_equal '', layout.slug |
| + | assert_not_equal '', layout.identifier |
| assert_equal 'Failed to update layout', flash[:error] | |
| end | |
| @@ | @@ -105,8 +105,8 @@ class CmsAdmin::LayoutsControllerTest < ActionController::TestCase |
| def test_reorder | |
| layout_one = cms_layouts(:default) | |
| layout_two = cms_sites(:default).layouts.create!( | |
| - | :label => 'test', |
| - | :slug => 'test' |
| + | :label => 'test', |
| + | :identifier => 'test' |
| ) | |
| assert_equal 0, layout_one.position | |
| assert_equal 1, layout_two.position | |
test/functional/cms_content_controller_test.rb
+4
-4
| @@ | @@ -134,26 +134,26 @@ class CmsContentControllerTest < ActionController::TestCase |
| end | |
| def test_render_css | |
| - | get :render_css, :site_id => cms_sites(:default).id, :layout_slug => cms_layouts(:default).slug |
| + | get :render_css, :site_id => cms_sites(:default).id, :identifier => cms_layouts(:default).identifier |
| assert_response :success | |
| assert_match %r{text\/css}, response.headers["Content-Type"] | |
| assert_equal cms_layouts(:default).css, response.body | |
| end | |
| def test_render_css_not_found | |
| - | get :render_css, :site_id => cms_sites(:default).id, :layout_slug => 'bogus' |
| + | get :render_css, :site_id => cms_sites(:default).id, :identifier => 'bogus' |
| assert_response 404 | |
| end | |
| def test_render_js | |
| - | get :render_js, :site_id => cms_sites(:default).id, :layout_slug => cms_layouts(:default).slug |
| + | get :render_js, :site_id => cms_sites(:default).id, :identifier => cms_layouts(:default).identifier |
| assert_response :success | |
| assert_match %r{text\/javascript}, response.headers["Content-Type"] | |
| assert_equal cms_layouts(:default).js, response.body | |
| end | |
| def test_render_js_not_found | |
| - | get :render_js, :site_id => cms_sites(:default).id, :layout_slug => 'bogus' |
| + | get :render_js, :site_id => cms_sites(:default).id, :identifier => 'bogus' |
| assert_response 404 | |
| end | |
test/integration/fixtures_test.rb
+2
-2
| @@ | @@ -13,7 +13,7 @@ class FixturesTest < ActionDispatch::IntegrationTest |
| assert_response :success | |
| assert_equal 'Default Page', Cms::Page.root.label | |
| - | assert_equal 'Default Layout', Cms::Layout.find_by_slug('default').label |
| + | assert_equal 'Default Layout', Cms::Layout.find_by_identifier('default').label |
| assert_equal 'Default Snippet', Cms::Snippet.find_by_slug('default').label | |
| end | |
| end | |
| @@ | @@ -31,7 +31,7 @@ class FixturesTest < ActionDispatch::IntegrationTest |
| assert_response :success | |
| assert_equal 'Home Fixture Page', Cms::Page.root.label | |
| - | assert_equal 'Default Fixture Layout', Cms::Layout.find_by_slug('default').label |
| + | assert_equal 'Default Fixture Layout', Cms::Layout.find_by_identifier('default').label |
| assert_equal 'Default Fixture Snippet', Cms::Snippet.find_by_slug('default').label | |
| assert_equal "<html>\n <body>\n Home Page Fixture Content\nFixture Content for Default Snippet\n </body>\n</html>", response.body | |
test/integration/render_cms_test.rb
+2
-2
| @@ | @@ -24,8 +24,8 @@ class RenderCmsTest < ActionDispatch::IntegrationTest |
| :label => 'SiteB', | |
| :hostname => 'site-b.test') | |
| layout = site.layouts.create!( | |
| - | :slug => 'default', |
| - | :content => 'site-b {{cms:page:content}}') |
| + | :identifier => 'default', |
| + | :content => 'site-b {{cms:page:content}}') |
| page = site.pages.create!( | |
| :label => 'default', | |
| :layout => layout, | |
test/unit/fixtures_test.rb
+4
-4
| @@ | @@ -8,13 +8,13 @@ class FixturesTest < ActiveSupport::TestCase |
| assert_difference 'Cms::Layout.count', 2 do | |
| ComfortableMexicanSofa::Fixtures.import_layouts('test.host', 'example.com') | |
| - | assert layout = Cms::Layout.find_by_slug('default') |
| + | assert layout = Cms::Layout.find_by_identifier('default') |
| assert_equal 'Default Fixture Layout', layout.label | |
| assert_equal "<html>\n <body>\n {{ cms:page:content }}\n </body>\n</html>", layout.content | |
| assert_equal 'body{color: red}', layout.css | |
| assert_equal '// default js', layout.js | |
| - | assert nested_layout = Cms::Layout.find_by_slug('nested') |
| + | assert nested_layout = Cms::Layout.find_by_identifier('nested') |
| assert_equal layout, nested_layout.parent | |
| assert_equal 'Default Fixture Nested Layout', nested_layout.label | |
| assert_equal "<div class='left'> {{ cms:page:left }} </div>\n<div class='right'> {{ cms:page:right }} </div>", nested_layout.content | |
| @@ | @@ -47,7 +47,7 @@ class FixturesTest < ActiveSupport::TestCase |
| assert_equal 'div{float:left}', nested_layout.css | |
| assert_equal '// nested js', nested_layout.js | |
| - | assert_nil Cms::Layout.find_by_slug('child') |
| + | assert_nil Cms::Layout.find_by_identifier('child') |
| end | |
| end | |
| @@ | @@ -66,7 +66,7 @@ class FixturesTest < ActiveSupport::TestCase |
| ComfortableMexicanSofa::Fixtures.import_layouts('test.host', 'example.com') | |
| layout.reload | |
| - | assert_equal 'default', layout.slug |
| + | assert_equal 'default', layout.identifier |
| assert_equal 'Default Layout', layout.label | |
| assert_equal "{{cms:field:default_field_text:text}}\nlayout_content_a\n{{cms:page:default_page_text:text}}\nlayout_content_b\n{{cms:snippet:default}}\nlayout_content_c", layout.content | |
| assert_equal 'default_css', layout.css | |
test/unit/mirrors_test.rb
+16
-16
| @@ | @@ -10,14 +10,14 @@ class MirrorsTest < ActiveSupport::TestCase |
| def test_layout_creation | |
| assert_difference 'Cms::Layout.count', 2 do | |
| - | layout = @site_a.layouts.create!(:slug => 'test') |
| + | layout = @site_a.layouts.create!(:identifier => 'test') |
| assert_equal 1, layout.mirrors.size | |
| - | assert_equal 'test', layout.mirrors.first.slug |
| + | assert_equal 'test', layout.mirrors.first.identifier |
| end | |
| end | |
| def test_page_creation | |
| - | layout = @site_a.layouts.create!(:slug => 'test') |
| + | layout = @site_a.layouts.create!(:identifier => 'test') |
| assert_difference 'Cms::Page.count', 2 do | |
| page = @site_a.pages.create!( | |
| @@ | @@ -38,9 +38,9 @@ class MirrorsTest < ActiveSupport::TestCase |
| end | |
| def test_layout_update | |
| - | layout_1a = @site_a.layouts.create!(:slug => 'test_a') |
| - | layout_1b = @site_a.layouts.create!(:slug => 'test_b') |
| - | layout_1c = @site_a.layouts.create!(:slug => 'nested', :parent => layout_1a) |
| + | layout_1a = @site_a.layouts.create!(:identifier => 'test_a') |
| + | layout_1b = @site_a.layouts.create!(:identifier => 'test_b') |
| + | layout_1c = @site_a.layouts.create!(:identifier => 'nested', :parent => layout_1a) |
| assert layout_2a = layout_1a.mirrors.first | |
| assert layout_2b = layout_1b.mirrors.first | |
| @@ | @@ -48,19 +48,19 @@ class MirrorsTest < ActiveSupport::TestCase |
| assert_equal layout_2a, layout_2c.parent | |
| layout_1c.update_attributes!( | |
| - | :slug => 'updated', |
| - | :parent => layout_1b, |
| - | :content => 'updated content' |
| + | :identifier => 'updated', |
| + | :parent => layout_1b, |
| + | :content => 'updated content' |
| ) | |
| layout_2c.reload | |
| - | assert_equal 'updated', layout_2c.slug |
| + | assert_equal 'updated', layout_2c.identifier |
| assert_equal layout_2b, layout_2c.parent | |
| assert_not_equal 'updated content', layout_2c | |
| end | |
| def test_page_update | |
| - | layout_1a = @site_a.layouts.create!(:slug => 'test_a') |
| - | layout_1b = @site_a.layouts.create!(:slug => 'test_b') |
| + | layout_1a = @site_a.layouts.create!(:identifier => 'test_a') |
| + | layout_1b = @site_a.layouts.create!(:identifier => 'test_b') |
| page_1r = @site_a.pages.create!(:slug => 'root', :layout => layout_1a) | |
| page_1a = @site_a.pages.create!(:slug => 'test_a', :layout => layout_1a) | |
| @@ | @@ -96,9 +96,9 @@ class MirrorsTest < ActiveSupport::TestCase |
| end | |
| def test_layout_destroy | |
| - | layout_1a = @site_a.layouts.create!(:slug => 'test_a') |
| - | layout_1b = @site_a.layouts.create!(:slug => 'test_b') |
| - | layout_1c = @site_a.layouts.create!(:slug => 'nested', :parent => layout_1b) |
| + | layout_1a = @site_a.layouts.create!(:identifier => 'test_a') |
| + | layout_1b = @site_a.layouts.create!(:identifier => 'test_b') |
| + | layout_1c = @site_a.layouts.create!(:identifier => 'nested', :parent => layout_1b) |
| assert layout_2a = layout_1a.mirrors.first | |
| assert layout_2b = layout_1b.mirrors.first | |
| @@ | @@ -116,7 +116,7 @@ class MirrorsTest < ActiveSupport::TestCase |
| end | |
| def test_page_destroy | |
| - | layout = @site_a.layouts.create!(:slug => 'test') |
| + | layout = @site_a.layouts.create!(:identifier => 'test') |
| page_1r = @site_a.pages.create!(:slug => 'root', :layout => layout) | |
| page_1a = @site_a.pages.create!(:slug => 'test_a', :layout => layout) | |
| page_1b = @site_a.pages.create!(:slug => 'test_b', :layout => layout) | |
test/unit/models/layout_test.rb
+11
-8
| @@ | @@ -11,11 +11,14 @@ class CmsLayoutTest < ActiveSupport::TestCase |
| def test_validations | |
| layout = cms_sites(:default).layouts.create | |
| assert layout.errors.present? | |
| - | assert_has_errors_on layout, [:label, :slug] |
| + | assert_has_errors_on layout, [:label, :identifier] |
| end | |
| def test_label_assignment | |
| - | layout = cms_sites(:default).layouts.new(:slug => 'test', :content => '{{cms:page:content}}') |
| + | layout = cms_sites(:default).layouts.new( |
| + | :identifier => 'test', |
| + | :content => '{{cms:page:content}}' |
| + | ) |
| assert layout.valid? | |
| assert_equal 'Test', layout.label | |
| end | |
| @@ | @@ -23,14 +26,14 @@ class CmsLayoutTest < ActiveSupport::TestCase |
| def test_creation | |
| assert_difference 'Cms::Layout.count' do | |
| layout = cms_sites(:default).layouts.create( | |
| - | :label => 'New Layout', |
| - | :slug => 'new-layout', |
| - | :content => '{{cms:page:content}}', |
| - | :css => 'css', |
| - | :js => 'js' |
| + | :label => 'New Layout', |
| + | :identifier => 'new-layout', |
| + | :content => '{{cms:page:content}}', |
| + | :css => 'css', |
| + | :js => 'js' |
| ) | |
| assert_equal 'New Layout', layout.label | |
| - | assert_equal 'new-layout', layout.slug |
| + | assert_equal 'new-layout', layout.identifier |
| assert_equal '{{cms:page:content}}', layout.content | |
| assert_equal 'css', layout.css | |
| assert_equal 'js', layout.js | |
test/unit/tag_test.rb
+4
-4
| @@ | @@ -225,8 +225,8 @@ class TagTest < ActiveSupport::TestCase |
| site = cms_sites(:default) | |
| layout = site.layouts.create!( | |
| - | :slug => 'no-irb-layout', |
| - | :content => '<% 1 + 1 %> {{cms:page:content}} {{cms:collection:snippet:cms/snippet}} <%= 1 + 1 %>' |
| + | :identifier => 'no-irb-layout', |
| + | :content => '<% 1 + 1 %> {{cms:page:content}} {{cms:collection:snippet:cms/snippet}} <%= 1 + 1 %>' |
| ) | |
| snippet = site.snippets.create!( | |
| :slug => 'no-irb-snippet', | |
| @@ | @@ -251,8 +251,8 @@ class TagTest < ActiveSupport::TestCase |
| site = cms_sites(:default) | |
| layout = site.layouts.create!( | |
| - | :slug => 'irb-layout', |
| - | :content => '<% 1 + 1 %> {{cms:page:content}} {{cms:collection:snippet:cms/snippet}} <%= 1 + 1 %>' |
| + | :identifier => 'irb-layout', |
| + | :content => '<% 1 + 1 %> {{cms:page:content}} {{cms:collection:snippet:cms/snippet}} <%= 1 + 1 %>' |
| ) | |
| snippet = site.snippets.create!( | |
| :slug => 'irb-snippet', | |