ripping out fixtures, cleaning up tests
Oleg
committed Apr 15, 2011
commit 0266a6a1eb10be10bdbd9dabcaa09ead401663ae
Showing 47
changed files with
46 additions
and 762 deletions
README.md
+3
-19
| @@ | @@ -142,25 +142,9 @@ Do you have other authentication system in place (like Devise, AuthLogic, etc) a |
| You can put this module in /config/initializers/comfortable\_mexican\_sofa.rb and change authentication method: `config.authentication = 'CmsDeviseAuth'`. Now to access Sofa's admin area users will be authenticated against your existing authentication system. | |
| - | Working with seeds |
| - | ------------------ |
| - | ComfortableMexicanSofa has seeds, functionality that helps manage content during development phase. It's very different from Rails seeds as Sofa's seeds are loaded with each page load. The database is completely bypassed when seeds are active. This way, you can source-control content before going live, disabling seeds and dumping everything into the database. |
| - | |
| - | First, you will need to set a path where fixture files will be found (inside Sofa's initializer): |
| - | |
| - | if Rails.env.development? || Rails.env.test? |
| - | ComfortableMexicanSofa.config.seed_data_path = File.expand_path('db/cms_seeds', Rails.root) |
| - | end |
| - | |
| - | If you ran `rails g cms`, you should find an example set of seeds in /db/cms\_seeds directory. Please note that seeds are nested in the folder that is the hostname of your site. Each file is an YAML representation of a database entry for that layout/page/snippet. |
| - | |
| - | There's a rake task that makes moving seeds into database (and vice-versa) easy: |
| - | |
| - | # from seeds into database |
| - | rake comfortable_mexican_sofa:import:all FROM=your-site.local TO=your-site.com SEED_PATH=/path/to/seeds |
| - | |
| - | # from database to seeds |
| - | rake comfortable_mexican_sofa:export:all FROM=your-site.com TO=your-site.local SEED_PATH=/path/to/seeds |
| + | Working with Fixtures |
| + | --------------------- |
| + | TODO |
| Active Components | |
| ----------------- | |
app/controllers/cms_admin/pages_controller.rb
+1
-1
| @@ | @@ -44,7 +44,7 @@ class CmsAdmin::PagesController < CmsAdmin::BaseController |
| end | |
| def form_blocks | |
| - | @cms_page = @cms_site.cms_pages.find_by_id(params[:id]) || CmsPage.new |
| + | @cms_page = @cms_site.cms_pages.find_by_id(params[:id]) || @cms_site.cms_pages.new |
| @cms_page.cms_layout = @cms_site.cms_layouts.find_by_id(params[:layout_id]) | |
| end | |
app/controllers/cms_content_controller.rb
+3
-3
| @@ | @@ -28,11 +28,11 @@ protected |
| end | |
| def load_cms_page | |
| - | @cms_page = CmsPage.published.load_for_full_path!(@cms_site, "/#{params[:cms_path]}") |
| + | @cms_page = @cms_site.cms_pages.published.find_by_full_path!("/#{params[:cms_path]}") |
| return redirect_to(@cms_page.target_page.full_path) if @cms_page.target_page | |
| rescue ActiveRecord::RecordNotFound | |
| - | if @cms_page = CmsPage.published.load_for_full_path(@cms_site, '/404') |
| + | if @cms_page = @cms_site.cms_pages.published.find_by_full_path('/404') |
| render_html(404) | |
| else | |
| render :text => 'Page Not Found', :status => 404 | |
| @@ | @@ -40,7 +40,7 @@ protected |
| end | |
| def load_cms_layout | |
| - | @cms_layout = CmsLayout.load_for_slug!(@cms_site, params[:id]) |
| + | @cms_layout = @cms_site.cms_layouts.find_by_slug!(params[:id]) |
| rescue ActiveRecord::RecordNotFound | |
| render :nothing => true, :status => 404 | |
| end | |
app/models/cms_layout.rb
+1
-31
| @@ | @@ -46,36 +46,6 @@ class CmsLayout < ActiveRecord::Base |
| end.compact | |
| end | |
| - | # Attempting to initialize layout object from yaml file that is found in config.seed_data_path |
| - | def self.load_from_file(site, slug) |
| - | return nil if ComfortableMexicanSofa.config.seed_data_path.blank? |
| - | file_path = "#{ComfortableMexicanSofa.config.seed_data_path}/#{site.hostname}/layouts/#{slug}.yml" |
| - | return nil unless File.exists?(file_path) |
| - | attributes = YAML.load_file(file_path).symbolize_keys! |
| - | attributes[:parent] = CmsLayout.load_from_file(site, attributes[:parent]) |
| - | attributes[:cms_site] = site |
| - | new(attributes) |
| - | rescue |
| - | raise "Failed to load from #{file_path}" |
| - | end |
| - | |
| - | # Wrapper around load_from_file and find_by_slug |
| - | # returns layout object if loaded / found |
| - | def self.load_for_slug!(site, slug) |
| - | if ComfortableMexicanSofa.configuration.seed_data_path |
| - | load_from_file(site, slug) |
| - | else |
| - | site.cms_layouts.find_by_slug(slug) |
| - | end || raise(ActiveRecord::RecordNotFound, "CmsLayout with slug: #{slug} cannot be found") |
| - | end |
| - | |
| - | # Non-blowing-up version of the method above |
| - | def self.load_for_slug(site, slug) |
| - | load_for_slug!(site, slug) |
| - | rescue ActiveRecord::RecordNotFound |
| - | nil |
| - | end |
| - | |
| # -- Instance Methods ----------------------------------------------------- | |
| # magical merging tag is {cms:page:content} If parent layout has this tag | |
| # defined its content will be merged. If no such tag found, parent content | |
| @@ | @@ -96,7 +66,7 @@ class CmsLayout < ActiveRecord::Base |
| protected | |
| def check_content_tag_presence | |
| - | CmsTag.process_content((test_page = CmsPage.new), content) |
| + | CmsTag.process_content((test_page = cms_site.cms_pages.new), content) |
| if test_page.cms_tags.select{|t| t.class.superclass == CmsBlock}.blank? | |
| self.errors.add(:content, 'No cms page tags defined') | |
| end | |
app/models/cms_page.rb
+0
-34
| @@ | @@ -54,40 +54,6 @@ class CmsPage < ActiveRecord::Base |
| return out.compact | |
| end | |
| - | # Attempting to initialize page object from yaml file that is found in config.seed_data_path |
| - | # This file defines all attributes of the page plus all the block information |
| - | def self.load_from_file(site, path) |
| - | return nil if ComfortableMexicanSofa.config.seed_data_path.blank? |
| - | path = (path == '/')? '/index' : path.to_s.chomp('/') |
| - | file_path = "#{ComfortableMexicanSofa.config.seed_data_path}/#{site.hostname}/pages#{path}.yml" |
| - | return nil unless File.exists?(file_path) |
| - | attributes = YAML.load_file(file_path).symbolize_keys! |
| - | attributes[:cms_layout] = CmsLayout.load_from_file(site, attributes[:cms_layout]) |
| - | attributes[:parent] = CmsPage.load_from_file(site, attributes[:parent]) |
| - | attributes[:cms_site] = site |
| - | attributes[:target_page]= CmsPage.load_from_file(site, attributes[:target_page]) |
| - | new(attributes) |
| - | rescue |
| - | raise "Failed to load from #{file_path}" |
| - | end |
| - | |
| - | # Wrapper around load_from_file and find_by_full_path |
| - | # returns page object if loaded / found |
| - | def self.load_for_full_path!(site, path) |
| - | if ComfortableMexicanSofa.configuration.seed_data_path |
| - | load_from_file(site, path) |
| - | else |
| - | site.cms_pages.find_by_full_path(path) |
| - | end || raise(ActiveRecord::RecordNotFound, "CmsPage with path: #{path} cannot be found") |
| - | end |
| - | |
| - | # Non-blowing-up version of the method above |
| - | def self.load_for_full_path(site, path) |
| - | load_for_full_path!(site, path) |
| - | rescue ActiveRecord::RecordNotFound |
| - | nil |
| - | end |
| - | |
| # -- Instance Methods ----------------------------------------------------- | |
| # For previewing purposes sometimes we need to have full_path set | |
| def full_path | |
app/models/cms_snippet.rb
+2
-32
| @@ | @@ -23,38 +23,8 @@ class CmsSnippet < ActiveRecord::Base |
| end | |
| def self.initialize_or_find(cms_page, slug) | |
| - | load_for_slug(cms_page.cms_site, slug) || new(:slug => slug) |
| - | end |
| - | |
| - | # Attempting to initialize snippet object from yaml file that is found in config.seed_data_path |
| - | def self.load_from_file(site, name) |
| - | return nil if ComfortableMexicanSofa.config.seed_data_path.blank? |
| - | file_path = "#{ComfortableMexicanSofa.config.seed_data_path}/#{site.hostname}/snippets/#{name}.yml" |
| - | return nil unless File.exists?(file_path) |
| - | attributes = YAML.load_file(file_path).symbolize_keys! |
| - | new(attributes) |
| - | rescue |
| - | raise "Failed to load from #{file_path}" |
| - | end |
| - | |
| - | # Wrapper around load_from_file and find_by_slug |
| - | # returns layout object if loaded / found |
| - | def self.load_for_slug!(site, slug) |
| - | if ComfortableMexicanSofa.configuration.seed_data_path |
| - | load_from_file(site, slug) |
| - | else |
| - | # FIX: This a bit odd... Snippet is used as a tag, so sometimes there's no site scope |
| - | # being passed. So we're enforcing this only if it's found. Need to review. |
| - | conditions = site ? {:conditions => {:cms_site_id => site.id}} : {} |
| - | find_by_slug(slug, conditions) |
| - | end || raise(ActiveRecord::RecordNotFound, "CmsSnippet with slug: #{slug} cannot be found") |
| - | end |
| - | |
| - | # Non-blowing-up version of the method above |
| - | def self.load_for_slug(site, slug) |
| - | load_for_slug!(site, slug) |
| - | rescue ActiveRecord::RecordNotFound |
| - | nil |
| + | find_by_slug(slug, :conditions => {:cms_site_id => cms_page.cms_site.id}) || |
| + | new(:slug => slug, :cms_site => cms_page.cms_site) |
| end | |
| protected | |
cms_fixtures/example.local/layouts/default/_default.yml b/db/cms_fixtures/example.local/layouts/default/_default.yml
+1
-0
| @@ | @@ -0,0 +1 @@ |
| + | label: Default Layout |
| \ No newline at end of file | |
cms_fixtures/example.local/layouts/default/content.html b/db/cms_fixtures/example.local/layouts/default/content.html
+5
-0
| @@ | @@ -0,0 +1,5 @@ |
| + | <html> |
| + | <body> |
| + | {{ cms:page:content }} |
| + | </body> |
| + | </html> |
| \ No newline at end of file | |
cms_fixtures/example.local/layouts/default/css.css b/db/cms_fixtures/example.local/layouts/default/css.css
+1
-0
| @@ | @@ -0,0 +1 @@ |
| + | body{color: red} |
| \ No newline at end of file | |
cms_fixtures/example.local/layouts/default/js.js b/db/cms_fixtures/example.local/layouts/default/js.js
+1
-0
| @@ | @@ -0,0 +1 @@ |
| + | // default js |
| \ No newline at end of file | |
cms_fixtures/example.local/layouts/default/nested/_nested.yml b/db/cms_fixtures/example.local/layouts/default/nested/_nested.yml
+1
-0
| @@ | @@ -0,0 +1 @@ |
| + | label: Default Layout |
| \ No newline at end of file | |
cms_fixtures/example.local/layouts/default/nested/content.html b/db/cms_fixtures/example.local/layouts/default/nested/content.html
+2
-0
| @@ | @@ -0,0 +1,2 @@ |
| + | <div class='left'> {{ cms:page:left }} </div> |
| + | <div class='right'> {{ cms:page:right }} </div> |
| \ No newline at end of file | |
cms_fixtures/example.local/layouts/default/nested/css.css b/db/cms_fixtures/example.local/layouts/default/nested/css.css
+1
-0
| @@ | @@ -0,0 +1 @@ |
| + | div{float:left} |
| \ No newline at end of file | |
cms_fixtures/example.local/layouts/default/nested/js.js b/db/cms_fixtures/example.local/layouts/default/nested/js.js
+1
-0
| @@ | @@ -0,0 +1 @@ |
| + | // nested js |
| \ No newline at end of file | |
cms_fixtures/example.local/pages/index/_index.yml b/db/cms_fixtures/example.local/pages/index/_index.yml
+2
-0
| @@ | @@ -0,0 +1,2 @@ |
| + | label: Home Page |
| + | layout: default |
| \ No newline at end of file | |
cms_fixtures/example.local/pages/index/child/_child.yml b/db/cms_fixtures/example.local/pages/index/child/_child.yml
+1
-0
| @@ | @@ -0,0 +1 @@ |
| + | label: Child Page |
| \ No newline at end of file | |
cms_fixtures/example.local/pages/index/child/content.html b/db/cms_fixtures/example.local/pages/index/child/content.html
+1
-0
| @@ | @@ -0,0 +1 @@ |
| + | Child Page Conte dnt |
| \ No newline at end of file | |
cms_fixtures/example.local/pages/index/child/subchild/_subchild.yml b/db/cms_fixtures/example.local/pages/index/child/subchild/_subchild.yml
+2
-0
| @@ | @@ -0,0 +1,2 @@ |
| + | label: Sub-Child Page |
| + | layout: nested |
| \ No newline at end of file | |
cms_fixtures/example.local/pages/index/child/subchild/left.html b/db/cms_fixtures/example.local/pages/index/child/subchild/left.html
+1
-0
| @@ | @@ -0,0 +1 @@ |
| + | Sub Child Page Left Content |
| \ No newline at end of file | |
cms_fixtures/example.local/pages/index/child/subchild/right.html b/db/cms_fixtures/example.local/pages/index/child/subchild/right.html
+1
-0
| @@ | @@ -0,0 +1 @@ |
| + | Sub Child Page Right Content |
| \ No newline at end of file | |
cms_fixtures/example.local/pages/index/content.html b/db/cms_fixtures/example.local/pages/index/content.html
+2
-0
| @@ | @@ -0,0 +1,2 @@ |
| + | Home Page Content |
| + | {{ cms:snippet:example }} |
| \ No newline at end of file | |
cms_fixtures/example.local/snippets/default/_default.yml b/db/cms_fixtures/example.local/snippets/default/_default.yml
+1
-0
| @@ | @@ -0,0 +1 @@ |
| + | label: Default Snippet |
| \ No newline at end of file | |
cms_fixtures/example.local/snippets/default/content.html b/db/cms_fixtures/example.local/snippets/default/content.html
+1
-0
| @@ | @@ -0,0 +1 @@ |
| + | Content for Snippet |
| \ No newline at end of file | |
cms_seeds/example.local/layouts/default.yml b/db/cms_seeds/example.local/layouts/default.yml
+0
-8
| @@ | @@ -1,8 +0,0 @@ |
| - | label: Default Layout |
| - | slug: default |
| - | content: |- |
| - | <html> |
| - | <body> |
| - | {{ cms:page:content }} |
| - | </body> |
| - | </html> |
| \ No newline at end of file | |
cms_seeds/example.local/layouts/nested.yml b/db/cms_seeds/example.local/layouts/nested.yml
+0
-6
| @@ | @@ -1,6 +0,0 @@ |
| - | label: Nested Layout |
| - | slug: nested |
| - | parent: default |
| - | content: |- |
| - | <div class='left'> {{ cms:page:left }} </div> |
| - | <div class='left'> {{ cms:page:right }} </div> |
| \ No newline at end of file | |
cms_seeds/example.local/pages/child.yml b/db/cms_seeds/example.local/pages/child.yml
+0
-10
| @@ | @@ -1,10 +0,0 @@ |
| - | label: Child Page |
| - | parent: / |
| - | cms_layout: default |
| - | full_path: /child |
| - | slug: child |
| - | cms_blocks_attributes: |
| - | - |
| - | label: content |
| - | content: |- |
| - | Child Page Content |
| \ No newline at end of file | |
cms_seeds/example.local/pages/child/subchild.yml b/db/cms_seeds/example.local/pages/child/subchild.yml
+0
-14
| @@ | @@ -1,14 +0,0 @@ |
| - | label: Sub-Child Page |
| - | parent: /child |
| - | cms_layout: nested |
| - | full_path: /child/subchild |
| - | slug: subchild |
| - | cms_blocks_attributes: |
| - | - |
| - | label: left |
| - | content: |- |
| - | Sub Child Page Left Content |
| - | - |
| - | label: right |
| - | content: |- |
| - | Sub Child Page Right Content |
| \ No newline at end of file | |
cms_seeds/example.local/pages/index.yml b/db/cms_seeds/example.local/pages/index.yml
+0
-11
| @@ | @@ -1,11 +0,0 @@ |
| - | label: Home Page |
| - | parent: |
| - | cms_layout: default |
| - | full_path: / |
| - | slug: |
| - | cms_blocks_attributes: |
| - | - |
| - | label: content |
| - | content: |- |
| - | Home Page Content |
| - | {{ cms:snippet:example }} |
| \ No newline at end of file | |
cms_seeds/example.local/snippets/example.yml b/db/cms_seeds/example.local/snippets/example.yml
+0
-4
| @@ | @@ -1,4 +0,0 @@ |
| - | label: Example Snippet |
| - | slug: example |
| - | content: |- |
| - | Content for Example Snippet |
| \ No newline at end of file | |
comfortable_mexican_sofa/view_methods.rb b/lib/comfortable_mexican_sofa/view_methods.rb
+4
-3
| @@ | @@ -22,8 +22,9 @@ module ComfortableMexicanSofa::ViewMethods |
| # Content of a snippet. Example: | |
| # cms_snippet_content(:my_snippet) | |
| - | def cms_snippet_content(snippet_slug) |
| - | return '' unless snippet = CmsSnippet.load_for_slug(@cms_site, snippet_slug) |
| + | def cms_snippet_content(snippet_slug, cms_site = nil) |
| + | return '' unless cms_site ||= (@cms_site || CmsSite.find_by_hostname!(request.host.downcase)) |
| + | return '' unless snippet = cms_site.cms_snippets.find_by_slug(snippet_slug) |
| snippet.content.to_s.html_safe | |
| end | |
| @@ | @@ -33,7 +34,7 @@ module ComfortableMexicanSofa::ViewMethods |
| # cms_page_content(:left_column) # if @cms_page is present | |
| def cms_page_content(block_label, page = nil) | |
| return '' unless page ||= @cms_page | |
| - | return '' unless block = page.cms_blocks.select{|b| b.label == block_label}.first |
| + | return '' unless block = page.cms_blocks.find_by_label(block_label) |
| block.content.to_s.html_safe | |
| end | |
| end | |
tasks/comfortable_mexican_sofa.rake b/lib/tasks/comfortable_mexican_sofa.rake
+0
-284
| @@ | @@ -1,284 +0,0 @@ |
| - | # Small hack to auto-run migrations during testing |
| - | namespace :db do |
| - | task :abort_if_pending_migrations => [:migrate] |
| - | end |
| - | |
| - | namespace :comfortable_mexican_sofa do |
| - | |
| - | # Example use: |
| - | # rake comfortable_mexican_sofa:import:all FROM=mysite.local TO=mysite.com SEED_PATH=/path/to/seed_data |
| - | namespace :import do |
| - | |
| - | task :check_for_requirements => :environment do |task, args| |
| - | @from = args[:from].present?? args[:from] : nil |
| - | @site = args[:to].present?? args[:to] : nil |
| - | @seed_path = |
| - | ComfortableMexicanSofa.config.seed_data_path = |
| - | (args[:seed_path].present?? args[:seed_path] : nil) || ComfortableMexicanSofa.config.seed_data_path |
| - | |
| - | if !@seed_path |
| - | abort 'SEED_PATH is not set. Please define where cms fixtures are located.' |
| - | end |
| - | unless File.exists?((@from && @seed_path = "#{@seed_path}/#{@from}").to_s) |
| - | abort "FROM is not properly set. Cannot find fixtures in '#{@seed_path}'" |
| - | end |
| - | if !(@site = CmsSite.find_by_hostname(args[:to])) |
| - | abort "TO is not properly set. Cannot find site with hostname '#{args[:to]}'" |
| - | end |
| - | |
| - | # a small hack to ensure that #load_from_file looks in the right directory |
| - | @site.hostname = args[:from] |
| - | |
| - | puts "Starting import into #{@site.label} (#{@site.hostname}) from '#{@seed_path}'" |
| - | end |
| - | |
| - | desc 'Import layouts into database' |
| - | task :layouts => [:environment, :check_for_requirements] do |task, args| |
| - | puts 'Importing Layouts' |
| - | puts '-----------------' |
| - | layouts = Dir.glob(File.expand_path('layouts/*.yml', @seed_path)).collect do |layout_file_path| |
| - | begin |
| - | attributes = YAML.load_file(layout_file_path).symbolize_keys! |
| - | @site.cms_layouts.load_from_file(@site, attributes[:slug]) |
| - | rescue |
| - | nil |
| - | end |
| - | end.compact |
| - | CmsLayout.connection.transaction do |
| - | # Fixtures are not ordered in any particular way. Saving order matters, |
| - | # so we cycle them until there nothing left to save |
| - | while layouts.present? |
| - | layout = layouts.shift |
| - | if !layout.parent || layout.parent && parent = @site.cms_layouts.find_by_slug(layout.parent.slug) |
| - | 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? (y/N): " |
| - | should_write = ($stdin.gets.to_s.strip.downcase == 'y') |
| - | end |
| - | if should_write |
| - | if existing_layout |
| - | existing_layout.attributes = layout.attributes.slice('label', 'content', 'css', 'js') |
| - | layout = existing_layout |
| - | end |
| - | puts "Saving layout: #{layout.label} (#{layout.slug})" |
| - | layout.save! |
| - | else |
| - | puts "Skipping layout: #{layout.label} (#{layout.slug})" |
| - | end |
| - | else |
| - | layouts.push layout |
| - | end |
| - | end |
| - | end |
| - | end |
| - | |
| - | desc 'Import pages into database' |
| - | task :pages => [:environment, :check_for_requirements] do |task, args| |
| - | puts 'Importing Pages' |
| - | puts '---------------' |
| - | pages = Dir.glob(File.expand_path('pages/**/*.yml', @seed_path)).collect do |page_file_path| |
| - | begin |
| - | attributes = YAML.load_file(page_file_path).symbolize_keys! |
| - | @site.cms_pages.load_from_file(@site, attributes[:full_path]) |
| - | rescue |
| - | nil |
| - | end |
| - | end.compact |
| - | CmsPage.connection.transaction do |
| - | # Fixtures are not ordered in any particular way. Saving order matters, |
| - | # so we cycle them until there nothing left to save |
| - | while pages.present? |
| - | page = pages.shift |
| - | if !page.parent || page.parent && parent = @site.cms_pages.find_by_full_path(page.parent.full_path) |
| - | page.parent = (parent rescue nil) |
| - | page.cms_layout = @site.cms_layouts.find_by_slug(page.cms_layout.slug) |
| - | should_write = true |
| - | existing_page = nil |
| - | |
| - | if existing_page = @site.cms_pages.find_by_full_path(page.full_path) |
| - | print "Found page in database with full_path: #{page.full_path}. Overwrite? (y/N): " |
| - | should_write = ($stdin.gets.to_s.strip.downcase == 'y') |
| - | end |
| - | |
| - | if should_write |
| - | if existing_page |
| - | # merging cms_blocks_attributes with the existing page |
| - | attrs = page.cms_blocks_attributes.collect do |block_attrs| |
| - | existing_block = existing_page.cms_blocks_attributes.find{|b| b[:label] == block_attrs[:label]} |
| - | block_attrs[:id] = existing_block[:id] if existing_block |
| - | block_attrs.stringify_keys |
| - | end |
| - | |
| - | existing_page.attributes = page.attributes.slice('label') |
| - | existing_page.cms_blocks_attributes = attrs |
| - | page = existing_page |
| - | end |
| - | puts "... Saving page: #{page.label} (#{page.full_path})" |
| - | page.save! |
| - | else |
| - | puts "... Skipping page: #{page.label} (#{page.full_path})" |
| - | end |
| - | else |
| - | pages.push page |
| - | end |
| - | end |
| - | end |
| - | end |
| - | |
| - | desc 'Import snippets into database' |
| - | task :snippets => [:environment, :check_for_requirements] do |task, args| |
| - | puts 'Importing Snippets' |
| - | puts '------------------' |
| - | snippets = Dir.glob(File.expand_path('snippets/*.yml', @seed_path)).collect do |snippet_file_path| |
| - | begin |
| - | attributes = YAML.load_file(snippet_file_path).symbolize_keys! |
| - | @site.cms_snippets.load_from_file(@site, attributes[:slug]) |
| - | rescue |
| - | nil |
| - | end |
| - | end.compact |
| - | CmsSnippet.connection.transaction do |
| - | snippets.each do |snippet| |
| - | should_write = true |
| - | existing_snippet = nil |
| - | if existing_snippet = @site.cms_snippets.find_by_slug(snippet.slug) |
| - | print "Found snippet in database with slug: #{snippet.slug}. Overwrite? (y/N): " |
| - | should_write = ($stdin.gets.to_s.strip.downcase == 'y') |
| - | end |
| - | if should_write |
| - | if existing_snippet |
| - | existing_snippet.attributes = snippet.attributes.slice('label', 'content') |
| - | snippet = existing_snippet |
| - | end |
| - | puts "... Saving snippet: #{snippet.label} (#{snippet.slug})" |
| - | snippet.save! |
| - | else |
| - | puts "... Skipping snippet: #{snippet.label} (#{snippet.slug})" |
| - | end |
| - | end |
| - | end |
| - | end |
| - | |
| - | desc 'Import layouts, pages and snippets all in one go' |
| - | task :all => [:layouts, :pages, :snippets] |
| - | |
| - | end |
| - | |
| - | # Example use: |
| - | # rake comfortable_mexican_sofa:import:all FROM=mysite.com TO=mysite.local SEED_PATH=/path/to/seed_data |
| - | namespace :export do |
| - | |
| - | task :check_for_requirements => :environment do |task, args| |
| - | @site = args[:from].present?? args[:from] : nil |
| - | @to = args[:to].present?? args[:to] : nil |
| - | @seed_path = |
| - | ComfortableMexicanSofa.config.seed_data_path = |
| - | (args[:seed_path].present?? args[:seed_path] : nil) || ComfortableMexicanSofa.config.seed_data_path |
| - | |
| - | if !@seed_path |
| - | abort 'SEED_PATH is not set. Please define where cms fixtures are located.' |
| - | end |
| - | if !(@site = CmsSite.find_by_hostname(args[:from])) |
| - | abort "FROM is not properly set. Cannot find site with hostname '#{args[:from]}'" |
| - | end |
| - | unless @to && @seed_path = "#{@seed_path}/#{@to}" |
| - | abort "TO is not properly set. What's the target hostname?" |
| - | end |
| - | |
| - | FileUtils.mkdir_p @seed_path |
| - | FileUtils.mkdir_p "#{@seed_path}/layouts" |
| - | FileUtils.mkdir_p "#{@seed_path}/pages" |
| - | FileUtils.mkdir_p "#{@seed_path}/snippets" |
| - | |
| - | puts "Starting export from #{@site.label} (#{@site.hostname}) to '#{@seed_path}'" |
| - | end |
| - | |
| - | desc 'Export layouts to yaml files' |
| - | task :layouts => [:environment, :check_for_requirements] do |task, args| |
| - | puts 'Exporting Layouts' |
| - | puts '-----------------' |
| - | CmsLayout.all.each do |layout| |
| - | should_write = true |
| - | file_path = File.join(@seed_path, 'layouts', "#{layout.slug}.yml") |
| - | if File.exists?(file_path) |
| - | print "Found layout fixture: #{file_path} Overwrite? (y/N): " |
| - | should_write = ($stdin.gets.to_s.strip.downcase == 'y') |
| - | end |
| - | if should_write |
| - | attributes = layout.attributes.slice('label', 'slug', 'content', 'css', 'js') |
| - | attributes['parent'] = layout.parent.slug if layout.parent |
| - | open(file_path, 'w') do |f| |
| - | f.write(attributes.to_yaml) |
| - | end |
| - | puts "... Saving layout: #{layout.label} (#{layout.slug})" |
| - | else |
| - | puts "... Skipping layout: #{layout.label} (#{layout.slug})" |
| - | end |
| - | end |
| - | end |
| - | |
| - | desc 'Export pages to yaml files' |
| - | task :pages => [:environment, :check_for_requirements] do |task, args| |
| - | puts 'Exporting Pages' |
| - | puts '---------------' |
| - | CmsPage.all.each do |page| |
| - | should_write = true |
| - | page_name = page.full_path.split('/').last || 'index' |
| - | page_path = (p = page.full_path.split('/')) && p.pop && p.join('/') |
| - | |
| - | FileUtils.mkdir_p "#{@seed_path}/pages/#{page_path}" |
| - | file_path = File.join(@seed_path, 'pages', "#{page_path}/#{page_name}.yml") |
| - | |
| - | if File.exists?(file_path) |
| - | print "Found page fixture: #{file_path} Overwrite? (y/N): " |
| - | should_write = ($stdin.gets.to_s.strip.downcase == 'y') |
| - | end |
| - | if should_write |
| - | |
| - | attributes = page.attributes.slice('label', 'slug', 'full_path', 'is_published') |
| - | attributes['targe_page'] = page.target_page.full_path if page.target_page |
| - | attributes['parent'] = page.parent.full_path if page.parent |
| - | attributes['cms_layout'] = page.cms_layout.slug |
| - | attributes['cms_blocks_attributes'] = page.cms_blocks_attributes.collect{|b| b.delete(:id) && b.stringify_keys} |
| - | |
| - | open(file_path, 'w') do |f| |
| - | f.write(attributes.to_yaml) |
| - | end |
| - | puts "... Saving page: #{page.label} (#{page.full_path})" |
| - | else |
| - | puts "... Skipping page: #{page.label} (#{page.full_path})" |
| - | end |
| - | end |
| - | end |
| - | |
| - | desc 'Export snippets to yaml files' |
| - | task :snippets => [:environment, :check_for_requirements] do |task, args| |
| - | puts 'Exporting Snippets' |
| - | puts '------------------' |
| - | CmsSnippet.all.each do |snippet| |
| - | should_write = true |
| - | file_path = File.join(@seed_path, 'snippets', "#{snippet.slug}.yml") |
| - | if File.exists?(file_path) |
| - | print "Found snippet fixture: #{file_path} Overwrite? (y/N): " |
| - | should_write = ($stdin.gets.to_s.strip.downcase == 'y') |
| - | end |
| - | if should_write |
| - | attributes = snippet.attributes.slice('label', 'slug', 'content') |
| - | open(file_path, 'w') do |f| |
| - | f.write(attributes.to_yaml) |
| - | end |
| - | puts "... Saving snippet: #{snippet.label} (#{snippet.slug})" |
| - | else |
| - | puts "... Skipping snippet: #{snippet.label} (#{snippet.slug})" |
| - | end |
| - | end |
| - | end |
| - | |
| - | desc 'Export layouts, pages and snippets all in one go' |
| - | task :all => [:layouts, :pages, :snippets] |
| - | |
| - | end |
| - | end |
test/cms_seeds/test.host/layouts/broken.yml
+0
-1
| @@ | @@ -1 +0,0 @@ |
| - | broken yml file |
| \ No newline at end of file | |
test/cms_seeds/test.host/layouts/default.yml
+0
-3
| @@ | @@ -1,3 +0,0 @@ |
| - | label: Default Layout |
| - | slug: default |
| - | content: <html>{{cms:page:content}}</html> |
| \ No newline at end of file | |
test/cms_seeds/test.host/layouts/nested.yml
+0
-4
| @@ | @@ -1,4 +0,0 @@ |
| - | label: Nested Layout |
| - | slug: nested |
| - | parent: default |
| - | content: <div>{{cms:page:content}}</div> |
| \ No newline at end of file | |
test/cms_seeds/test.host/pages/broken.yml
+0
-1
| @@ | @@ -1 +0,0 @@ |
| - | broken yml file |
| \ No newline at end of file | |
test/cms_seeds/test.host/pages/child.yml
+0
-10
| @@ | @@ -1,10 +0,0 @@ |
| - | label: Child Page |
| - | parent: / |
| - | cms_layout: default |
| - | full_path: /child |
| - | slug: child |
| - | cms_blocks_attributes: |
| - | - |
| - | label: content |
| - | content: |- |
| - | Child Page Content |
| \ No newline at end of file | |
test/cms_seeds/test.host/pages/child/subchild.yml
+0
-10
| @@ | @@ -1,10 +0,0 @@ |
| - | label: Child Page |
| - | parent: /child |
| - | cms_layout: nested |
| - | full_path: /child/subchild |
| - | slug: subchild |
| - | cms_blocks_attributes: |
| - | - |
| - | label: content |
| - | content: |- |
| - | Sub Child Page Content {{cms:snippet:default}} |
| \ No newline at end of file | |
test/cms_seeds/test.host/pages/index.yml
+0
-10
| @@ | @@ -1,10 +0,0 @@ |
| - | label: Default Page |
| - | parent: |
| - | cms_layout: default |
| - | full_path: / |
| - | slug: |
| - | cms_blocks_attributes: |
| - | - |
| - | label: content |
| - | content: |- |
| - | Default Page Content |
| \ No newline at end of file | |
test/cms_seeds/test.host/snippets/broken.yml
+0
-1
| @@ | @@ -1 +0,0 @@ |
| - | broken yml file |
| \ No newline at end of file | |
test/cms_seeds/test.host/snippets/default.yml
+0
-3
| @@ | @@ -1,3 +0,0 @@ |
| - | label: Default Snippet |
| - | slug: default |
| - | content: Content for Default Snippet |
| \ No newline at end of file | |
test/integration/rake_tasks_test.rb
+0
-65
| @@ | @@ -1,65 +0,0 @@ |
| - | require File.expand_path('../test_helper', File.dirname(__FILE__)) |
| - | |
| - | require 'rake' |
| - | require 'rake/rdoctask' |
| - | require 'rake/testtask' |
| - | |
| - | Rake.application.rake_require '../lib/tasks/comfortable_mexican_sofa' |
| - | |
| - | class RakeTasksTest < ActionDispatch::IntegrationTest |
| - | |
| - | def test_layouts_import |
| - | CmsLayout.destroy_all |
| - | ComfortableMexicanSofa.configuration.seed_data_path = File.expand_path('../cms_seeds', File.dirname(__FILE__)) |
| - | |
| - | assert_difference 'CmsLayout.count', 2 do |
| - | capture_rake_output{ |
| - | Rake.application['comfortable_mexican_sofa:import:check_for_requirements'].execute( |
| - | :from => 'test.host', :to => 'test.host' ) |
| - | Rake.application['comfortable_mexican_sofa:import:layouts'].execute( |
| - | :from => 'test.host', :to => 'test.host' ) |
| - | } |
| - | end |
| - | end |
| - | |
| - | def test_pages_import |
| - | CmsPage.destroy_all |
| - | ComfortableMexicanSofa.configuration.seed_data_path = File.expand_path('../cms_seeds', File.dirname(__FILE__)) |
| - | |
| - | assert_difference ['CmsPage.count', 'CmsBlock.count'], 3 do |
| - | capture_rake_output{ |
| - | Rake.application['comfortable_mexican_sofa:import:check_for_requirements'].execute( |
| - | :from => 'test.host', :to => 'test.host' ) |
| - | Rake.application['comfortable_mexican_sofa:import:pages'].execute( |
| - | :from => 'test.host', :to => 'test.host' ) |
| - | } |
| - | end |
| - | end |
| - | |
| - | def test_snippets_import |
| - | CmsSnippet.destroy_all |
| - | ComfortableMexicanSofa.configuration.seed_data_path = File.expand_path('../cms_seeds', File.dirname(__FILE__)) |
| - | |
| - | assert_difference 'CmsSnippet.count', 1 do |
| - | capture_rake_output{ |
| - | Rake.application['comfortable_mexican_sofa:import:check_for_requirements'].execute( |
| - | :from => 'test.host', :to => 'test.host' ) |
| - | Rake.application['comfortable_mexican_sofa:import:snippets'].execute( |
| - | :from => 'test.host', :to => 'test.host' ) |
| - | } |
| - | end |
| - | end |
| - | |
| - | protected |
| - | |
| - | def capture_rake_output |
| - | s = StringIO.new |
| - | oldstdout = $stdout |
| - | $stdout = s |
| - | yield |
| - | s.string |
| - | ensure |
| - | $stdout = oldstdout |
| - | end |
| - | |
| - | end |
| \ No newline at end of file | |
test/integration/render_cms_seed_test.rb
+0
-34
| @@ | @@ -1,34 +0,0 @@ |
| - | require File.expand_path('../test_helper', File.dirname(__FILE__)) |
| - | |
| - | class RenderCmsSeedTest < ActionDispatch::IntegrationTest |
| - | |
| - | def test_render_with_seed_data_enabled |
| - | get '/child/subchild' |
| - | assert_response 404 |
| - | |
| - | ComfortableMexicanSofa.configuration.seed_data_path = File.expand_path('../cms_seeds', File.dirname(__FILE__)) |
| - | |
| - | get '/child/subchild' |
| - | assert_response :success |
| - | assert_equal '<html><div>Sub Child Page Content Content for Default Snippet</div></html>', response.body |
| - | end |
| - | |
| - | def test_get_seed_data_page |
| - | ComfortableMexicanSofa.configuration.seed_data_path = File.expand_path('../cms_seeds', File.dirname(__FILE__)) |
| - | |
| - | get '/' |
| - | assert_response :success |
| - | assert assigns(:cms_page) |
| - | assert assigns(:cms_page).new_record? |
| - | end |
| - | |
| - | def test_get_seed_data_css |
| - | ComfortableMexicanSofa.configuration.seed_data_path = File.expand_path('../cms_seeds', File.dirname(__FILE__)) |
| - | |
| - | get '/cms-css/default' |
| - | assert_response :success |
| - | assert assigns(:cms_layout) |
| - | assert assigns(:cms_layout).new_record? |
| - | end |
| - | |
| - | end |
| \ No newline at end of file | |
test/unit/cms_layout_test.rb
+3
-53
| @@ | @@ -9,16 +9,16 @@ class CmsLayoutTest < ActiveSupport::TestCase |
| end | |
| def test_validations | |
| - | layout = CmsLayout.create |
| + | layout = cms_sites(:default).cms_layouts.create |
| assert layout.errors.present? | |
| assert_has_errors_on layout, [:label, :slug, :content] | |
| end | |
| def test_validation_of_tag_presence | |
| - | layout = CmsLayout.create(:content => 'some text') |
| + | layout = cms_sites(:default).cms_layouts.create(:content => 'some text') |
| assert_has_errors_on layout, :content | |
| - | layout = CmsLayout.create(:content => '{cms:snippet:blah}') |
| + | layout = cms_sites(:default).cms_layouts.create(:content => '{cms:snippet:blah}') |
| assert_has_errors_on layout, :content | |
| layout = cms_sites(:default).cms_layouts.new( | |
| @@ | @@ -84,56 +84,6 @@ class CmsLayoutTest < ActiveSupport::TestCase |
| assert_equal '{{cms:page:content}}', child_layout.merged_content | |
| end | |
| - | def test_load_from_file |
| - | assert !CmsLayout.load_from_file(cms_sites(:default), 'default') |
| - | |
| - | ComfortableMexicanSofa.configuration.seed_data_path = File.expand_path('../cms_seeds', File.dirname(__FILE__)) |
| - | |
| - | assert !CmsLayout.load_from_file(cms_sites(:default), 'bogus') |
| - | |
| - | assert layout = CmsLayout.load_from_file(cms_sites(:default), 'default') |
| - | assert_equal 'Default Layout', layout.label |
| - | assert_equal '<html>{{cms:page:content}}</html>', layout.content |
| - | |
| - | assert layout = CmsLayout.load_from_file(cms_sites(:default), 'nested') |
| - | assert_equal 'Nested Layout', layout.label |
| - | assert_equal '<div>{{cms:page:content}}</div>', layout.content |
| - | assert_equal '<html><div>{{cms:page:content}}</div></html>', layout.merged_content |
| - | end |
| - | |
| - | def test_load_from_file_broken |
| - | ComfortableMexicanSofa.configuration.seed_data_path = File.expand_path('../cms_seeds', File.dirname(__FILE__)) |
| - | error_message = "Failed to load from #{ComfortableMexicanSofa.configuration.seed_data_path}/test.host/layouts/broken.yml" |
| - | assert_exception_raised RuntimeError, error_message do |
| - | CmsLayout.load_from_file(cms_sites(:default), 'broken') |
| - | end |
| - | end |
| - | |
| - | def test_load_for_slug |
| - | assert layout = CmsLayout.load_for_slug!(cms_sites(:default), 'default') |
| - | assert !layout.new_record? |
| - | db_content = layout.content |
| - | |
| - | ComfortableMexicanSofa.configuration.seed_data_path = File.expand_path('../cms_seeds', File.dirname(__FILE__)) |
| - | assert layout = CmsLayout.load_for_slug!(cms_sites(:default), 'default') |
| - | assert layout.new_record? |
| - | file_content = layout.content |
| - | assert_not_equal db_content, file_content |
| - | end |
| - | |
| - | def test_load_for_slug_exceptions |
| - | assert_exception_raised ActiveRecord::RecordNotFound, 'CmsLayout with slug: not_found cannot be found' do |
| - | CmsLayout.load_for_slug!(cms_sites(:default), 'not_found') |
| - | end |
| - | assert !CmsLayout.load_for_slug(cms_sites(:default), 'not_found') |
| - | |
| - | ComfortableMexicanSofa.configuration.seed_data_path = File.expand_path('../cms_seeds', File.dirname(__FILE__)) |
| - | assert_exception_raised ActiveRecord::RecordNotFound, 'CmsLayout with slug: not_found cannot be found' do |
| - | CmsLayout.load_for_slug!(cms_sites(:default), 'not_found') |
| - | end |
| - | assert !CmsLayout.load_for_slug(cms_sites(:default), 'not_found') |
| - | end |
| - | |
| def test_update_forces_page_content_reload | |
| layout_1 = cms_layouts(:nested) | |
| layout_2 = cms_layouts(:child) | |
test/unit/cms_page_test.rb
+0
-58
| @@ | @@ -152,64 +152,6 @@ class CmsPageTest < ActiveSupport::TestCase |
| CmsPage.options_for_select(cms_sites(:default), page).collect{|t| t.first } | |
| end | |
| - | def test_load_from_file |
| - | assert !CmsPage.load_from_file(cms_sites(:default), '/') |
| - | |
| - | ComfortableMexicanSofa.configuration.seed_data_path = File.expand_path('../cms_seeds', File.dirname(__FILE__)) |
| - | |
| - | assert !CmsPage.load_from_file(cms_sites(:default), '/bogus') |
| - | |
| - | assert page = CmsPage.load_from_file(cms_sites(:default), '/') |
| - | assert_equal 'Default Page', page.label |
| - | assert_equal 1, page.cms_blocks.size |
| - | assert page.cms_layout |
| - | assert_equal '<html>Default Page Content</html>', page.content |
| - | |
| - | assert page = CmsPage.load_from_file(cms_sites(:default), '/child') |
| - | assert_equal 1, page.cms_blocks.size |
| - | assert page.cms_layout |
| - | assert_equal '<html>Child Page Content</html>', page.content |
| - | |
| - | assert page = CmsPage.load_from_file(cms_sites(:default), '/child/subchild') |
| - | assert_equal 1, page.cms_blocks.size |
| - | assert page.cms_layout |
| - | assert_equal 'Nested Layout', page.cms_layout.label |
| - | assert_equal '<html><div>Sub Child Page Content Content for Default Snippet</div></html>', page.content |
| - | end |
| - | |
| - | def test_load_from_file_broken |
| - | ComfortableMexicanSofa.configuration.seed_data_path = File.expand_path('../cms_seeds', File.dirname(__FILE__)) |
| - | error_message = "Failed to load from #{ComfortableMexicanSofa.configuration.seed_data_path}/test.host/pages/broken.yml" |
| - | assert_exception_raised RuntimeError, error_message do |
| - | CmsPage.load_from_file(cms_sites(:default), '/broken') |
| - | end |
| - | end |
| - | |
| - | def test_load_for_full_path |
| - | assert page = CmsPage.load_for_full_path!(cms_sites(:default), '/') |
| - | assert !page.new_record? |
| - | db_content = page.content |
| - | |
| - | ComfortableMexicanSofa.configuration.seed_data_path = File.expand_path('../cms_seeds', File.dirname(__FILE__)) |
| - | assert page = CmsPage.load_for_full_path!(cms_sites(:default), '/') |
| - | assert page.new_record? |
| - | file_content = page.content |
| - | assert_not_equal db_content, file_content |
| - | end |
| - | |
| - | def test_load_for_full_path_exceptions |
| - | assert_exception_raised ActiveRecord::RecordNotFound, 'CmsPage with path: /invalid_page cannot be found' do |
| - | CmsPage.load_for_full_path!(cms_sites(:default), '/invalid_page') |
| - | end |
| - | assert !CmsPage.load_for_full_path(cms_sites(:default), '/invalid_page') |
| - | |
| - | ComfortableMexicanSofa.configuration.seed_data_path = File.expand_path('../cms_seeds', File.dirname(__FILE__)) |
| - | assert_exception_raised ActiveRecord::RecordNotFound, 'CmsPage with path: /invalid_page cannot be found' do |
| - | CmsPage.load_for_full_path!(cms_sites(:default), '/invalid_page') |
| - | end |
| - | assert !CmsPage.load_for_full_path(cms_sites(:default), '/invalid_page') |
| - | end |
| - | |
| def test_cms_blocks_attributes_accessor | |
| page = cms_pages(:default) | |
| assert_equal page.cms_blocks.count, page.cms_blocks_attributes.size | |
test/unit/cms_snippet_test.rb
+0
-45
| @@ | @@ -20,51 +20,6 @@ class CmsSnippetTest < ActiveSupport::TestCase |
| assert_equal '', CmsSnippet.content_for('nonexistent_snippet') | |
| end | |
| - | def test_load_from_file |
| - | assert !CmsSnippet.load_from_file(cms_sites(:default), 'default') |
| - | |
| - | ComfortableMexicanSofa.configuration.seed_data_path = File.expand_path('../cms_seeds', File.dirname(__FILE__)) |
| - | |
| - | assert !CmsSnippet.load_from_file(cms_sites(:default), 'bogus') |
| - | |
| - | assert snippet = CmsSnippet.load_from_file(cms_sites(:default), 'default') |
| - | assert_equal 'Default Snippet', snippet.label |
| - | assert_equal 'Content for Default Snippet', snippet.content |
| - | end |
| - | |
| - | def test_load_from_file_broken |
| - | ComfortableMexicanSofa.configuration.seed_data_path = File.expand_path('../cms_seeds', File.dirname(__FILE__)) |
| - | error_message = "Failed to load from #{ComfortableMexicanSofa.configuration.seed_data_path}/test.host/snippets/broken.yml" |
| - | assert_exception_raised RuntimeError, error_message do |
| - | CmsSnippet.load_from_file(cms_sites(:default), 'broken') |
| - | end |
| - | end |
| - | |
| - | def test_load_for_slug |
| - | assert snippet = CmsSnippet.load_for_slug!(cms_sites(:default), 'default') |
| - | assert !snippet.new_record? |
| - | db_content = snippet.content |
| - | |
| - | ComfortableMexicanSofa.configuration.seed_data_path = File.expand_path('../cms_seeds', File.dirname(__FILE__)) |
| - | assert snippet = CmsSnippet.load_for_slug!(cms_sites(:default), 'default') |
| - | assert snippet.new_record? |
| - | file_content = snippet.content |
| - | assert_not_equal db_content, file_content |
| - | end |
| - | |
| - | def test_load_for_slug_exceptions |
| - | assert_exception_raised ActiveRecord::RecordNotFound, 'CmsSnippet with slug: not_found cannot be found' do |
| - | CmsSnippet.load_for_slug!(cms_sites(:default), 'not_found') |
| - | end |
| - | assert !CmsSnippet.load_for_slug(cms_sites(:default), 'not_found') |
| - | |
| - | ComfortableMexicanSofa.configuration.seed_data_path = File.expand_path('../cms_seeds', File.dirname(__FILE__)) |
| - | assert_exception_raised ActiveRecord::RecordNotFound, 'CmsSnippet with slug: not_found cannot be found' do |
| - | CmsSnippet.load_for_slug!(cms_sites(:default), 'not_found') |
| - | end |
| - | assert !CmsSnippet.load_for_slug(cms_sites(:default), 'not_found') |
| - | end |
| - | |
| def test_update_forces_page_content_reload | |
| snippet = cms_snippets(:default) | |
| page = cms_pages(:default) | |
test/unit/cms_tag_test.rb
+2
-2
| @@ | @@ -97,7 +97,7 @@ class CmsTagTest < ActiveSupport::TestCase |
| end | |
| def test_content_for_new_page_with_layout | |
| - | page = CmsPage.new(:cms_layout => cms_layouts(:default)) |
| + | page = cms_sites(:default).cms_pages.new(:cms_layout => cms_layouts(:default)) |
| assert page.cms_blocks.blank? | |
| assert page.cms_tags.blank? | |
| assert_equal rendered_content_formatter( | |
| @@ | @@ -116,7 +116,7 @@ class CmsTagTest < ActiveSupport::TestCase |
| end | |
| def test_content_for_new_page_with_initilized_cms_blocks | |
| - | page = CmsPage.new(:cms_layout => cms_layouts(:default)) |
| + | page = cms_sites(:default).cms_pages.new(:cms_layout => cms_layouts(:default)) |
| assert page.cms_blocks.blank? | |
| assert page.cms_tags.blank? | |
| page.cms_blocks_attributes = [ | |
test/unit/view_methods_test.rb
+2
-2
| @@ | @@ -5,8 +5,8 @@ class ViewMethodsTest < ActiveSupport::TestCase |
| include ComfortableMexicanSofa::ViewMethods | |
| def test_cms_snippet_content | |
| - | assert_equal 'default_snippet_content', cms_snippet_content('default') |
| - | assert_equal '', cms_snippet_content('not_found') |
| + | assert_equal 'default_snippet_content', cms_snippet_content('default', cms_sites(:default)) |
| + | assert_equal '', cms_snippet_content('not_found', cms_sites(:default)) |
| end | |
| def test_cms_page_content | |