Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

index pages #27

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions app/controllers/high_voltage/pages_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 9 additions & 0 deletions spec/controllers/pages_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions spec/dummy/app/views/pages/dir/index.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
hello <%= 'world' %> from index page