fixtures get loaded only within appropriate controllers, better logging

Oleg committed Jan 03, 2012
commit 3cb046f0a7f6e60d8f93c5120e66e43dbccffe67
Showing 2 changed files with 7 additions and 7 deletions
app/controllers/cms_admin/base_controller.rb +1 -1
@@ @@ -32,8 +32,8 @@ protected
def load_fixtures
return unless ComfortableMexicanSofa.config.enable_fixtures
- ComfortableMexicanSofa::Fixtures.import_all(@site.hostname)
if %w(cms_admin/layouts cms_admin/pages cms_admin/snippets).member?(params[:controller])
+ ComfortableMexicanSofa::Fixtures.import_all(@site.hostname)
flash.now[:error] = I18n.t('cms.base.fixtures_enabled')
end
end
comfortable_mexican_sofa/fixtures.rb b/lib/comfortable_mexican_sofa/fixtures.rb +6 -6
@@ @@ -15,7 +15,7 @@ module ComfortableMexicanSofa::Fixtures
def self.import_layouts(to_hostname, from_hostname = nil, path = nil, root = true, parent = nil, layout_ids = [])
site = Cms::Site.find_or_create_by_hostname(to_hostname)
unless path ||= find_fixtures_path((from_hostname || to_hostname), 'layouts')
- $stderr.puts 'Cannot find fixtures'
+ $stdout.puts 'Cannot find Layout fixtures'
return
end
@@ @@ -58,7 +58,7 @@ module ComfortableMexicanSofa::Fixtures
if layout.save
$stdout.puts "[Fixtures] Saved Layout {#{layout.identifier}}"
else
- $stderr.puts "[Fixtures] Failed to save Layout {#{layout.errors.inspect}}"
+ $stdout.puts "[Fixtures] Failed to save Layout {#{layout.errors.inspect}}"
end
end
layout_ids << layout.id
@@ @@ -80,7 +80,7 @@ module ComfortableMexicanSofa::Fixtures
def self.import_pages(to_hostname, from_hostname = nil, path = nil, root = true, parent = nil, page_ids = [])
site = Cms::Site.find_or_create_by_hostname(to_hostname)
unless path ||= find_fixtures_path((from_hostname || to_hostname), 'pages')
- $stderr.puts 'Cannot find fixtures'
+ $stdout.puts 'Cannot find Page fixtures'
return
end
@@ @@ -124,7 +124,7 @@ module ComfortableMexicanSofa::Fixtures
if page.save
$stdout.puts "[Fixtures] Saved Page {#{page.full_path}}"
else
- $stderr.puts "[Fixtures] Failed to save Page {#{page.errors.inspect}}"
+ $stdout.puts "[Fixtures] Failed to save Page {#{page.errors.inspect}}"
end
end
page_ids << page.id
@@ @@ -146,7 +146,7 @@ module ComfortableMexicanSofa::Fixtures
def self.import_snippets(to_hostname, from_hostname = nil)
site = Cms::Site.find_or_create_by_hostname(to_hostname)
unless path = find_fixtures_path((from_hostname || to_hostname), 'snippets')
- $stdout.puts 'Cannot find fixtures'
+ $stdout.puts 'Cannot find Snippet fixtures'
return
end
@@ @@ -177,7 +177,7 @@ module ComfortableMexicanSofa::Fixtures
if snippet.save
$stdout.puts "[Fixtures] Saved Snippet {#{snippet.identifier}}"
else
- $stderr.puts "[Fixtures] Failed to save Snippet {#{snippet.errors.inspect}}"
+ $stdout.puts "[Fixtures] Failed to save Snippet {#{snippet.errors.inspect}}"
end
end
snippet_ids << snippet.id