Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Tree: c6964f7e7b
Fetching contributors…

Cannot retrieve contributors at this time

106 lines (79 sloc) 3.345 kB
require 'spec_helper'
describe HighVoltage::PagesController do
render_views
context "using default configuration" do
describe "on GET to /pages/exists" do
before { get :show, :id => 'exists' }
it "should respond with success and render template" do
response.should be_success
response.should render_template('exists')
end
it "should use the default layout used by ApplicationController" do
response.should render_template("layouts/application")
end
end
describe "on GET to /pages/dir/nested" do
before { get :show, :id => 'dir/nested' }
it "should respond with success and render template" do
response.should be_success
response.should render_template('pages/dir/nested')
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
it "should raise a routing error for a page in another directory" do
lambda { get :show, :id => "../other/wrong" }.should raise_error(ActionController::RoutingError)
end
it "should raise missing template error for valid page with invalid partial" do
lambda { get :show, :id => "exists_but_references_nonexistent_partial" }.should raise_error(ActionView::MissingTemplate)
end
end
context "using custom layout" do
before(:all) do
HighVoltage::layout = "alternate"
end
describe "on GET to /pages/exists" do
before { get :show, :id => "exists" }
it "should use the custom configured layout" do
response.should_not render_template("layouts/application")
response.should render_template("layouts/alternate")
end
end
end
context "using custom content path" do
before(:all) do
HighVoltage::content_path = "other_pages/"
end
describe "on GET to /other_pages/also_exists" do
before { get :show, :id => 'also_exists' }
it "should respond with success and render template" do
response.should be_success
response.should render_template('other_pages/also_exists')
end
end
describe "on GET to /other_pages/also_dir/nested" do
before { get :show, :id => 'also_dir/also_nested' }
it "should respond with success and render template" do
response.should be_success
response.should render_template('other_pages/also_dir/also_nested')
end
end
it "should raise a routing error for an invalid page" do
lambda { get :show, :id => "also_invalid" }.should raise_error(ActionController::RoutingError)
end
it "should raise a routing error for a page in another directory" do
lambda { get :show, :id => "../other/wrong" }.should raise_error(ActionController::RoutingError)
end
it "should raise missing template error for valid page with invalid partial" do
lambda { get :show, :id => "also_exists_but_references_nonexistent_partial" }.should raise_error(ActionView::MissingTemplate)
end
end
end
Jump to Line
Something went wrong with that request. Please try again.