Created
September 18, 2011 06:40
-
-
Save d11wtq/1224809 to your computer and use it in GitHub Desktop.
Showing the current Rails 3.1 bug where generating a new session Set-Cookie header crashes Rack if :domain => :all
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'spec_helper' | |
class AbstractStoreSubclass < ActionDispatch::Session::AbstractStore | |
def get_session(env, sid) | |
[sid || generate_sid, nil] | |
end | |
def set_session(env, sid, data, options) | |
end | |
def destroy_session(env, sid, options) | |
end | |
end | |
describe AbstractStoreSubclass do | |
let(:response) { [200, {}, ""] } | |
let(:app) { stub(:app, :call => response) } | |
let(:host) { "site.com" } | |
let(:env) do | |
{ | |
"HTTP_HOST" => host | |
} | |
end | |
let(:options) do | |
{ | |
:ttl => 12.hours, | |
:domain => "site.com", | |
:key => "SID" | |
} | |
end | |
let(:store) { AbstractStoreSubclass.new(app, options) } | |
let(:session) { env["rack.session"] } | |
describe "writing" do | |
context "without a session id" do | |
before(:each) do | |
app.stub(:call) { session[:a] = "b"; response } | |
end | |
it "generates a new session id" do | |
store.call(env) | |
env["rack.session.options"][:id].should_not be_nil | |
end | |
describe "using an :all domain" do | |
before(:each) do | |
options[:domain] = :all | |
end | |
it "does not crash Rack" do | |
store.call(env) | |
end | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment