diff --git a/app/controllers/api_taster/application_controller.rb b/app/controllers/api_taster/application_controller.rb index d5654d9..76f491c 100644 --- a/app/controllers/api_taster/application_controller.rb +++ b/app/controllers/api_taster/application_controller.rb @@ -1,6 +1,6 @@ module ApiTaster class ApplicationController < ActionController::Base - layout proc { |controller| controller.request.xhr? ? nil : 'api_taster/application' } + layout proc { |controller| controller.request.xhr? ? false : 'api_taster/application' } before_filter :reload_routes diff --git a/spec/controllers/api_taster/routes_controller_spec.rb b/spec/controllers/api_taster/routes_controller_spec.rb index 87c8bc2..7c09df9 100644 --- a/spec/controllers/api_taster/routes_controller_spec.rb +++ b/spec/controllers/api_taster/routes_controller_spec.rb @@ -41,5 +41,25 @@ module ApiTaster assigns(:obsolete_definitions).should be_kind_of(Array) end + + context 'layout' do + context 'when request is not XHR' do + it 'renders application layout' do + get :index, :use_route => :api_taster + + response.should render_template('api_taster/application') + end + end + + context 'when request is XHR' do + before { request.stub(:xhr?) { true } } + + it 'does not render layout' do + get :index, :use_route => :api_taster + + response.should_not render_template('api_taster/application') + end + end + end end end