Skip to content

Instantly share code, notes, and snippets.

@d11wtq
Created September 18, 2011 06:40
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 d11wtq/1224809 to your computer and use it in GitHub Desktop.
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
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