Skip to content

Commit

Permalink
setting up my own error class. fixes comfy#52
Browse files Browse the repository at this point in the history
  • Loading branch information
Oleg committed May 26, 2011
1 parent 0dda25e commit 7a7170f
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 9 deletions.
15 changes: 9 additions & 6 deletions comfortable_mexican_sofa.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand All @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
1 change: 1 addition & 0 deletions lib/comfortable_mexican_sofa.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
end

[ 'comfortable_mexican_sofa/version',
'comfortable_mexican_sofa/error',
'comfortable_mexican_sofa/configuration',
'comfortable_mexican_sofa/http_auth',
'comfortable_mexican_sofa/rails_extensions',
Expand Down
4 changes: 2 additions & 2 deletions lib/comfortable_mexican_sofa/controller_methods.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ def self.included(base)
base.rescue_from 'ActionView::MissingTemplate' do |e|
begin
render :cms_page => request.path
rescue ActionView::MissingTemplate
rescue ComfortableMexicanSofa::MissingPage
raise e
end
end
Expand All @@ -29,7 +29,7 @@ def render(options = {}, locals = {}, &block)
@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)
Expand Down
11 changes: 11 additions & 0 deletions lib/comfortable_mexican_sofa/error.rb
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion test/integration/render_cms_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def test_get_with_explicit_cms_template_failure
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
Expand Down

0 comments on commit 7a7170f

Please sign in to comment.