current_user 0.0.1 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1 @@
1
+ 10750
@@ -0,0 +1,31 @@
1
+ require 'integration_test_helper'
2
+
3
+ class HelpersTest < ActionDispatch::IntegrationTest
4
+ include ::CurrentUser::NavigationHelper
5
+
6
+ fixtures :all
7
+
8
+ test "#signed_in?" do
9
+ visit '/helpers/signed_in_helper'
10
+ assert page.has_content?("#signed_in? is false"),
11
+ "User isn't signed in"
12
+
13
+ sign_in
14
+
15
+ visit '/helpers/signed_in_helper'
16
+ assert page.has_content?("#signed_in? is true"),
17
+ "User is signed in"
18
+ end
19
+
20
+ test "#current_user" do
21
+ visit '/helpers/current_user_helper'
22
+ assert page.has_content?("#current_user is nil"),
23
+ "Current user is nil"
24
+
25
+ sign_in
26
+
27
+ visit '/helpers/current_user_helper'
28
+ assert page.has_content?("#current_user is member@some.app.com"),
29
+ "User is signed in"
30
+ end
31
+ end
@@ -1,6 +1,8 @@
1
1
  require 'integration_test_helper'
2
2
 
3
3
  class LoginTest < ActionDispatch::IntegrationTest
4
+ include ::CurrentUser::NavigationHelper
5
+
4
6
  fixtures :all
5
7
 
6
8
  test "unauthorized user sees the 401 error page" do
@@ -45,28 +47,5 @@ class LoginTest < ActionDispatch::IntegrationTest
45
47
 
46
48
  test "helper methods in views" do end
47
49
  test "all users in the application database are listed in the signin page" do end
48
-
49
- private
50
-
51
- def sing_in_page_path(key = '12345')
52
- "/current_user/#{key}/sign_in"
53
- end
54
-
55
- def assert_user_sees_unauthorized_error
56
- assert page.has_content?('Unauthorized'), 'Contains "unauthorized" message'
57
- assert_equal 401, page.status_code, 'Responds with the unauthorized http status code'
58
- end
59
-
60
- def assert_user_sees_protected_page(identifier)
61
- assert_equal 200, page.status_code, 'Root responds with the OK http status code'
62
- assert page.has_content?("Welcome #{identifier}"), 'Contains the welcome message for the use'
63
- end
64
-
65
- def sign_in_as(identifier)
66
- visit sing_in_page_path
67
- assert_equal 200, page.status_code, 'Sign in responds with the OK http status code'
68
- page.click_button identifier
69
- assert_user_sees_protected_page identifier
70
- end
71
50
  end
72
51
 
@@ -0,0 +1,30 @@
1
+ module CurrentUser
2
+ module NavigationHelper
3
+ private
4
+
5
+ def sing_in_page_path(key = '12345')
6
+ "/current_user/#{key}/sign_in"
7
+ end
8
+
9
+ def assert_user_sees_unauthorized_error
10
+ assert page.has_content?('Unauthorized'), 'Contains "unauthorized" message'
11
+ assert_equal 401, page.status_code, 'Responds with the unauthorized http status code'
12
+ end
13
+
14
+ def assert_user_sees_protected_page(identifier)
15
+ assert_equal 200, page.status_code, 'Root responds with the OK http status code'
16
+ assert page.has_content?("Welcome #{identifier}"), 'Contains the welcome message for the use'
17
+ end
18
+
19
+ def sign_in
20
+ sign_in_as 'member@some.app.com'
21
+ end
22
+
23
+ def sign_in_as(identifier)
24
+ visit sing_in_page_path
25
+ assert_equal 200, page.status_code, 'Sign in responds with the OK http status code'
26
+ page.click_button identifier
27
+ assert_user_sees_protected_page identifier
28
+ end
29
+ end
30
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: current_user
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.1.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-07-02 00:00:00.000000000 Z
12
+ date: 2012-07-03 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
16
- requirement: &80944150 !ruby/object:Gem::Requirement
16
+ requirement: &68600560 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 3.2.6
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *80944150
24
+ version_requirements: *68600560
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: sqlite3
27
- requirement: &80943930 !ruby/object:Gem::Requirement
27
+ requirement: &68600230 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *80943930
35
+ version_requirements: *68600230
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: capybara
38
- requirement: &80943700 !ruby/object:Gem::Requirement
38
+ requirement: &68599920 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '0'
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *80943700
46
+ version_requirements: *68599920
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: database_cleaner
49
- requirement: &80943480 !ruby/object:Gem::Requirement
49
+ requirement: &68599500 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,7 +54,7 @@ dependencies:
54
54
  version: '0'
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *80943480
57
+ version_requirements: *68599500
58
58
  description: ! 'An authentication gem for the pre-production (mainly) phase of the
59
59
  application lifecycle.
60
60
 
@@ -91,13 +91,19 @@ files:
91
91
  - Rakefile
92
92
  - README.md
93
93
  - test/dummy/test/fixtures/users.yml
94
+ - test/dummy/tmp/pids/server.pid
94
95
  - test/dummy/config.ru
96
+ - test/dummy/log/development.log
97
+ - test/dummy/log/test.log
95
98
  - test/dummy/app/models/user.rb
96
99
  - test/dummy/app/assets/stylesheets/application.css
97
100
  - test/dummy/app/assets/javascripts/application.js
98
101
  - test/dummy/app/views/layouts/application.html.erb
102
+ - test/dummy/app/views/helpers/current_user_helper.erb
103
+ - test/dummy/app/views/helpers/signed_in_helper.erb
99
104
  - test/dummy/app/views/my_protected_pages/show.html.erb
100
105
  - test/dummy/app/controllers/application_controller.rb
106
+ - test/dummy/app/controllers/helpers_controller.rb
101
107
  - test/dummy/app/controllers/my_protected_pages_controller.rb
102
108
  - test/dummy/app/helpers/application_helper.rb
103
109
  - test/dummy/config/environments/test.rb
@@ -118,6 +124,10 @@ files:
118
124
  - test/dummy/config/database.yml
119
125
  - test/dummy/config/current_user/key
120
126
  - test/dummy/Rakefile
127
+ - test/dummy/db/development.sqlite3
128
+ - test/dummy/db/test.sqlite3
129
+ - test/dummy/db/migrate/20120319094037_create_users.rb
130
+ - test/dummy/db/schema.rb
121
131
  - test/dummy/public/422.html
122
132
  - test/dummy/public/500.html
123
133
  - test/dummy/public/404.html
@@ -125,7 +135,9 @@ files:
125
135
  - test/dummy/README.rdoc
126
136
  - test/dummy/script/rails
127
137
  - test/integration_test_helper.rb
138
+ - test/integration/helpers_test.rb
128
139
  - test/integration/login_test.rb
140
+ - test/support/current_user/navigation_helper.rb
129
141
  - test/test_helper.rb
130
142
  homepage: https://github.com/MitinPavel/current_user
131
143
  licenses: []
@@ -153,13 +165,19 @@ specification_version: 3
153
165
  summary: Dev phase auth for Rails
154
166
  test_files:
155
167
  - test/dummy/test/fixtures/users.yml
168
+ - test/dummy/tmp/pids/server.pid
156
169
  - test/dummy/config.ru
170
+ - test/dummy/log/development.log
171
+ - test/dummy/log/test.log
157
172
  - test/dummy/app/models/user.rb
158
173
  - test/dummy/app/assets/stylesheets/application.css
159
174
  - test/dummy/app/assets/javascripts/application.js
160
175
  - test/dummy/app/views/layouts/application.html.erb
176
+ - test/dummy/app/views/helpers/current_user_helper.erb
177
+ - test/dummy/app/views/helpers/signed_in_helper.erb
161
178
  - test/dummy/app/views/my_protected_pages/show.html.erb
162
179
  - test/dummy/app/controllers/application_controller.rb
180
+ - test/dummy/app/controllers/helpers_controller.rb
163
181
  - test/dummy/app/controllers/my_protected_pages_controller.rb
164
182
  - test/dummy/app/helpers/application_helper.rb
165
183
  - test/dummy/config/environments/test.rb
@@ -180,6 +198,10 @@ test_files:
180
198
  - test/dummy/config/database.yml
181
199
  - test/dummy/config/current_user/key
182
200
  - test/dummy/Rakefile
201
+ - test/dummy/db/development.sqlite3
202
+ - test/dummy/db/test.sqlite3
203
+ - test/dummy/db/migrate/20120319094037_create_users.rb
204
+ - test/dummy/db/schema.rb
183
205
  - test/dummy/public/422.html
184
206
  - test/dummy/public/500.html
185
207
  - test/dummy/public/404.html
@@ -187,5 +209,7 @@ test_files:
187
209
  - test/dummy/README.rdoc
188
210
  - test/dummy/script/rails
189
211
  - test/integration_test_helper.rb
212
+ - test/integration/helpers_test.rb
190
213
  - test/integration/login_test.rb
214
+ - test/support/current_user/navigation_helper.rb
191
215
  - test/test_helper.rb