sixarm_ruby_current_user 1.3.2 → 1.3.6
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.txt +3 -2
- data/lib/sixarm_ruby_current_user.rb +9 -5
- data/test/sixarm_ruby_current_user_test.rb +20 -23
- data.tar.gz.sig +2 -3
- metadata +4 -4
- metadata.gz.sig +2 -1
data/CHANGELOG.txt
CHANGED
@@ -10,13 +10,17 @@ module CurrentUser
|
|
10
10
|
include CurrentUserId
|
11
11
|
|
12
12
|
|
13
|
-
# Get the current user
|
14
|
-
#
|
15
|
-
#
|
13
|
+
# Get the current user.
|
14
|
+
#
|
15
|
+
# This calls User.find with the current_user_id
|
16
16
|
#
|
17
|
-
#
|
17
|
+
# The current user is memoized as @current_user.
|
18
|
+
# To reload, pass :reload => true
|
19
|
+
#
|
20
|
+
# Return the current user, or raise an exception if not found
|
18
21
|
|
19
|
-
def current_user
|
22
|
+
def current_user(ops={})
|
23
|
+
if ops[:reload] then @current_user=nil end
|
20
24
|
@current_user ||= User.find(self.current_user_id)
|
21
25
|
end
|
22
26
|
|
@@ -13,44 +13,41 @@ end
|
|
13
13
|
|
14
14
|
class Testing < Test::Unit::TestCase
|
15
15
|
|
16
|
-
|
17
|
-
|
18
|
-
ANNE_ID=1
|
19
|
-
BETH_ID=2
|
20
|
-
CATE_ID=3
|
21
|
-
|
22
|
-
ANNE = User.new(:id => ANNE_ID, :name => 'Anne')
|
23
|
-
BETH = User.new(:id => BETH_ID, :name => 'Beth')
|
24
|
-
CATE = User.new(:id => CATE_ID, :name => 'Cate')
|
25
|
-
|
16
|
+
# Mock session
|
26
17
|
def session
|
27
|
-
@session||=
|
18
|
+
@session||={}
|
28
19
|
end
|
29
20
|
|
21
|
+
include CurrentUser
|
22
|
+
|
23
|
+
ANNE = User.new(:id => 1, :name => 'Anne')
|
24
|
+
BETH = User.new(:id => 2, :name => 'Beth')
|
25
|
+
CATE = User.new(:id => 3, :name => 'Cate')
|
26
|
+
|
30
27
|
def test_blank_slate
|
31
|
-
assert_nil(
|
32
|
-
assert_nil(
|
28
|
+
assert_nil(current_user, "current_user")
|
29
|
+
assert_nil(current_user_id, "current_user_id")
|
33
30
|
end
|
34
31
|
|
35
32
|
def test_current_user_question
|
36
|
-
assert_equal(false,
|
33
|
+
assert_equal(false, current_user?, "current_user is set, so current_user? should return false")
|
37
34
|
self.current_user=BETH
|
38
|
-
assert_equal(true,
|
35
|
+
assert_equal(true, current_user?, "current_user is set, so current_user? should return true")
|
39
36
|
end
|
40
37
|
|
41
38
|
def test_current_user_equals
|
42
|
-
current_user=BETH
|
39
|
+
self.current_user=BETH
|
43
40
|
actual=current_user
|
44
41
|
assert_equal(BETH, actual, "beth, actual:#{actual}")
|
45
|
-
assert_not_equal(ANNE, actual, "anne, actual:#{actual}")
|
46
|
-
assert_not_equal(CATE, actual, "cate, actual:#{actual}")
|
47
42
|
end
|
48
43
|
|
49
|
-
def
|
50
|
-
current_user=
|
51
|
-
|
52
|
-
|
53
|
-
|
44
|
+
def test_current_user_equals_then_reset
|
45
|
+
self.current_user=BETH
|
46
|
+
actual=current_user
|
47
|
+
assert_equal(BETH, actual, "beth, actual:#{actual}")
|
48
|
+
self.current_user=nil
|
49
|
+
actual=current_user
|
50
|
+
assert_equal(nil, actual, "current_user")
|
54
51
|
end
|
55
52
|
|
56
53
|
end
|
data.tar.gz.sig
CHANGED
@@ -1,3 +1,2 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
�l�՝^�$|ugi|�o���F�&lm�"�\��y�]��Ì�;t8�BE��
|
1
|
+
?��߅�'�M��O(
|
2
|
+
iR���(8ڻ�d.�@2�Z<u�I����~�ړ��6�cϜ�H�[r�����/m�{��0
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: sixarm_ruby_current_user
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 1.3.
|
5
|
+
version: 1.3.6
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- SixArm
|
@@ -30,7 +30,7 @@ cert_chain:
|
|
30
30
|
eabwpCbAopo=
|
31
31
|
-----END CERTIFICATE-----
|
32
32
|
|
33
|
-
date: 2011-04-
|
33
|
+
date: 2011-04-25 00:00:00 -07:00
|
34
34
|
default_executable:
|
35
35
|
dependencies:
|
36
36
|
- !ruby/object:Gem::Dependency
|
@@ -41,7 +41,7 @@ dependencies:
|
|
41
41
|
requirements:
|
42
42
|
- - "="
|
43
43
|
- !ruby/object:Gem::Version
|
44
|
-
version: 1.3.
|
44
|
+
version: 1.3.6
|
45
45
|
type: :runtime
|
46
46
|
version_requirements: *id001
|
47
47
|
- !ruby/object:Gem::Dependency
|
@@ -52,7 +52,7 @@ dependencies:
|
|
52
52
|
requirements:
|
53
53
|
- - ">="
|
54
54
|
- !ruby/object:Gem::Version
|
55
|
-
version: 1.
|
55
|
+
version: 1.4.2
|
56
56
|
type: :runtime
|
57
57
|
version_requirements: *id002
|
58
58
|
description:
|
metadata.gz.sig
CHANGED
@@ -1 +1,2 @@
|
|
1
|
-
|
1
|
+
|pH�.
|
2
|
+
M��Ҵ��̄��e�*��8Z�:d�pzOd����$'%�YU���/%�44Gs�_�D� Q��s���2��2�nD�����a�#kT �9n���|Ҵ4�;5���Cvoñ��J"�/^�I��
|