Permalink
Browse files

raise original exception instead of routing error when a static page …

…exists but attempts to render a nonexistent partial
  • Loading branch information...
1 parent 50918c3 commit 7132e091c347585aeb306aee7aa2401fd67bf1f0 @jdewyea jdewyea committed Feb 26, 2011
@@ -2,18 +2,20 @@ class HighVoltage::PagesController < ApplicationController
unloadable
- rescue_from ActionView::MissingTemplate, :with => :invalid_page
+ rescue_from ActionView::MissingTemplate do |exception|
+ if exception.message =~ %r{Missing template pages/}
+ raise ActionController::RoutingError, "No such page: #{params[:id]}"
+ else
+ raise exception
+ end
+ end
def show
render :template => current_page
end
protected
- def invalid_page
- raise ActionController::RoutingError, "No such page: #{params[:id]}"
- end
-
def current_page
"pages/#{params[:id].to_s.downcase}"
end
@@ -0,0 +1,2 @@
+hello <%= 'world' %>
+<%= render 'nonexistent' %>
@@ -17,4 +17,9 @@ class HighVoltage::PagesControllerTest < ActionController::TestCase
end
end
+ should "raise missing template error for valid page with invalid partial" do
+ assert_raise ActionView::MissingTemplate do
+ get :show, :id => "exists_but_references_nonexistent_partial"
+ end
+ end
end

0 comments on commit 7132e09

Please sign in to comment.