setting up my own error class. fixes #52

Oleg committed May 26, 2011
commit 7a7170fb08d5a4ad4a96bce28891ed1865683cd0
Showing 5 changed files with 24 additions and 9 deletions
comfortable_mexican_sofa.gemspec +9 -6
@@ @@ -9,7 +9,7 @@ Gem::Specification.new do |s|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.authors = ["Oleg Khabarov", "The Working Group Inc"]
- s.date = %q{2011-05-24}
+ s.date = %q{2011-05-25}
s.description = %q{}
s.email = %q{oleg@theworkinggroup.ca}
s.extra_rdoc_files = [
@@ @@ -23,6 +23,13 @@ Gem::Specification.new do |s|
"README.md",
"Rakefile",
"VERSION",
+ "app/assets/javascripts/comfortable_mexican_sofa/application.js",
+ "app/assets/stylesheets/comfortable_mexican_sofa/application.css",
+ "app/assets/stylesheets/comfortable_mexican_sofa/content.css",
+ "app/assets/stylesheets/comfortable_mexican_sofa/form.css",
+ "app/assets/stylesheets/comfortable_mexican_sofa/reset.css",
+ "app/assets/stylesheets/comfortable_mexican_sofa/structure.css",
+ "app/assets/stylesheets/comfortable_mexican_sofa/typography.css",
"app/controllers/application_controller.rb",
"app/controllers/cms_admin/base_controller.rb",
"app/controllers/cms_admin/layouts_controller.rb",
@@ @@ -71,6 +78,7 @@ Gem::Specification.new do |s|
"app/views/layouts/cms_admin/_head.html.erb",
"app/views/layouts/cms_admin/_left.html.erb",
"app/views/layouts/cms_admin/_right.html.erb",
+ "comfortable_mexican_sofa.gemspec",
"config.ru",
"config/application.rb",
"config/boot.rb",
@@ @@ -205,11 +213,6 @@ Gem::Specification.new do |s|
"public/javascripts/comfortable_mexican_sofa/tiny_mce/tiny_mce.js",
"public/javascripts/comfortable_mexican_sofa/tiny_mce/tiny_mce_popup.js",
"public/robots.txt",
- "public/stylesheets/comfortable_mexican_sofa/content.css",
- "public/stylesheets/comfortable_mexican_sofa/form.css",
- "public/stylesheets/comfortable_mexican_sofa/reset.css",
- "public/stylesheets/comfortable_mexican_sofa/structure.css",
- "public/stylesheets/comfortable_mexican_sofa/typography.css",
"script/rails",
"test/fixtures/cms/blocks.yml",
"test/fixtures/cms/layouts.yml",
comfortable_mexican_sofa.rb b/lib/comfortable_mexican_sofa.rb +1 -0
@@ @@ -4,6 +4,7 @@ unless defined? ComfortableMexicanSofa::Application
end
[ 'comfortable_mexican_sofa/version',
+ 'comfortable_mexican_sofa/error',
'comfortable_mexican_sofa/configuration',
'comfortable_mexican_sofa/http_auth',
'comfortable_mexican_sofa/rails_extensions',
comfortable_mexican_sofa/controller_methods.rb b/lib/comfortable_mexican_sofa/controller_methods.rb +2 -2
@@ @@ -8,7 +8,7 @@ module ComfortableMexicanSofa::ControllerMethods
base.rescue_from 'ActionView::MissingTemplate' do |e|
begin
render :cms_page => request.path
- rescue ActionView::MissingTemplate
+ rescue ComfortableMexicanSofa::MissingPage
raise e
end
end
@@ @@ -29,7 +29,7 @@ module ComfortableMexicanSofa::ControllerMethods
@cms_page = page
super(options, locals, &block)
else
- raise ActionView::MissingTemplate.new([path], path, "CMS page not found", nil)
+ raise ComfortableMexicanSofa::MissingPage.new(path)
end
else
super(options, locals, &block)
comfortable_mexican_sofa/error.rb b/lib/comfortable_mexican_sofa/error.rb +11 -0
@@ @@ -0,0 +1,11 @@
+ module ComfortableMexicanSofa
+
+ class Error < StandardError
+ end
+
+ class MissingPage < ComfortableMexicanSofa::Error
+ def initialize(path)
+ super "Cannot find CMS page at #{path}"
+ end
+ end
+ end
\ No newline at end of file
test/integration/render_cms_test.rb +1 -1
@@ @@ -59,7 +59,7 @@ class RenderCmsTest < ActionDispatch::IntegrationTest
page = cms_pages(:child)
page.slug = 'render-explicit-404'
page.save!
- assert_exception_raised ActionView::MissingTemplate do
+ assert_exception_raised ComfortableMexicanSofa::MissingPage do
get '/render-explicit'
end
end