Class: ActionController::TestSession

Inherits:
Rack::Session::Abstract::SessionHash
  • Object
show all
Defined in:
actionpack/lib/action_controller/test_case.rb

Overview

Methods #destroy and #load! are overridden to avoid calling methods on the

Constant Summary collapse

DEFAULT_OPTIONS =

:nodoc:

Rack::Session::Abstract::Persisted::DEFAULT_OPTIONS

Instance Method Summary collapse

Constructor Details

#initialize(session = {}) ⇒ TestSession

Returns a new instance of TestSession.


176
177
178
179
180
181
# File 'actionpack/lib/action_controller/test_case.rb', line 176

def initialize(session = {})
  super(nil, nil)
  @id = SecureRandom.hex(16)
  @data = stringify_keys(session)
  @loaded = true
end

Instance Method Details

#destroyObject


195
196
197
# File 'actionpack/lib/action_controller/test_case.rb', line 195

def destroy
  clear
end

#exists?Boolean

Returns:

  • (Boolean)

183
184
185
# File 'actionpack/lib/action_controller/test_case.rb', line 183

def exists?
  true
end

#fetch(key, *args, &block) ⇒ Object


199
200
201
# File 'actionpack/lib/action_controller/test_case.rb', line 199

def fetch(key, *args, &block)
  @data.fetch(key.to_s, *args, &block)
end

#keysObject


187
188
189
# File 'actionpack/lib/action_controller/test_case.rb', line 187

def keys
  @data.keys
end

#valuesObject


191
192
193
# File 'actionpack/lib/action_controller/test_case.rb', line 191

def values
  @data.values
end