invisible_captcha 0.9.2 → 0.9.3
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 +16 -6
- data/Appraisals +4 -0
- data/gemfiles/rails_5.1.gemfile +7 -0
- data/lib/invisible_captcha/controller_ext.rb +5 -1
- data/lib/invisible_captcha/version.rb +1 -1
- data/spec/controllers_spec.rb +27 -11
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 80d28e320294b2c40e8df6975a0efe8ce36ae9b3
|
4
|
+
data.tar.gz: 27fbdf58a83d4a84475e05cea92d706dc6c37b96
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d49d4f389ea60c174c1ab89d31fdb2414f0a7c8626a3a75a11ab1e0cd18fd1e3fbee07ff21d1b6456249c2b98e49748c6dbec829ef99403956f299ecaca3a5ba
|
7
|
+
data.tar.gz: 7d8b1e7937307cbf2493de51cf2e38b8acf090455756fa719c2482530fe90a64d73c9fa07cef7da2f1aacb4d6dd011d350ee5c557cbe626b30290f05c33b16d4
|
data/.travis.yml
CHANGED
@@ -5,13 +5,15 @@ cache: bundler
|
|
5
5
|
sudo: false
|
6
6
|
|
7
7
|
rvm:
|
8
|
-
-
|
9
|
-
- 2.
|
10
|
-
- 2.
|
8
|
+
- ruby-head
|
9
|
+
- 2.4.1
|
10
|
+
- 2.3.4
|
11
|
+
- 2.2.7
|
11
12
|
- 2.1
|
12
13
|
- 1.9.3
|
13
14
|
|
14
15
|
gemfile:
|
16
|
+
- gemfiles/rails_5.1.gemfile
|
15
17
|
- gemfiles/rails_5.0.gemfile
|
16
18
|
- gemfiles/rails_4.2.gemfile
|
17
19
|
- gemfiles/rails_4.1.gemfile
|
@@ -23,9 +25,17 @@ matrix:
|
|
23
25
|
gemfile: gemfiles/rails_4.2.gemfile
|
24
26
|
- rvm: 1.9.3
|
25
27
|
gemfile: gemfiles/rails_5.0.gemfile
|
28
|
+
- rvm: 1.9.3
|
29
|
+
gemfile: gemfiles/rails_5.1.gemfile
|
26
30
|
- rvm: 2.1
|
27
31
|
gemfile: gemfiles/rails_5.0.gemfile
|
28
|
-
- rvm: 2.
|
32
|
+
- rvm: 2.1
|
33
|
+
gemfile: gemfiles/rails_5.1.gemfile
|
34
|
+
- rvm: 2.4.1
|
29
35
|
gemfile: gemfiles/rails_4.1.gemfile
|
30
|
-
- rvm: 2.4.
|
31
|
-
gemfile: gemfiles/rails_3.2.gemfile
|
36
|
+
- rvm: 2.4.1
|
37
|
+
gemfile: gemfiles/rails_3.2.gemfile
|
38
|
+
- rvm: ruby-head
|
39
|
+
gemfile: gemfiles/rails_3.2.gemfile
|
40
|
+
allow_failures:
|
41
|
+
- rvm: ruby-head
|
data/Appraisals
CHANGED
@@ -26,7 +26,11 @@ module InvisibleCaptcha
|
|
26
26
|
if action = options[:on_timestamp_spam]
|
27
27
|
send(action)
|
28
28
|
else
|
29
|
-
|
29
|
+
if respond_to?(:redirect_back)
|
30
|
+
redirect_back(fallback_location: root_path, flash: { error: InvisibleCaptcha.timestamp_error_message })
|
31
|
+
else
|
32
|
+
redirect_to :back, flash: { error: InvisibleCaptcha.timestamp_error_message }
|
33
|
+
end
|
30
34
|
end
|
31
35
|
end
|
32
36
|
|
data/spec/controllers_spec.rb
CHANGED
@@ -3,6 +3,22 @@ require 'spec_helper'
|
|
3
3
|
describe InvisibleCaptcha::ControllerExt, type: :controller do
|
4
4
|
render_views
|
5
5
|
|
6
|
+
def switchable_post(action, params = {})
|
7
|
+
if ::Rails::VERSION::STRING > '5'
|
8
|
+
post action, params: params
|
9
|
+
else
|
10
|
+
post action, params
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def switchable_put(action, params = {})
|
15
|
+
if ::Rails::VERSION::STRING > '5'
|
16
|
+
put action, params: params
|
17
|
+
else
|
18
|
+
put action, params
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
6
22
|
before do
|
7
23
|
@controller = TopicsController.new
|
8
24
|
InvisibleCaptcha.timestamp_threshold = 1
|
@@ -12,9 +28,9 @@ describe InvisibleCaptcha::ControllerExt, type: :controller do
|
|
12
28
|
context 'without invisible_captcha_timestamp in session' do
|
13
29
|
it 'fails like if it was submitted too fast' do
|
14
30
|
request.env['HTTP_REFERER'] = 'http://test.host/topics'
|
15
|
-
|
31
|
+
switchable_post :create, topic: { title: 'foo' }
|
16
32
|
|
17
|
-
expect(response).to redirect_to
|
33
|
+
expect(response).to redirect_to 'http://test.host/topics'
|
18
34
|
expect(flash[:error]).to eq(InvisibleCaptcha.timestamp_error_message)
|
19
35
|
end
|
20
36
|
end
|
@@ -23,7 +39,7 @@ describe InvisibleCaptcha::ControllerExt, type: :controller do
|
|
23
39
|
it 'does not fail like if it was submitted too fast' do
|
24
40
|
request.env['HTTP_REFERER'] = 'http://test.host/topics'
|
25
41
|
InvisibleCaptcha.timestamp_enabled = false
|
26
|
-
|
42
|
+
switchable_post :create, topic: { title: 'foo' }
|
27
43
|
|
28
44
|
expect(flash[:error]).not_to be_present
|
29
45
|
expect(response.body).to be_present
|
@@ -37,14 +53,14 @@ describe InvisibleCaptcha::ControllerExt, type: :controller do
|
|
37
53
|
|
38
54
|
it 'fails if submission before timestamp_threshold' do
|
39
55
|
request.env['HTTP_REFERER'] = 'http://test.host/topics'
|
40
|
-
|
56
|
+
switchable_post :create, topic: { title: 'foo' }
|
41
57
|
|
42
|
-
expect(response).to redirect_to
|
58
|
+
expect(response).to redirect_to 'http://test.host/topics'
|
43
59
|
expect(flash[:error]).to eq(InvisibleCaptcha.timestamp_error_message)
|
44
60
|
end
|
45
61
|
|
46
62
|
it 'allow custom on_timestamp_spam callback' do
|
47
|
-
|
63
|
+
switchable_put :update, id: 1, topic: { title: 'bar' }
|
48
64
|
|
49
65
|
expect(response).to redirect_to(root_path)
|
50
66
|
end
|
@@ -53,7 +69,7 @@ describe InvisibleCaptcha::ControllerExt, type: :controller do
|
|
53
69
|
it 'passes if submission on or after timestamp_threshold' do
|
54
70
|
sleep InvisibleCaptcha.timestamp_threshold
|
55
71
|
|
56
|
-
|
72
|
+
switchable_post :create, topic: { title: 'foo' }
|
57
73
|
|
58
74
|
expect(flash[:error]).not_to be_present
|
59
75
|
expect(response.body).to be_present
|
@@ -62,7 +78,7 @@ describe InvisibleCaptcha::ControllerExt, type: :controller do
|
|
62
78
|
it 'allow to set a custom timestamp_threshold per action' do
|
63
79
|
sleep 2 # custom threshold
|
64
80
|
|
65
|
-
|
81
|
+
switchable_post :publish, id: 1
|
66
82
|
|
67
83
|
expect(flash[:error]).not_to be_present
|
68
84
|
expect(response.body).to be_present
|
@@ -78,19 +94,19 @@ describe InvisibleCaptcha::ControllerExt, type: :controller do
|
|
78
94
|
end
|
79
95
|
|
80
96
|
it 'fails with spam' do
|
81
|
-
|
97
|
+
switchable_post :create, topic: { subtitle: 'foo' }
|
82
98
|
|
83
99
|
expect(response.body).to be_blank
|
84
100
|
end
|
85
101
|
|
86
102
|
it 'passes with no spam' do
|
87
|
-
|
103
|
+
switchable_post :create, topic: { title: 'foo' }
|
88
104
|
|
89
105
|
expect(response.body).to be_present
|
90
106
|
end
|
91
107
|
|
92
108
|
it 'allow custom on_spam callback' do
|
93
|
-
|
109
|
+
switchable_put :update, id: 1, topic: { subtitle: 'foo' }
|
94
110
|
|
95
111
|
expect(response.body).to redirect_to(new_topic_path)
|
96
112
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: invisible_captcha
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Marc Anguera Insa
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-07-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -99,6 +99,7 @@ files:
|
|
99
99
|
- gemfiles/rails_4.1.gemfile
|
100
100
|
- gemfiles/rails_4.2.gemfile
|
101
101
|
- gemfiles/rails_5.0.gemfile
|
102
|
+
- gemfiles/rails_5.1.gemfile
|
102
103
|
- invisible_captcha.gemspec
|
103
104
|
- lib/invisible_captcha.rb
|
104
105
|
- lib/invisible_captcha/controller_ext.rb
|