index pages #27

Closed
wants to merge 2 commits into
from
@@ -5,8 +5,12 @@ class HighVoltage::PagesController < ApplicationController
rescue_from ActionView::MissingTemplate do |exception|
if exception.message =~ %r{Missing template #{HighVoltage::content_path}}
- raise ActionController::RoutingError, "No such page: #{params[:id]}"
- else
+ begin
+ render :template => "#{current_page}/index", :layout => HighVoltage::layout
+ rescue ActionView::MissingTemplate => e
+ raise ActionController::RoutingError, "No such page: #{params[:id]}"
+ end
+ else
raise exception
end
end
@@ -28,6 +28,15 @@
end
end
+ describe "on GET to /pages/dir" do
+ before { get :show, :id => 'dir' }
+
+ it "should respond with success and render index template" do
+ response.should be_success
+ response.should render_template('pages/dir/index')
+ end
+ end
+
it "should raise a routing error for an invalid page" do
lambda { get :show, :id => "invalid" }.should raise_error(ActionController::RoutingError)
end
@@ -0,0 +1 @@
+hello <%= 'world' %> from index page