Sha256: 01acb318bf1159387646d25c75b24aaf5274d5f096b54d7759b6db7812503c49
Contents?: true
Size: 979 Bytes
Versions: 1
Compression:
Stored size: 979 Bytes
Contents
# Used to persist session data in test mode instead of using cookies. Stores the session # data lazily in a global var, accessible across the testing environment. class TestSessionStore def initialize(session = nil) @session = session end def destroy $challah_test_session = nil end def read if $challah_test_session return $challah_test_session.to_s.split(':') end nil end def save(token, user_id) $challah_test_session = "#{token}:#{user_id}" true end end Challah.options[:storage_class] = TestSessionStore class ActiveSupport::TestCase # Sign the given user instance in def signin_as(user) Challah::Session.create!(user, nil, nil, user.class) end alias_method :login_as, :signin_as # Sign the given user instance out def signout Challah::Session.destroy end alias_method :logout, :signout setup do # Reset any challah user sessions for each test. $challah_test_session = nil end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
challah-1.1.1 | lib/challah/test.rb |