session_store_test.rb
1.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
require File.dirname(__FILE__) + '/test_helper'
class SessionStoreTest < ActiveSupport::TestCase
should 'create a session store without client key' do
store = Noosfero::API::SessionStore.create
assert_not_nil store
private_token = store.private_token
assert_not_nil private_token
key = store.key
assert_not_nil key
assert_equal key, private_token
end
should 'create a session store with client key' do
store = Noosfero::API::SessionStore.create("mykey")
assert_not_nil store
private_token = store.private_token
assert_not_nil private_token
key = store.key
assert_not_nil key
assert_equal key, "mykey##{private_token}"
end
should 'get a session store with client key' do
store = Noosfero::API::SessionStore.create("mykey")
retrieved = Noosfero::API::SessionStore.get(store.key)
assert_not_nil retrieved
end
should 'not get a destroyed session store with client key' do
store = Noosfero::API::SessionStore.create("mykey")
store.destroy
retrieved = Noosfero::API::SessionStore.get(store.key)
assert_nil retrieved
end
should 'store data in session store' do
store = Noosfero::API::SessionStore.create("mykey")
store.data = [1, 2]
## Put it back in cache
store.store
retrieved = Noosfero::API::SessionStore.get(store.key)
assert_equal [1,2], retrieved.data
end
end