public
Description: A Ruby web application framework
Homepage: http://www.mackframework.com
Clone URL: git://github.com/markbates/mack.git
Click here to lend your support to: mack and make a donation at www.pledgie.com !
Feature: Tell Messaging [#5 state:resolved]
Fixed: Sessions in testing [#81 state:resolved]
markbates (author)
Thu Aug 07 11:11:01 -0700 2008
commit  88430a20db7fa50e18433d2719154a4c4666bfd0
tree    115382e56e9de92d79735bb32b402a5b6bbc1b70
parent  2484372bd61049f586d29aba3fd93db05303a5bc
...
 
1
2
3
4
5
6
7
 
 
8
9
10
...
1
2
3
 
4
5
6
7
8
9
10
11
12
0
@@ -1,10 +1,12 @@
0
+* [#81] Fixed sessions working with redirects in testing
0
 * [#76] Move mack_ring_server to mack-distributed
0
 * [#75] Left over mack-distributed rake tasks
0
-* [#8]  Move distributed code from mack-core to mack-more
0
 * [#74] Added optional feature to disable initialization logging.
0
 * [#73] Tests no longer use the functional/unit directories
0
 * [#69] Added ViewHelperGenerator and ControllerHelperGenerator
0
 * [#25] Added ControllerGenerator
0
+* [#8]  Move distributed code from mack-core to mack-more
0
+* [#5] Added tell messaging
0
 * gem: genosaurus 1.2.2
0
 
0
 ===0.6.1.1
...
7
8
9
10
 
11
12
13
...
23
24
25
 
 
 
26
27
28
29
 
 
 
 
30
31
32
...
7
8
9
 
10
11
12
13
...
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
0
@@ -7,7 +7,7 @@ module Mack
0
       
0
       def start(request, response, cookies)
0
         if app_config.mack.use_sessions
0
-          sess_id = cookies[app_config.mack.session_id]
0
+          sess_id = retrieve_session_id(request, response, cookies)
0
           unless sess_id
0
             sess_id = create_new_session(request, response, cookies)
0
           else
0
@@ -23,10 +23,17 @@ module Mack
0
       end
0
       
0
       def complete(request, response, cookies)
0
+        unless response.redirection?
0
+          request.session[:tell] = nil
0
+        end
0
         Cachetastic::Caches::MackSessionCache.set(sess_id, request.session) if app_config.mack.use_sessions
0
       end
0
       
0
       private
0
+      def retrieve_session_id(request, response, cookies)
0
+        cookies[app_config.mack.session_id]
0
+      end
0
+      
0
       def create_new_session(request, response, cookies)
0
         id = String.randomize(40).downcase
0
         cookies[app_config.mack.session_id] = {:value => id, :expires => nil}
...
1
2
 
 
 
 
 
 
 
 
 
 
 
 
 
3
4
5
...
95
96
97
98
 
99
100
101
102
 
103
104
105
...
108
109
110
 
111
 
112
113
114
...
169
170
171
 
172
173
174
...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
...
108
109
110
 
111
112
113
114
115
116
117
118
119
...
122
123
124
125
126
127
128
129
130
...
185
186
187
188
189
190
191
0
@@ -1,5 +1,18 @@
0
 require "test/unit"
0
 
0
+#--
0
+module Mack
0
+  module RunnerHelpers # :nodoc:
0
+    class Session
0
+      private
0
+      def retrieve_session_id(request, response, cookies)
0
+        $current_session_id
0
+      end
0
+    end # Session
0
+  end # RunnerHelpers
0
+end # Mack
0
+#++
0
+
0
 module Mack
0
   module Testing # :nodoc:
0
     module Helpers
0
@@ -95,11 +108,12 @@ module Mack
0
     
0
       # Returns a Mack::Session from the request.
0
       def session # :nodoc:
0
-        Cachetastic::Caches::MackSessionCache.get(cookies[app_config.mack.session_id]) do
0
+        Cachetastic::Caches::MackSessionCache.get($current_session_id) do
0
           id = String.randomize(40).downcase
0
           set_cookie(app_config.mack.session_id, id)
0
           sess = Mack::Session.new(id)
0
           Cachetastic::Caches::MackSessionCache.set(id, sess)
0
+          $current_session_id = id
0
           sess
0
         end
0
       end
0
@@ -108,7 +122,9 @@ module Mack
0
       def in_session
0
         @_mack_in_session = true
0
         clear_session
0
+        $current_session_id = session.id
0
         yield
0
+        $current_session_id = nil
0
         clear_session
0
         @_mack_in_session = false
0
       end
0
@@ -169,6 +185,7 @@ module Mack
0
       def strip_cookies_from_response(res)
0
         unless res.original_headers["Set-Cookie"].nil?
0
           res.original_headers["Set-Cookie"].each do |ck|
0
+            puts "ck: #{ck}"
0
             spt = ck.split("=")
0
             name = spt.first
0
             value = spt.last
...
2
3
4
 
 
 
 
 
 
5
6
7
...
2
3
4
5
6
7
8
9
10
11
12
13
0
@@ -2,6 +2,12 @@ Mack::Routes.build do |r|
0
 
0
   r.resource "admin/users"
0
   
0
+  r.with_options(:controller => :tattle) do |map|
0
+    map.set_tell "/tattle/set_tell", :action => :set_tell
0
+    map.set_tell_and_redirect "/tattle/set_tell_and_redirect", :action => :set_tell_and_redirect
0
+    map.read_tell "/tattle/read_tell", :action => :read_tell
0
+  end
0
+  
0
   r.with_options(:controller => :tst_home_page) do |map|
0
     map.connect "/"
0
     map.connect "foo", :action => :foo
...
4
5
6
7
8
9
10
11
 
 
 
 
 
 
 
12
13
 
 
 
 
 
 
 
 
14
15
16
...
4
5
6
 
 
 
 
 
7
8
9
10
11
12
13
14
 
15
16
17
18
19
20
21
22
23
24
25
0
@@ -4,13 +4,22 @@ require Pathname(__FILE__).dirname.expand_path.parent.parent + 'spec_helper'
0
 describe Mack::Controller::Tell do
0
   include Mack::Controller::Tell
0
   
0
-  it "should be settable in a controller"
0
-  
0
-  it "should be readable in a view"
0
-  
0
-  it "should persist until the next non-redirected action"
0
+  it "should be settable in a controller and readable in a view" do
0
+    session[:tell].should be_nil
0
+    get set_tell_url(:say => "hello good looking")
0
+    response.should be_successful
0
+    response.body.should match(/Someone wanted to say: 'hello good looking'/)
0
+    session[:tell].should be_nil
0
+  end
0
   
0
-  it "should behave like a Hash"
0
+  it "should be persist through a redirect" do
0
+    session[:tell].should be_nil
0
+    get set_tell_and_redirect_url(:say => "what up?")
0
+    response.should be_redirect
0
+    response.should be_redirected_to(read_tell_url)
0
+    response.body.should match(/Someone wanted to say: 'what up\?'/)
0
+    session[:tell].should be_nil
0
+  end
0
   
0
   it "should get set to an empty Hash in the Session if it's nil" do
0
     session[:tell].should be_nil

Comments