Skip to content

Instantly share code, notes, and snippets.

@masterkain
Created June 19, 2011 04:04
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 masterkain/1033747 to your computer and use it in GitHub Desktop.
Save masterkain/1033747 to your computer and use it in GitHub Desktop.
class ApplicationController < ActionController::Base
protect_from_forgery
layout Proc.new { |controller| controller.request.xhr? ? 'ajax' : 'test' }
end
Failures:
1) StoresController GET render_implicit_html_template_from_xhr_request with XHR should render the ajax layout
Failure/Error: response.should render_template("layouts/ajax")
Expected block to return true value.
# ./spec/controllers/stores_controller_spec.rb:29:in `block (3 levels) in <top (required)>'
Finished in 0.35621 seconds
3 examples, 1 failure
class StoresController < ApplicationController
# Layout inheritance is not working.
# Please see https://github.com/rails/rails/issues/1685
# layout Proc.new { |controller| controller.request.xhr? ? 'ajax' : 'application' }
def render_implicit_html_template_from_xhr_request
end
end
require "spec_helper"
describe StoresController do
include Devise::TestHelpers
render_views
before (:each) do
@user = Factory.create(:user)
sign_in @user
end
context "GET render_implicit_html_template_from_xhr_request with XHR" do
before(:each) do
xhr :get, :render_implicit_html_template_from_xhr_request
end
it {should respond_with :success }
it {should render_template(:render_implicit_html_template_from_xhr_request) }
it "should render the ajax layout" do
response.should render_template("layouts/ajax") # fails
# response.should render_template("layouts/test") # passes
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment