Skip to content

Instantly share code, notes, and snippets.

@agibralter
Created September 9, 2008 18:04
Show Gist options
  • Save agibralter/9727 to your computer and use it in GitHub Desktop.
Save agibralter/9727 to your computer and use it in GitHub Desktop.
WHERE THE HELL IS E2's remember me coming from!??!?!? (last line)
E 1: {"test_ls"=>"TUEukYXutyX4CnrjckGjYw%3D%3D--2aa4c5c7df094842a0ee60107f1ff444496e78a1", "test_session"=>"BAh7CjoOeF9zZXNzaW9uewg6GGFub255bW91c19yX3Nlc3Npb25GOhFyX3Nl%0Ac3Npb25faWRpAnE8OhFsX3Nlc3Npb25faWRpAoE7Og1xdWVzdGlvbnsHOwlp%0AAtQtOgxhbnN3ZXJzWwhpAnqJaQJ7iWkCfIk6CXVzZXJpAgcQOg5yZXR1cm5f%0AdG8wIgpmbGFzaElDOidBY3Rpb25Db250cm9sbGVyOjpGbGFzaDo6Rmxhc2hI%0AYXNoewAGOgpAdXNlZHsA--5ea2ecb92e6706a4335241a853a86889a0203489"}
A 1: {"test_ls"=>["TUEukYXutyX4CnrjckGjYw==--2aa4c5c7df094842a0ee60107f1ff444496e78a1"], "test_session"=>["BAh7CjoOeF9zZXNzaW9uewg6GGFub255bW91c19yX3Nlc3Npb25GOhFyX3Nl\nc3Npb25faWRpAnE8OhFsX3Nlc3Npb25faWRpAoE7Og1xdWVzdGlvbnsHOwlp\nAtQtOgxhbnN3ZXJzWwhpAnqJaQJ7iWkCfIk6CXVzZXJpAgcQOg5yZXR1cm5f\ndG8wIgpmbGFzaElDOidBY3Rpb25Db250cm9sbGVyOjpGbGFzaDo6Rmxhc2hI\nYXNoewAGOgpAdXNlZHsA--5ea2ecb92e6706a4335241a853a86889a0203489"]}
B 1: {"test_ls"=>["TUEukYXutyX4CnrjckGjYw==--2aa4c5c7df094842a0ee60107f1ff444496e78a1"], "test_session"=>["BAh7CjoOeF9zZXNzaW9uewg6GGFub255bW91c19yX3Nlc3Npb25GOhFyX3Nl\nc3Npb25faWRpAnE8OhFsX3Nlc3Npb25faWRpAoE7Og1xdWVzdGlvbnsHOwlp\nAtQtOgxhbnN3ZXJzWwhpAnqJaQJ7iWkCfIk6CXVzZXJpAgcQOg5yZXR1cm5f\ndG8wIgpmbGFzaElDOidBY3Rpb25Db250cm9sbGVyOjpGbGFzaDo6Rmxhc2hI\nYXNoewAGOgpAdXNlZHsA--5ea2ecb92e6706a4335241a853a86889a0203489"]}
C 1: {"test_ls"=>["TUEukYXutyX4CnrjckGjYw==--2aa4c5c7df094842a0ee60107f1ff444496e78a1"], "test_session"=>["BAh7CjoOeF9zZXNzaW9uewg6GGFub255bW91c19yX3Nlc3Npb25GOhFyX3Nl\nc3Npb25faWRpAnE8OhFsX3Nlc3Npb25faWRpAoE7Og1xdWVzdGlvbnsHOwlp\nAtQtOgxhbnN3ZXJzWwhpAnqJaQJ7iWkCfIk6CXVzZXJpAgcQOg5yZXR1cm5f\ndG8wIgpmbGFzaElDOidBY3Rpb25Db250cm9sbGVyOjpGbGFzaDo6Rmxhc2hI\nYXNoewAGOgpAdXNlZHsA--5ea2ecb92e6706a4335241a853a86889a0203489"]}
C 2: {"test_ls"=>["TUEukYXutyX4CnrjckGjYw==--2aa4c5c7df094842a0ee60107f1ff444496e78a1"], "test_session"=>["BAh7CjoOeF9zZXNzaW9uewg6GGFub255bW91c19yX3Nlc3Npb25GOhFyX3Nl\nc3Npb25faWRpAnE8OhFsX3Nlc3Npb25faWRpAoE7Og1xdWVzdGlvbnsHOwlp\nAtQtOgxhbnN3ZXJzWwhpAnqJaQJ7iWkCfIk6CXVzZXJpAgcQOg5yZXR1cm5f\ndG8wIgpmbGFzaElDOidBY3Rpb25Db250cm9sbGVyOjpGbGFzaDo6Rmxhc2hI\nYXNoewAGOgpAdXNlZHsA--5ea2ecb92e6706a4335241a853a86889a0203489"]}
B 2: {"test_ls"=>["TUEukYXutyX4CnrjckGjYw==--2aa4c5c7df094842a0ee60107f1ff444496e78a1"], "test_session"=>["BAh7CjoOeF9zZXNzaW9uewg6GGFub255bW91c19yX3Nlc3Npb25GOhFyX3Nl\nc3Npb25faWRpAnE8OhFsX3Nlc3Npb25faWRpAoE7Og1xdWVzdGlvbnsHOwlp\nAtQtOgxhbnN3ZXJzWwhpAnqJaQJ7iWkCfIk6CXVzZXJpAgcQOg5yZXR1cm5f\ndG8wIgpmbGFzaElDOidBY3Rpb25Db250cm9sbGVyOjpGbGFzaDo6Rmxhc2hI\nYXNoewAGOgpAdXNlZHsA--5ea2ecb92e6706a4335241a853a86889a0203489"]}
A 2: {"test_ls"=>["TUEukYXutyX4CnrjckGjYw==--2aa4c5c7df094842a0ee60107f1ff444496e78a1"], "test_session"=>["BAh7CjoOeF9zZXNzaW9uewg6GGFub255bW91c19yX3Nlc3Npb25GOhFyX3Nl\nc3Npb25faWRpAnE8OhFsX3Nlc3Npb25faWRpAoE7Og1xdWVzdGlvbnsHOwlp\nAtQtOgxhbnN3ZXJzWwhpAnqJaQJ7iWkCfIk6CXVzZXJpAgcQOg5yZXR1cm5f\ndG8wIgpmbGFzaElDOidBY3Rpb25Db250cm9sbGVyOjpGbGFzaDo6Rmxhc2hI\nYXNoewAGOgpAdXNlZHsA--5ea2ecb92e6706a4335241a853a86889a0203489"]}
A 3: {"test_ls"=>["TUEukYXutyX4CnrjckGjYw==--2aa4c5c7df094842a0ee60107f1ff444496e78a1"], "test_session"=>["BAh7CjoOeF9zZXNzaW9uewg6GGFub255bW91c19yX3Nlc3Npb25GOhFyX3Nl\nc3Npb25faWRpAnE8OhFsX3Nlc3Npb25faWRpAoE7Og1xdWVzdGlvbnsHOwlp\nAtQtOgxhbnN3ZXJzWwhpAnqJaQJ7iWkCfIk6CXVzZXJpAgcQOg5yZXR1cm5f\ndG8wIgpmbGFzaElDOidBY3Rpb25Db250cm9sbGVyOjpGbGFzaDo6Rmxhc2hI\nYXNoewAGOgpAdXNlZHsA--5ea2ecb92e6706a4335241a853a86889a0203489"]}
E 2: {"test_ls"=>"TUEukYXutyX4CnrjckGjYw%3D%3D--2aa4c5c7df094842a0ee60107f1ff444496e78a1", "remember_me"=>"", "test_session"=>"BAh7CjoNcXVlc3Rpb257BzsAaQLULToMYW5zd2Vyc1sIaQJ6iWkCe4lpAnyJ%0AOg54X3Nlc3Npb257CDoYYW5vbnltb3VzX3Jfc2Vzc2lvbkY6EXJfc2Vzc2lv%0Abl9pZGkCcTw6EWxfc2Vzc2lvbl9pZGkCgTs6CXVzZXJpAgcQIgpmbGFzaElD%0AOidBY3Rpb25Db250cm9sbGVyOjpGbGFzaDo6Rmxhc2hIYXNoewY6C25vdGlj%0AZSIeWW91IGhhdmUgYmVlbiBsb2dnZWQgb3V0LgY6CkB1c2VkewY7DUY6DnJl%0AdHVybl90bzA%3D--ca279c768291b89c9a8535f0342bff27ca7b5706"}
module AuthenticatedSystem
...
def current_user_forget_me
puts "B 1: #{cookies.inspect}"
levain_cookie_delete(COOKIE_KEY)
puts "B 2: #{cookies.inspect}"
end
...
end
module LevainCookies
...
def levain_cookie_delete(key)
puts "C 1: #{cookies.inspect}"
cookies.delete(key, :domain => COOKIE_HOST)
puts "C 2: #{cookies.inspect}"
end
...
end
class SessionsController < ApplicationController
before_filter :login_required, :only => :destroy
#
# THIS BEFORE FILTER IS BREAKING MY STORY
# When I have a log in, then a log out, then a log back in, the second login fails.
#
prepend_before_filter :unauthenticated_required, :except => :destroy
def new
end
def create
self.current_user = User.authenticate(params[:login_or_email], params[:password])
if logged_in?
if params[:remember_me] == '1'
self.current_user_remember_me
end
flash[:notice] = 'Logged in successfully.'
respond_to do |format|
format.html { redirect_back_or_default(new_response_url) }
format.xml { render :nothing => true, :layout => true, :status => 200 }
end
else
flash.now[:warning] = 'Login failed.'
respond_to do |format|
format.html { render :action => :new }
format.xml { render :nothing => true, :layout => true, :status => 400 }
end
end
end
def destroy
puts "A 1: #{cookies.inspect}"
self.current_user_forget_me
puts "A 2: #{cookies.inspect}"
# reset_session
flash[:notice] = 'You have been logged out.'
respond_to do |format|
# format.html { redirect_to(home_url) }
format.xml { render :nothing => true, :layout => true, :status => 200 }
end
puts "A 3: #{cookies.inspect}"
end
end
...
Scenario: A logged in user comes to the site and visits pages ...
Given a User with no email, login 'bob', and password 'password'
And 'bob' logged in with password 'password'
When 'bob' visits '/responses/new'
And 'bob' logs out
And 'bob' logs in with password 'password'
And 'bob' visits '/responses/new'
Then nothing
...
steps_for :user do
Given "a User with no email, login '$login', and password '$password'" do |login, password|
Factory :user, :email => nil, :login => login, :password => password, :password_confirmation => password
end
Given "'$login_or_email' logged in with password '$password'" do |login_or_email, password|
post '/session', { :login_or_email => login_or_email, :password => password }
response.should be_redirect
end
When "'$agent' logs out" do |agent|
puts "E 1: #{cookies.inspect}"
delete '/session'
puts "E 2: #{cookies.inspect}"
response.should be_redirect
end
When "'$login_or_email' logs in with password '$password'" do |login_or_email, password|
post '/session', { :login_or_email => login_or_email, :password => password }
puts response.inspect
response.should be_redirect # THIS FAILS!!!
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment