Skip to content

Commit

Permalink
do not render layout in xhr request
Browse files Browse the repository at this point in the history
  • Loading branch information
Artem Biserov authored and vast committed Oct 10, 2013
1 parent a1561f5 commit 0ba6468
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/controllers/api_taster/application_controller.rb
Original file line number Diff line number Diff line change
@@ -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

Expand Down
20 changes: 20 additions & 0 deletions spec/controllers/api_taster/routes_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 0ba6468

Please sign in to comment.