Permalink
Browse files

do not render layout in xhr request

  • Loading branch information...
1 parent a1561f5 commit 0ba64689386dfc7fd6b0d77223c8f55f2a556a01 @artembiserov artembiserov committed with vast Oct 7, 2013
@@ -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
@@ -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.