aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack
diff options
context:
space:
mode:
authorAttila Domokos <adomokos@gmail.com>2014-03-19 21:01:08 -0500
committerAttila Domokos <adomokos@gmail.com>2014-03-19 21:01:08 -0500
commit102c556e0b1d7e442075625163d57374e798982c (patch)
treec3c87e31f8ca7f3fd80d4e4415b67e69af87abda /actionpack
parent0e0fc50477897c5d0d6775a7c95fa38821621d51 (diff)
downloadrails-102c556e0b1d7e442075625163d57374e798982c.tar.gz
rails-102c556e0b1d7e442075625163d57374e798982c.tar.bz2
rails-102c556e0b1d7e442075625163d57374e798982c.zip
Cleaning and adding tests for Session
Adding tests for Session `destroy`, `update` and `delete` methods. No changes for code under test.
Diffstat (limited to 'actionpack')
-rw-r--r--actionpack/test/dispatch/request/session_test.rb41
1 files changed, 34 insertions, 7 deletions
diff --git a/actionpack/test/dispatch/request/session_test.rb b/actionpack/test/dispatch/request/session_test.rb
index df55fcc8bc..10fb04e230 100644
--- a/actionpack/test/dispatch/request/session_test.rb
+++ b/actionpack/test/dispatch/request/session_test.rb
@@ -36,29 +36,55 @@ module ActionDispatch
assert_equal s, Session.find(env)
end
+ def test_destroy
+ s = Session.create(store, {}, {})
+ s['rails'] = 'ftw'
+
+ s.destroy
+
+ assert_empty s
+ end
+
def test_keys
- env = {}
- s = Session.create(store, env, {})
+ s = Session.create(store, {}, {})
s['rails'] = 'ftw'
s['adequate'] = 'awesome'
assert_equal %w[rails adequate], s.keys
end
def test_values
- env = {}
- s = Session.create(store, env, {})
+ s = Session.create(store, {}, {})
s['rails'] = 'ftw'
s['adequate'] = 'awesome'
assert_equal %w[ftw awesome], s.values
end
def test_clear
- env = {}
- s = Session.create(store, env, {})
+ s = Session.create(store, {}, {})
s['rails'] = 'ftw'
s['adequate'] = 'awesome'
+
s.clear
- assert_equal([], s.values)
+ assert_empty(s.values)
+ end
+
+ def test_update
+ s = Session.create(store, {}, {})
+ s['rails'] = 'ftw'
+
+ s.update(:rails => 'awesome')
+
+ assert_equal(['rails'], s.keys)
+ assert_equal('awesome', s['rails'])
+ end
+
+ def test_delete
+ s = Session.create(store, {}, {})
+ s['rails'] = 'ftw'
+
+ s.delete('rails')
+
+ assert_empty(s.keys)
end
def test_fetch
@@ -82,6 +108,7 @@ module ActionDispatch
Class.new {
def load_session(env); [1, {}]; end
def session_exists?(env); true; end
+ def destroy_session(env, id, options); 123; end
}.new
end
end