sixarm_ruby_current_user_id 1.2.6 → 1.3.4
Sign up to get free protection for your applications and to get access to all the features.
- data.tar.gz.sig +0 -0
- data/CHANGELOG.txt +4 -0
- data/README.rdoc +1 -1
- data/VERSION +1 -0
- data/lib/sixarm_ruby_current_user_id.rb +9 -2
- data/test/sixarm_ruby_current_user_id_test.rb +21 -16
- metadata +6 -4
- metadata.gz.sig +0 -0
data.tar.gz.sig
CHANGED
Binary file
|
data/CHANGELOG.txt
ADDED
data/README.rdoc
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
= SixArm.com » Ruby » CurrentUserId module for Rails sessions
|
2
2
|
|
3
|
-
Author:: Joel Parker Henderson, joelparkerhenderson
|
3
|
+
Author:: Joel Parker Henderson, joel@joelparkerhenderson.com
|
4
4
|
Copyright:: Copyright (c) 2006-2011 Joel Parker Henderson
|
5
5
|
License:: See LICENSE.txt file
|
6
6
|
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
1.3.4
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
2
|
=begin rdoc
|
3
|
-
Please see README.rdoc
|
3
|
+
Please see README.rdoc
|
4
4
|
=end
|
5
5
|
|
6
6
|
module CurrentUserId
|
@@ -14,11 +14,18 @@ module CurrentUserId
|
|
14
14
|
end
|
15
15
|
|
16
16
|
|
17
|
+
# Is there a current user id in the Rails session array?
|
18
|
+
|
19
|
+
def current_user_id?
|
20
|
+
return session[:current_user_id] ? true : false
|
21
|
+
end
|
22
|
+
|
23
|
+
|
17
24
|
# Set the current user id in the Rails session array.
|
18
25
|
# Return the current user id, suitable for chaining.
|
19
26
|
|
20
27
|
def current_user_id=(id)
|
21
|
-
|
28
|
+
session[:current_user_id]=id
|
22
29
|
end
|
23
30
|
|
24
31
|
|
@@ -1,31 +1,36 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
1
2
|
require 'test/unit'
|
2
3
|
require 'sixarm_ruby_current_user_id'
|
3
|
-
require 'simplecov'
|
4
|
-
SimpleCov.start
|
4
|
+
#require 'simplecov'
|
5
|
+
#SimpleCov.start
|
5
6
|
|
6
7
|
class Testing < Test::Unit::TestCase
|
7
8
|
|
8
|
-
|
9
|
-
|
9
|
+
# Mock session
|
10
10
|
def session
|
11
|
-
@session||=
|
11
|
+
return @session||={}
|
12
12
|
end
|
13
13
|
|
14
|
+
include CurrentUserId
|
15
|
+
|
14
16
|
ID=1234
|
15
|
-
|
16
|
-
def test_current_user_id_before_setting
|
17
|
-
assert_nil(current_user_id, "current_user_id is not set, so should be nil")
|
18
|
-
end
|
19
17
|
|
20
|
-
def
|
21
|
-
|
18
|
+
def test_current_user_id_default_is_nil
|
19
|
+
assert_nil(self.current_user_id, "current_user_id is not set, so current_user_id should be nil")
|
22
20
|
end
|
23
|
-
|
21
|
+
|
24
22
|
def test_current_user_id_round_trip
|
25
|
-
current_user_id=ID
|
26
|
-
|
27
|
-
|
28
|
-
|
23
|
+
self.current_user_id=ID
|
24
|
+
assert_equal(ID, current_user_id, "current_user_id is set, so current_user_id should be an id")
|
25
|
+
end
|
26
|
+
|
27
|
+
def test_current_user_id_question_is_false
|
28
|
+
assert_equal(false, current_user_id?, "current_user_id is not set, so current_user_id? should be false")
|
29
|
+
end
|
30
|
+
|
31
|
+
def test_current_user_id_question_is_true
|
32
|
+
self.current_user_id=ID
|
33
|
+
assert_equal(true, current_user_id?, "current_user_id is set, so current_user_id? should be true")
|
29
34
|
end
|
30
35
|
|
31
36
|
end
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: sixarm_ruby_current_user_id
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 1.
|
5
|
+
version: 1.3.4
|
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-22 00:00:00 -07:00
|
34
34
|
default_executable:
|
35
35
|
dependencies: []
|
36
36
|
|
@@ -44,10 +44,12 @@ extra_rdoc_files: []
|
|
44
44
|
|
45
45
|
files:
|
46
46
|
- .gemtest
|
47
|
-
-
|
48
|
-
- README.rdoc
|
47
|
+
- CHANGELOG.txt
|
49
48
|
- INSTALL.txt
|
50
49
|
- LICENSE.txt
|
50
|
+
- Rakefile
|
51
|
+
- README.rdoc
|
52
|
+
- VERSION
|
51
53
|
- lib/sixarm_ruby_current_user_id.rb
|
52
54
|
- test/sixarm_ruby_current_user_id_test.rb
|
53
55
|
has_rdoc: true
|
metadata.gz.sig
CHANGED
Binary file
|