From 4939017f8d114a6b7c191dd76141ed6274814265 Mon Sep 17 00:00:00 2001 From: Mario Visic Date: Sat, 29 Oct 2011 14:35:23 +0800 Subject: [PATCH] No Site now renders a 404 error, this will prevent indexing of pages that do not exist. --- lib/locomotive/routing/site_dispatcher.rb | 2 +- spec/lib/locomotive/routing/site_dispatcher_spec.rb | 12 ++++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/lib/locomotive/routing/site_dispatcher.rb b/lib/locomotive/routing/site_dispatcher.rb index 7405be1d..186a5630 100644 --- a/lib/locomotive/routing/site_dispatcher.rb +++ b/lib/locomotive/routing/site_dispatcher.rb @@ -39,7 +39,7 @@ module Locomotive end def render_no_site_error - render :template => '/admin/errors/no_site', :layout => false + render :template => '/admin/errors/no_site', :layout => false, :status => :not_found end def validate_site_membership diff --git a/spec/lib/locomotive/routing/site_dispatcher_spec.rb b/spec/lib/locomotive/routing/site_dispatcher_spec.rb index 6b4a4c6f..43802192 100644 --- a/spec/lib/locomotive/routing/site_dispatcher_spec.rb +++ b/spec/lib/locomotive/routing/site_dispatcher_spec.rb @@ -147,11 +147,19 @@ describe Locomotive::Routing::SiteDispatcher do describe '#render_no_site_error' do - it 'renders the no site template with no layout' do - @controller.expects(:render).with(:template => '/admin/errors/no_site', :layout => false) + before :each do + @controller.instance_variable_set('@_response', ActionDispatch::Response.new) @controller.send(:render_no_site_error) end + it 'should have a no site error message' do + @controller.response.body.should include 'No Site' + end + + it 'should have a 404 not found status' do + @controller.response.should be_not_found + end + end describe '#validate_site_membership' do