Created
January 4, 2009 01:20
-
-
Save lukemelia/42973 to your computer and use it in GitHub Desktop.
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
#features/steps/users_steps.rb: | |
Given "I'm a logged in member" do | |
@me = create_adult | |
logged_in_as @me | |
end | |
#features/support/env.rb: | |
class Cucumber::Rails::World | |
... | |
def logged_in_as(user) | |
cookies['integration_test_user'] = user.id.to_s | |
end | |
... | |
end | |
#app/controllers/application.rb | |
class ApplicationController < ActionController::Base | |
... | |
before_filter :login_integration_test_user, :if => lambda { Rails.env == 'test' } | |
... | |
def login_integration_test_user | |
return true if cookies['integration_test_user'].blank? | |
integration_test_user_id = cookies['integration_test_user'].to_i | |
if integration_test_user_id != current_user.id | |
reset_session | |
self.current_user = User.find(integration_test_user_id) | |
end | |
cookies['integration_test_user'] = nil | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment