Class: ActionController::TestSession
- Inherits:
-
Rack::Session::Abstract::PersistedSecure::SecureSessionHash
- Object
- Rack::Session::Abstract::PersistedSecure::SecureSessionHash
- ActionController::TestSession
- Defined in:
- 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
- #destroy ⇒ Object
- #dig(*keys) ⇒ Object
- #enabled? ⇒ Boolean
- #exists? ⇒ Boolean
- #fetch(key, *args, &block) ⇒ Object
-
#initialize(session = {}) ⇒ TestSession
constructor
A new instance of TestSession.
- #keys ⇒ Object
- #values ⇒ Object
Constructor Details
#initialize(session = {}) ⇒ TestSession
Returns a new instance of TestSession.
185 186 187 188 189 190 |
# File 'lib/action_controller/test_case.rb', line 185 def initialize(session = {}) super(nil, nil) @id = Rack::Session::SessionId.new(SecureRandom.hex(16)) @data = stringify_keys(session) @loaded = true end |
Instance Method Details
#destroy ⇒ Object
204 205 206 |
# File 'lib/action_controller/test_case.rb', line 204 def destroy clear end |
#dig(*keys) ⇒ Object
208 209 210 211 |
# File 'lib/action_controller/test_case.rb', line 208 def dig(*keys) keys = keys.map.with_index { |key, i| i.zero? ? key.to_s : key } @data.dig(*keys) end |
#enabled? ⇒ Boolean
217 218 219 |
# File 'lib/action_controller/test_case.rb', line 217 def enabled? true end |
#exists? ⇒ Boolean
192 193 194 |
# File 'lib/action_controller/test_case.rb', line 192 def exists? true end |
#fetch(key, *args, &block) ⇒ Object
213 214 215 |
# File 'lib/action_controller/test_case.rb', line 213 def fetch(key, *args, &block) @data.fetch(key.to_s, *args, &block) end |
#keys ⇒ Object
196 197 198 |
# File 'lib/action_controller/test_case.rb', line 196 def keys @data.keys end |
#values ⇒ Object
200 201 202 |
# File 'lib/action_controller/test_case.rb', line 200 def values @data.values end |