Class: Mack::RunnerHelpers::Session

Inherits:
Base show all
Defined in:
lib/mack/testing/helpers.rb,
lib/mack/runner_helpers/session.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#sess_idObject

Returns the value of attribute sess_id.



6
7
8
# File 'lib/mack/runner_helpers/session.rb', line 6

def sess_id
  @sess_id
end

Instance Method Details

#complete(request, response, cookies) ⇒ Object



25
26
27
28
29
30
31
32
# File 'lib/mack/runner_helpers/session.rb', line 25

def complete(request, response, cookies)
  if configatron.mack.use_sessions
    unless response.redirection?
      request.session.delete(:tell)
    end
    Mack::SessionStore.set(request.session.id, request, response, cookies)
  end
end

#start(request, response, cookies) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/mack/runner_helpers/session.rb', line 8

def start(request, response, cookies)
  if configatron.mack.use_sessions
    self.sess_id = retrieve_session_id(request, response, cookies)
    unless self.sess_id
      self.sess_id = create_new_session(request, response, cookies)
    else
      sess = Mack::SessionStore.get(self.sess_id, request, response, cookies)
      if sess
        request.session = sess
      else
        # we couldn't find it in the store, so we need to create it:
        self.sess_id = create_new_session(request, response, cookies)
      end
    end
  end
end