fixtures are loading in admin area as well

Oleg committed May 16, 2011
commit 944eddbb64b042173213ab37be18c28de33c7eba
Showing 2 changed files with 26 additions and 1 deletions
app/controllers/cms_admin/base_controller.rb +8 -1
@@ @@ -6,7 +6,8 @@ class CmsAdmin::BaseController < ApplicationController
include ComfortableMexicanSofa.config.authentication.to_s.constantize
before_filter :authenticate,
- :load_admin_cms_site
+ :load_admin_cms_site,
+ :load_fixtures
layout 'cms_admin'
@@ @@ -31,4 +32,10 @@ protected
return redirect_to(cms_admin_sites_path)
end
end
+
+ def load_fixtures
+ return unless ComfortableMexicanSofa.config.enable_fixtures
+ ComfortableMexicanSofa::Fixtures.sync(@cms_site)
+ flash.now[:error] = 'CMS Fixtures are enabled. All changes done here will be discarded.'
+ end
end
test/integration/fixtures_test.rb +18 -0
@@ @@ -40,4 +40,22 @@ class FixturesTest < ActionDispatch::IntegrationTest
end
end
+ def test_fixtures_enabled_in_admin
+ ComfortableMexicanSofa.config.enable_fixtures = true
+ Cms::Layout.destroy_all
+ Cms::Page.destroy_all
+ Cms::Snippet.destroy_all
+
+ assert_difference 'Cms::Page.count', 2 do
+ assert_difference 'Cms::Layout.count', 2 do
+ assert_difference 'Cms::Snippet.count', 1 do
+ http_auth :get, '/cms-admin/pages'
+ assert_response :success
+ assert_equal 'CMS Fixtures are enabled. All changes done here will be discarded.', flash[:error]
+ end
+ end
+ end
+
+ end
+
end
\ No newline at end of file