Sha256: cfa81356e64517fb7c7a61af1d05f97a62f8aa385dbce0bc2779cacc0419fac3

Contents?: true

Size: 957 Bytes

Versions: 25

Compression:

Stored size: 957 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)
  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

25 entries across 24 versions & 2 rubygems

Version Path
challah-1.1.0 lib/challah/test.rb
challah-1.0.0 lib/challah/test.rb
challah-1.0.0.beta3 lib/challah/test.rb
challah-1.0.0.beta2 lib/challah/test.rb
challah-1.0.0.beta lib/challah/test.rb
challah-0.9.1.beta.3 lib/challah/test.rb
challah-0.9.1.beta.2 lib/challah/test.rb
challah-0.9.1.beta lib/challah/test.rb
challah-0.9.0 lib/challah/test.rb
challah-0.9.0.pre lib/challah/test.rb
challah-rolls-0.2.0 vendor/bundle/gems/challah-0.8.3/lib/challah/test.rb
challah-rolls-0.2.0 vendor/bundle/gems/challah-0.8.0.pre/lib/challah/test.rb
challah-0.8.3 lib/challah/test.rb
challah-0.8.2 lib/challah/test.rb
challah-0.8.1 lib/challah/test.rb
challah-0.8.0 lib/challah/test.rb
challah-rolls-0.1.0 vendor/bundle/gems/challah-0.8.0.pre/lib/challah/test.rb
challah-0.8.0.pre lib/challah/test.rb
challah-0.7.1 lib/challah/test.rb
challah-0.7.0 lib/challah/test.rb