Skip to content

Instantly share code, notes, and snippets.

@raviolicode
Created June 18, 2011 01:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save raviolicode/1032704 to your computer and use it in GitHub Desktop.
Save raviolicode/1032704 to your computer and use it in GitHub Desktop.
require 'abstract_unit'
class ParentController < ActionController::Base
protect_from_forgery
layout Proc.new { |controller| controller.request.xhr? ? '/layouts/xhr' : '/layouts/standard' }
end
class ChildController < ParentController
def render_implicit_html_template_from_xhr_request
render :template => "test/hello_world"
end
end
class RenderChildControllerTest < ActionController::TestCase
tests ChildController
def test_should_render_xhr_template_from_inherited_proc
xhr :get, :render_implicit_html_template_from_xhr_request
assert_equal "XHR!\nHello world!", @response.body
end
def test_should_render_standard_template_on_get_request
get :render_implicit_html_template_from_xhr_request
assert_equal "<html>Hello world!</html>", @response.body
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment