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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: dd5997c0dafd14fd6ddf1dea96a9cbc3c33ae172
4
- data.tar.gz: b615f78ab1c2ffa6a62e9633b6d2edee8c6b3de5
3
+ metadata.gz: 80d28e320294b2c40e8df6975a0efe8ce36ae9b3
4
+ data.tar.gz: 27fbdf58a83d4a84475e05cea92d706dc6c37b96
5
5
  SHA512:
6
- metadata.gz: 2bd891628a17962b2e098bd5e10b60757ecd4fe6ec6012d8dbb484ed6914acd46a4e9981299ad9b117d448433eb07abf86bd3046c67dd76ce8318de92ea1afe3
7
- data.tar.gz: 4e7730bd1d87dcf0e5f095af3bff41deb830c5a37a17385b4048445e78f6249ae700487b8077b01685f90f6b3e89a9d5c9ce438a60cc108446594897e23263b8
6
+ metadata.gz: d49d4f389ea60c174c1ab89d31fdb2414f0a7c8626a3a75a11ab1e0cd18fd1e3fbee07ff21d1b6456249c2b98e49748c6dbec829ef99403956f299ecaca3a5ba
7
+ data.tar.gz: 7d8b1e7937307cbf2493de51cf2e38b8acf090455756fa719c2482530fe90a64d73c9fa07cef7da2f1aacb4d6dd011d350ee5c557cbe626b30290f05c33b16d4
@@ -5,13 +5,15 @@ cache: bundler
5
5
  sudo: false
6
6
 
7
7
  rvm:
8
- - 2.4.0
9
- - 2.3.3
10
- - 2.2.6
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.4.0
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.0
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
@@ -1,3 +1,7 @@
1
+ appraise "rails-5.1" do
2
+ gem "rails", "~> 5.1.0"
3
+ end
4
+
1
5
  appraise "rails-5.0" do
2
6
  gem "rails", "~> 5.0.0"
3
7
  end
@@ -0,0 +1,7 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "rails", "~> 5.1.0"
6
+
7
+ gemspec :path => "../"
@@ -26,7 +26,11 @@ module InvisibleCaptcha
26
26
  if action = options[:on_timestamp_spam]
27
27
  send(action)
28
28
  else
29
- redirect_to :back, flash: { error: InvisibleCaptcha.timestamp_error_message }
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
 
@@ -1,3 +1,3 @@
1
1
  module InvisibleCaptcha
2
- VERSION = "0.9.2"
2
+ VERSION = "0.9.3"
3
3
  end
@@ -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
- post :create, topic: { title: 'foo' }
31
+ switchable_post :create, topic: { title: 'foo' }
16
32
 
17
- expect(response).to redirect_to :back
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
- post :create, topic: { title: 'foo' }
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
- post :create, topic: { title: 'foo' }
56
+ switchable_post :create, topic: { title: 'foo' }
41
57
 
42
- expect(response).to redirect_to :back
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
- put :update, id: 1, topic: { title: 'bar' }
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
- post :create, topic: { title: 'foo' }
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
- post :publish, id: 1
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
- post :create, topic: { subtitle: 'foo' }
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
- post :create, topic: { title: 'foo' }
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
- put :update, id: 1, topic: { subtitle: 'foo' }
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.2
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-01-04 00:00:00.000000000 Z
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