goma 0.0.1.rc1 → 0.0.1.rc2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.travis.yml +4 -1
- data/Gemfile.lock +1 -1
- data/Rakefile +6 -0
- data/goma.gemspec +0 -5
- data/lib/goma/config.rb +3 -3
- data/lib/goma/models/confirmable.rb +2 -3
- data/lib/goma/models/lockable.rb +1 -0
- data/lib/goma/models/omniauthable.rb +9 -2
- data/lib/goma/models/password_authenticatable.rb +1 -1
- data/lib/goma/models/timeoutable.rb +1 -1
- data/lib/goma/models/validatable.rb +1 -1
- data/lib/goma/version.rb +1 -1
- data/test/fabricators/authentication_fabricator.rb +4 -0
- data/test/fabricators/{users_fabricator.rb → user_fabricator.rb} +8 -0
- data/test/integration/confirmable_integration_test.rb +5 -5
- data/test/integration/lockable_integration_test.rb +1 -1
- data/test/integration/recoverable_integration_test.rb +2 -2
- data/test/integration/timeoutable_integration_test.rb +171 -171
- data/test/models/confirmable_test.rb +207 -159
- data/test/{goma_test.rb → models/goma_test.rb} +0 -5
- data/test/models/lockable_test.rb +131 -0
- data/test/models/recoverable_test.rb +108 -0
- data/test/models/rememberable_test.rb +115 -0
- data/test/models/timeoutable_test.rb +33 -0
- data/test/models/trackable_test.rb +37 -0
- data/test/models/validatable_test.rb +131 -35
- data/test/rails_app/config/initializers/goma.rb +1 -1
- data/test/rails_app/db/migrate/20140515111009_create_users.rb +1 -0
- data/test/rails_app/db/schema.rb +1 -0
- data/test/test_helper.rb +1 -0
- metadata +19 -13
- data/test/config_test.rb +0 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0d6099fa064157ae214f3a611bc179f97732ea87
|
4
|
+
data.tar.gz: 5e9b12ea1433741c58da4a6b9abe08e7c4b320d9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 73a52d5b437db21c532f16b6179cc3a163ebac83ae496657337b24b58351e0985b7cab88d49663d0450c1bd443093e3f7542a52423340b20fb85957dd21b1425
|
7
|
+
data.tar.gz: 0d62cf55a2bc7df0c209722eb3ae7e3347ea5b82b7ee549fd25dba5d16841a8d56480a8925fe84b921760352b76944cce87d0afaf50028d7eee7ea9d45631713
|
data/.travis.yml
CHANGED
data/Gemfile.lock
CHANGED
data/Rakefile
CHANGED
@@ -44,4 +44,10 @@ task "rebuild_test_app" do
|
|
44
44
|
cd "../.."
|
45
45
|
end
|
46
46
|
|
47
|
+
desc "Run tests for all environment variables"
|
48
|
+
task "test_all" do
|
49
|
+
sh "VALIDATE_SESSION_EVEN_IN_NOT_LOGIN_AREA=true bundle exec rake test"
|
50
|
+
sh "VALIDATE_SESSION_EVEN_IN_NOT_LOGIN_AREA=false bundle exec rake test"
|
51
|
+
end
|
52
|
+
|
47
53
|
task default: :test
|
data/goma.gemspec
CHANGED
@@ -49,11 +49,6 @@ That's it.
|
|
49
49
|
This gem is in early development phase and I do not recommend you to use this for production for a while.
|
50
50
|
Bug reports and pull requests are welcome.
|
51
51
|
|
52
|
-
I am surprised that this gem has been downloaded over 200 times, in spite of pre release versions of v0.0.1.
|
53
|
-
And, I feel bad about there were lots of bugs and incomplete implementations in previous versions.
|
54
|
-
|
55
|
-
I will release this as a release candidate, but will add lots of code before v0.0.1.
|
56
|
-
|
57
52
|
Enjoy!\e[0m
|
58
53
|
MESSAGE
|
59
54
|
|
data/lib/goma/config.rb
CHANGED
@@ -4,12 +4,12 @@ module Goma
|
|
4
4
|
yield @config ||= Goma::Configuration.new
|
5
5
|
end
|
6
6
|
|
7
|
-
def config
|
8
|
-
@config
|
7
|
+
def config(scope=nil)
|
8
|
+
scope ? (config_for[scope] || @config) : @config
|
9
9
|
end
|
10
10
|
|
11
11
|
def configure_for(scope, &block)
|
12
|
-
yield config_for[scope] = config.dup
|
12
|
+
yield config_for[scope] = @config.dup
|
13
13
|
end
|
14
14
|
|
15
15
|
def config_for
|
@@ -24,7 +24,6 @@ module Goma
|
|
24
24
|
|
25
25
|
def initialize(*args)
|
26
26
|
super
|
27
|
-
@email_confirmation_setup = false
|
28
27
|
@skip_email_confirmation = false
|
29
28
|
|
30
29
|
# Following instance variables are not used by this library.
|
@@ -84,7 +83,8 @@ module Goma
|
|
84
83
|
end
|
85
84
|
|
86
85
|
def send_email_confirmation_needed_email?
|
87
|
-
|
86
|
+
send(goma_config.unconfirmed_email_changed_getter) && send(goma_config.unconfirmed_email_getter) &&
|
87
|
+
goma_config.email_confirmation_needed_email_method_name && !@skip_email_confirmation_needed_email
|
88
88
|
end
|
89
89
|
|
90
90
|
def send_email_confirmation_success_email?
|
@@ -113,7 +113,6 @@ module Goma
|
|
113
113
|
def setup_email_confirmation
|
114
114
|
self.send(Goma.config.unconfirmed_email_setter, self.send(Goma.config.email_getter))
|
115
115
|
self.send(Goma.config.email_setter, self.send(Goma.config.email_was_getter))
|
116
|
-
@email_confirmation_setup = true
|
117
116
|
|
118
117
|
generate_confirmation_token
|
119
118
|
end
|
data/lib/goma/models/lockable.rb
CHANGED
@@ -23,12 +23,14 @@ module Goma
|
|
23
23
|
fill_with_omniauth(omniauth) if respond_to? :fill_with_omniauth
|
24
24
|
end
|
25
25
|
RUBY
|
26
|
+
|
27
|
+
attr_accessor :creating_with_omniauth
|
26
28
|
end
|
27
29
|
|
28
30
|
module ClassMethods
|
29
|
-
def
|
30
|
-
@creating_with_omniauth = true
|
31
|
+
def build_with_omniauth!(omniauth)
|
31
32
|
record = new
|
33
|
+
record.creating_with_omniauth = true
|
32
34
|
if goma_config.modules.include? :confirmable
|
33
35
|
record.send(goma_config.activated_at_setter, Time.now.utc)
|
34
36
|
end
|
@@ -36,8 +38,13 @@ module Goma
|
|
36
38
|
|
37
39
|
authentication = record.send(goma_config.oauth_association_name).build
|
38
40
|
authentication._fill_with_omniauth(omniauth)
|
41
|
+
record
|
42
|
+
end
|
39
43
|
|
44
|
+
def create_with_omniauth!(omniauth)
|
45
|
+
record = build_with_omniauth!(omniauth)
|
40
46
|
record.save!
|
47
|
+
record.creating_with_omniauth = false
|
41
48
|
record
|
42
49
|
end
|
43
50
|
|
@@ -9,8 +9,8 @@ module Goma
|
|
9
9
|
|
10
10
|
class_eval <<-METHOD, __FILE__, __LINE__ + 1
|
11
11
|
def #{password_attr}=(new_#{password_attr})
|
12
|
-
return if new_#{password_attr}.blank?
|
13
12
|
@#{password_attr} = new_#{password_attr}
|
13
|
+
return if new_#{password_attr}.blank?
|
14
14
|
self.#{Goma.config.encrypted_password_attribute_name} = encrypt_password(new_#{password_attr})
|
15
15
|
end
|
16
16
|
METHOD
|
@@ -2,7 +2,7 @@ module Goma
|
|
2
2
|
module Models
|
3
3
|
module Timeoutable
|
4
4
|
def timeout?(last_request_at)
|
5
|
-
false if remember_exists_and_not_expired?
|
5
|
+
return false if remember_exists_and_not_expired?
|
6
6
|
goma_config.timeout_in && last_request_at && last_request_at <= goma_config.timeout_in.ago
|
7
7
|
end
|
8
8
|
|
@@ -32,9 +32,9 @@ module Goma
|
|
32
32
|
end
|
33
33
|
|
34
34
|
validates_presence_of goma_config.password_attribute_name, if: :password_required?
|
35
|
-
validates_confirmation_of goma_config.password_attribute_name, if: :password_required?
|
36
35
|
validates_length_of goma_config.password_attribute_name,
|
37
36
|
within: goma_config.password_length, allow_blank: true
|
37
|
+
validates_confirmation_of goma_config.password_attribute_name
|
38
38
|
|
39
39
|
if omniauthable?
|
40
40
|
class_eval <<-RUBY, __FILE__, __LINE__ + 1
|
data/lib/goma/version.rb
CHANGED
@@ -9,3 +9,11 @@ end
|
|
9
9
|
Fabricator(:unactivated_user, from: :user) do
|
10
10
|
activated_at nil
|
11
11
|
end
|
12
|
+
|
13
|
+
Fabricator(:oauth_user, from: :user) do
|
14
|
+
username nil
|
15
|
+
email nil
|
16
|
+
password nil
|
17
|
+
password_confirmation nil
|
18
|
+
authentications(count: 1) { Fabricate(:authentication) }
|
19
|
+
end
|
@@ -48,7 +48,7 @@ class ConfirmableIntegrationTest < ActionDispatch::IntegrationTest
|
|
48
48
|
fill_in :user_password_confirmation, with: 'password'
|
49
49
|
|
50
50
|
assert_no_difference 'User.count' do
|
51
|
-
|
51
|
+
assert_emails 1 do
|
52
52
|
click_button 'Sign up'
|
53
53
|
end
|
54
54
|
end
|
@@ -101,7 +101,7 @@ class ConfirmableIntegrationTest < ActionDispatch::IntegrationTest
|
|
101
101
|
fill_in :username_or_email, with: 'user'
|
102
102
|
|
103
103
|
assert_no_difference 'User.count' do
|
104
|
-
|
104
|
+
assert_emails 1 do
|
105
105
|
click_button 'Resend activation instructions'
|
106
106
|
end
|
107
107
|
end
|
@@ -132,7 +132,7 @@ class ConfirmableIntegrationTest < ActionDispatch::IntegrationTest
|
|
132
132
|
fill_in :username_or_email, with: 'user@example.com'
|
133
133
|
|
134
134
|
assert_no_difference 'User.count' do
|
135
|
-
|
135
|
+
assert_emails 1 do
|
136
136
|
click_button 'Resend activation instructions'
|
137
137
|
end
|
138
138
|
end
|
@@ -159,7 +159,7 @@ class ConfirmableIntegrationTest < ActionDispatch::IntegrationTest
|
|
159
159
|
visit edit_user_url(user)
|
160
160
|
fill_in :user_email, with: 'new@example.com'
|
161
161
|
|
162
|
-
|
162
|
+
assert_emails 1 do
|
163
163
|
click_button 'Update'
|
164
164
|
end
|
165
165
|
assert_match /but we need to verify your new email address/, _flash[:notice]
|
@@ -171,7 +171,7 @@ class ConfirmableIntegrationTest < ActionDispatch::IntegrationTest
|
|
171
171
|
assert_equal 'old@example.com', user.email
|
172
172
|
assert_equal 'new@example.com', user.unconfirmed_email
|
173
173
|
|
174
|
-
|
174
|
+
assert_emails 1 do
|
175
175
|
visit email_confirmation_url('sesame')
|
176
176
|
end
|
177
177
|
email = ActionMailer::Base.deliveries.last
|
@@ -30,7 +30,7 @@ class LockableIntegrationTest < ActionDispatch::IntegrationTest
|
|
30
30
|
|
31
31
|
visit new_unlock_url
|
32
32
|
fill_in :username_or_email, with: @user.email
|
33
|
-
|
33
|
+
assert_emails 1 do
|
34
34
|
click_button 'Resend unlock instructions'
|
35
35
|
end
|
36
36
|
email = ActionMailer::Base.deliveries.last
|
@@ -9,7 +9,7 @@ class RecoverableIntegrationTest < ActionDispatch::IntegrationTest
|
|
9
9
|
Goma.token_generator.stubs(:friendly_token).returns('sesame')
|
10
10
|
visit new_password_url
|
11
11
|
fill_in :username_or_email, with: @user.email
|
12
|
-
|
12
|
+
assert_emails 1 do
|
13
13
|
click_button 'Send me reset password instructions'
|
14
14
|
end
|
15
15
|
|
@@ -31,7 +31,7 @@ class RecoverableIntegrationTest < ActionDispatch::IntegrationTest
|
|
31
31
|
Goma.token_generator.stubs(:friendly_token).returns('sesame')
|
32
32
|
visit new_password_url
|
33
33
|
fill_in :username_or_email, with: @user.email
|
34
|
-
|
34
|
+
assert_emails 1 do
|
35
35
|
click_button 'Send me reset password instructions'
|
36
36
|
end
|
37
37
|
|
@@ -1,201 +1,201 @@
|
|
1
1
|
require 'test_helper'
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
3
|
+
if ENV['VALIDATE_SESSION_EVEN_IN_NOT_LOGIN_AREA'] == 'true'
|
4
|
+
class TimeoutableIntegrationTest < ActionDispatch::IntegrationTest
|
5
|
+
def setup
|
6
|
+
@user = Fabricate(:user)
|
7
|
+
post 'session', username_or_email: @user.email, password: 'password'
|
8
|
+
end
|
8
9
|
|
9
|
-
|
10
|
-
|
10
|
+
test "should set goma.last_request_at immediately after login" do
|
11
|
+
assert request.env['warden'].session(:user)['goma.last_request_at']
|
11
12
|
|
12
|
-
|
13
|
-
|
14
|
-
|
13
|
+
Timecop.freeze 30.minutes.from_now
|
14
|
+
get 'secret/index'
|
15
|
+
assert_redirected_to root_url
|
15
16
|
|
16
|
-
|
17
|
-
|
17
|
+
Timecop.return
|
18
|
+
end
|
18
19
|
|
19
|
-
|
20
|
-
|
21
|
-
|
20
|
+
test "should timeout" do
|
21
|
+
Timecop.freeze Time.now
|
22
|
+
get 'secret/index'
|
22
23
|
|
23
|
-
|
24
|
-
|
25
|
-
|
24
|
+
Timecop.freeze 29.minutes.from_now
|
25
|
+
get 'secret/index'
|
26
|
+
assert_response :success
|
26
27
|
|
27
|
-
|
28
|
-
|
29
|
-
|
28
|
+
Timecop.freeze 30.minutes.from_now
|
29
|
+
get 'secret/index'
|
30
|
+
assert_redirected_to root_url
|
30
31
|
|
31
|
-
|
32
|
-
|
32
|
+
Timecop.return
|
33
|
+
end
|
33
34
|
|
34
|
-
|
35
|
-
|
36
|
-
|
35
|
+
test "should not timeout if accessed a page which does not require login" do
|
36
|
+
Timecop.freeze Time.now
|
37
|
+
get 'secret/index'
|
37
38
|
|
38
|
-
|
39
|
-
|
40
|
-
|
39
|
+
Timecop.freeze 20.minutes.from_now
|
40
|
+
get '/'
|
41
|
+
assert_response :success
|
41
42
|
|
42
|
-
|
43
|
-
|
44
|
-
|
43
|
+
Timecop.freeze 20.minutes.from_now
|
44
|
+
get 'secret/index'
|
45
|
+
assert_response :success
|
45
46
|
|
46
|
-
|
47
|
-
|
47
|
+
Timecop.return
|
48
|
+
end
|
48
49
|
|
49
|
-
|
50
|
-
|
51
|
-
|
50
|
+
test "should timeout if accessing skip_trackabled action" do
|
51
|
+
Timecop.freeze Time.now
|
52
|
+
get 'secret/index'
|
52
53
|
|
53
|
-
|
54
|
-
|
55
|
-
|
54
|
+
Timecop.freeze 20.minutes.from_now
|
55
|
+
get 'secret/not_track'
|
56
|
+
assert_response :success
|
56
57
|
|
57
|
-
|
58
|
-
|
59
|
-
|
58
|
+
Timecop.freeze 20.minutes.from_now
|
59
|
+
get 'secret/not_track'
|
60
|
+
assert_redirected_to root_url
|
60
61
|
|
61
|
-
|
62
|
-
|
62
|
+
Timecop.return
|
63
|
+
end
|
64
|
+
|
65
|
+
test "should not timeout but update last_request_at by accessing skip_timeout action" do
|
66
|
+
Timecop.freeze Time.now
|
67
|
+
get 'secret/index'
|
68
|
+
|
69
|
+
Timecop.freeze 60.minutes.from_now
|
70
|
+
get 'secret/not_timeout'
|
71
|
+
assert_response :success
|
72
|
+
|
73
|
+
Timecop.freeze 29.minutes.from_now
|
74
|
+
get 'secret/index'
|
75
|
+
assert_response :success
|
63
76
|
|
64
|
-
|
65
|
-
|
66
|
-
|
77
|
+
Timecop.freeze 60.minutes.from_now
|
78
|
+
get 'secret/not_timeout'
|
79
|
+
assert_response :success
|
67
80
|
|
68
|
-
|
69
|
-
|
70
|
-
|
81
|
+
Timecop.freeze 30.minutes.from_now
|
82
|
+
get 'secret/index'
|
83
|
+
assert_redirected_to root_url
|
71
84
|
|
72
|
-
|
73
|
-
|
74
|
-
assert_response :success
|
85
|
+
Timecop.return
|
86
|
+
end
|
75
87
|
|
76
|
-
|
77
|
-
|
78
|
-
|
88
|
+
test "should not timeout nor update last_request_at by accessing skip_validate_session action" do
|
89
|
+
Timecop.freeze Time.now
|
90
|
+
get 'secret/index'
|
79
91
|
|
80
|
-
|
81
|
-
|
82
|
-
|
92
|
+
Timecop.freeze 60.minutes.from_now
|
93
|
+
get 'secret/not_validate_session'
|
94
|
+
assert_response :success
|
83
95
|
|
84
|
-
|
96
|
+
get 'secret/index'
|
97
|
+
assert_redirected_to root_url
|
98
|
+
|
99
|
+
Timecop.return
|
100
|
+
end
|
85
101
|
end
|
102
|
+
else
|
103
|
+
class TimeoutableIntegrationTest < ActionDispatch::IntegrationTest
|
104
|
+
def setup
|
105
|
+
@user = Fabricate(:user)
|
106
|
+
post 'session', username_or_email: @user.email, password: 'password'
|
107
|
+
end
|
108
|
+
|
109
|
+
test "should set goma.last_request_at immediately after login" do
|
110
|
+
assert request.env['warden'].session(:user)['goma.last_request_at']
|
111
|
+
|
112
|
+
Timecop.freeze 30.minutes.from_now
|
113
|
+
get 'secret/index'
|
114
|
+
assert_redirected_to root_url
|
115
|
+
|
116
|
+
Timecop.return
|
117
|
+
end
|
118
|
+
|
119
|
+
test "should timeout" do
|
120
|
+
Timecop.freeze Time.now
|
121
|
+
get 'secret/index'
|
122
|
+
|
123
|
+
Timecop.freeze 29.minutes.from_now
|
124
|
+
get 'secret/index'
|
125
|
+
assert_response :success
|
126
|
+
|
127
|
+
Timecop.freeze 30.minutes.from_now
|
128
|
+
get 'secret/index'
|
129
|
+
assert_redirected_to root_url
|
130
|
+
|
131
|
+
Timecop.return
|
132
|
+
end
|
86
133
|
|
87
|
-
|
88
|
-
|
89
|
-
|
134
|
+
test "should timeout if accessed a page which does not require login" do
|
135
|
+
Timecop.freeze Time.now
|
136
|
+
get 'secret/index'
|
90
137
|
|
91
|
-
|
92
|
-
|
93
|
-
|
138
|
+
Timecop.freeze 20.minutes.from_now
|
139
|
+
get '/'
|
140
|
+
assert_response :success
|
94
141
|
|
95
|
-
|
96
|
-
|
142
|
+
Timecop.freeze 20.minutes.from_now
|
143
|
+
get 'secret/index'
|
144
|
+
assert_redirected_to root_url
|
97
145
|
|
98
|
-
|
146
|
+
Timecop.return
|
147
|
+
end
|
148
|
+
|
149
|
+
test "should timeout if accessing skip_trackabled action" do
|
150
|
+
Timecop.freeze Time.now
|
151
|
+
get 'secret/index'
|
152
|
+
|
153
|
+
Timecop.freeze 20.minutes.from_now
|
154
|
+
get 'secret/not_track'
|
155
|
+
assert_response :success
|
156
|
+
|
157
|
+
Timecop.freeze 20.minutes.from_now
|
158
|
+
get 'secret/not_track'
|
159
|
+
assert_redirected_to root_url
|
160
|
+
|
161
|
+
Timecop.return
|
162
|
+
end
|
163
|
+
|
164
|
+
test "should not timeout but update last_request_at by accessing skip_timeout action" do
|
165
|
+
Timecop.freeze Time.now
|
166
|
+
get 'secret/index'
|
167
|
+
|
168
|
+
Timecop.freeze 60.minutes.from_now
|
169
|
+
get 'secret/not_timeout'
|
170
|
+
assert_response :success
|
171
|
+
|
172
|
+
Timecop.freeze 29.minutes.from_now
|
173
|
+
get 'secret/index'
|
174
|
+
assert_response :success
|
175
|
+
|
176
|
+
Timecop.freeze 60.minutes.from_now
|
177
|
+
get 'secret/not_timeout'
|
178
|
+
assert_response :success
|
179
|
+
|
180
|
+
Timecop.freeze 30.minutes.from_now
|
181
|
+
get 'secret/index'
|
182
|
+
assert_redirected_to root_url
|
183
|
+
|
184
|
+
Timecop.return
|
185
|
+
end
|
186
|
+
|
187
|
+
test "should not timeout nor update last_request_at by accessing skip_validate_session action" do
|
188
|
+
Timecop.freeze Time.now
|
189
|
+
get 'secret/index'
|
190
|
+
|
191
|
+
Timecop.freeze 60.minutes.from_now
|
192
|
+
get 'secret/not_validate_session'
|
193
|
+
assert_response :success
|
194
|
+
|
195
|
+
get 'secret/index'
|
196
|
+
assert_redirected_to root_url
|
197
|
+
|
198
|
+
Timecop.return
|
199
|
+
end
|
99
200
|
end
|
100
201
|
end
|
101
|
-
|
102
|
-
# uninclude Module has not yet correctly implemented.
|
103
|
-
# Therefore, omit following test
|
104
|
-
#
|
105
|
-
# class TimeoutableDoNotValidateSessionInNotLoginAreaTest < ActionDispatch::IntegrationTest
|
106
|
-
# def setup
|
107
|
-
# # Goma.config.validate_session_even_in_not_login_area = false
|
108
|
-
# # reinclude_timeout_module
|
109
|
-
# @user = Fabricate(:user)
|
110
|
-
# post 'session', username_or_email: @user.email, password: 'password'
|
111
|
-
# end
|
112
|
-
# #
|
113
|
-
# # def teardown
|
114
|
-
# # Goma.config.validate_session_even_in_not_login_area = true
|
115
|
-
# # reinclude_timeout_module
|
116
|
-
# # end
|
117
|
-
#
|
118
|
-
# test "should timeout if accessed a page which does not require login" do
|
119
|
-
# Timecop.freeze Time.now
|
120
|
-
# get 'secret/index'
|
121
|
-
#
|
122
|
-
# Timecop.freeze 20.minutes.from_now
|
123
|
-
# get '/'
|
124
|
-
# assert_response :success
|
125
|
-
#
|
126
|
-
# Timecop.freeze 20.minutes.from_now
|
127
|
-
# get 'secret/index'
|
128
|
-
# assert_redirected_to root_url
|
129
|
-
#
|
130
|
-
# Timecop.return
|
131
|
-
# end
|
132
|
-
#
|
133
|
-
# test "should timeout if accessing skip_trackabled action" do
|
134
|
-
# Timecop.freeze Time.now
|
135
|
-
# get 'secret/index'
|
136
|
-
#
|
137
|
-
# Timecop.freeze 20.minutes.from_now
|
138
|
-
# get 'secret/not_track'
|
139
|
-
# assert_response :success
|
140
|
-
#
|
141
|
-
# Timecop.freeze 20.minutes.from_now
|
142
|
-
# get 'secret/not_track'
|
143
|
-
# assert_redirected_to root_url
|
144
|
-
#
|
145
|
-
# Timecop.return
|
146
|
-
# end
|
147
|
-
#
|
148
|
-
# test "should not timeout but update last_request_at by accessing skip_timeout action" do
|
149
|
-
# Timecop.freeze Time.now
|
150
|
-
# get 'secret/index'
|
151
|
-
#
|
152
|
-
# Timecop.freeze 60.minutes.from_now
|
153
|
-
# get 'secret/not_timeout'
|
154
|
-
# assert_response :success
|
155
|
-
#
|
156
|
-
# Timecop.freeze 29.minutes.from_now
|
157
|
-
# get 'secret/index'
|
158
|
-
# assert_response :success
|
159
|
-
#
|
160
|
-
# Timecop.freeze 60.minutes.from_now
|
161
|
-
# get 'secret/not_timeout'
|
162
|
-
# assert_response :success
|
163
|
-
#
|
164
|
-
# Timecop.freeze 30.minutes.from_now
|
165
|
-
# get 'secret/index'
|
166
|
-
# assert_redirected_to root_url
|
167
|
-
#
|
168
|
-
# Timecop.return
|
169
|
-
# end
|
170
|
-
#
|
171
|
-
# test "should not timeout nor update last_request_at by accessing skip_validate_session action" do
|
172
|
-
# Timecop.freeze Time.now
|
173
|
-
# get 'secret/index'
|
174
|
-
#
|
175
|
-
# Timecop.freeze 60.minutes.from_now
|
176
|
-
# get 'secret/not_validate_session'
|
177
|
-
# assert_response :success
|
178
|
-
#
|
179
|
-
# get 'secret/index'
|
180
|
-
# assert_redirected_to root_url
|
181
|
-
#
|
182
|
-
# Timecop.return
|
183
|
-
# end
|
184
|
-
#
|
185
|
-
# private
|
186
|
-
# def reinclude_timeout_module
|
187
|
-
# ActionController::Base.send :uninclude, Goma::Controllers::Timeoutable
|
188
|
-
# ActionController::Base.send :unextend, Goma::Controllers::Timeoutable::ClassMethods
|
189
|
-
# # ActionController::Base.class_eval{ skip_filter :validate_session }
|
190
|
-
# # SecretController.class_eval{ skip_filter :validate_session }
|
191
|
-
# SecretController.class_eval do
|
192
|
-
# _process_action_callbacks.reject! do |callback|
|
193
|
-
# callback.filter == :validate_session ||
|
194
|
-
# callback.filter == :skip_timeout ||
|
195
|
-
# callback.filter == :skip_validate_session
|
196
|
-
# end
|
197
|
-
# end
|
198
|
-
# load File.expand_path('../../../lib/goma/controllers/timeoutable.rb', __FILE__)
|
199
|
-
# ActionController::Base.send :include, Goma::Controllers::Timeoutable
|
200
|
-
# end
|
201
|
-
# end
|