invisible_captcha 0.12.0 → 0.12.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 69fb2a8c65477376dbea0a7162151d6c100282dc
4
- data.tar.gz: b5f5134aff6f55b7d766972151ce85194cadd3e6
2
+ SHA256:
3
+ metadata.gz: f0904f2d5218d84ee62e3328259b217c7a3772497c8ecf47ed94a34b4bc083f8
4
+ data.tar.gz: a2e806057b7cbe29927bbb705e342426b666cbc5c6bc823fe97434d912b322cc
5
5
  SHA512:
6
- metadata.gz: 390075abc680625ac3eee6b237765336554c5e7eec9c06acb368aa1b7f403ef4c1fc8b7ff21170fde71217b7704dc85b4d797e2f4760c9e255a464c7367deda5
7
- data.tar.gz: be7d59009de1f3d70485fc19dd6e3bb5b8f0537a5f2e51b879a33ff8a4de9d7832bc81583ca3cf2f5f229ddd1fdde8c54f0e1201127a4e6941974b410f0127b2
6
+ metadata.gz: 9f0ac495f41f5937859077d758e88884e369aa534d97b595fd4dc560923ce8cb9deb31bd3c487f33d04c82878eeed9ada45508b511e8ff77320d762979f0ea7d
7
+ data.tar.gz: 953bfa53bf999143d76c45f785e11e80e8fbd44a20fc0182c6d87e009ece31610f9b699049e01e01b6fcfeb887de968a656f1dd437973a5d54e8d43cc6c170bb
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
@@ -3,23 +3,38 @@ cache: bundler
3
3
  sudo: false
4
4
  rvm:
5
5
  - ruby-head
6
- - 2.5.1
7
- - 2.4.4
8
- - 2.3.6
9
- - 2.2.9
6
+ - 2.6.2
7
+ - 2.5.5
8
+ - 2.4.5
9
+ - 2.3.8
10
+ - 2.2.10
10
11
  gemfile:
12
+ - gemfiles/rails_6.0.gemfile
11
13
  - gemfiles/rails_5.2.gemfile
12
14
  - gemfiles/rails_5.1.gemfile
13
15
  - gemfiles/rails_5.0.gemfile
14
16
  - gemfiles/rails_4.2.gemfile
15
17
  - gemfiles/rails_3.2.gemfile
18
+ before_install:
19
+ # Rails 4.x requires Bundler version < 2.0.
20
+ - "find /home/travis/.rvm/rubies -wholename '*default/bundler-*.gemspec' -delete"
21
+ - rvm @global do gem uninstall bundler -a -x
22
+ - rvm @global do yes | gem install bundler -v '< 2'
16
23
  matrix:
17
24
  exclude:
25
+ - rvm: 2.4.5
26
+ gemfile: gemfiles/rails_6.0.gemfile
27
+ - rvm: 2.3.8
28
+ gemfile: gemfiles/rails_6.0.gemfile
29
+ - rvm: 2.2.10
30
+ gemfile: gemfiles/rails_6.0.gemfile
18
31
  - rvm: ruby-head
19
32
  gemfile: gemfiles/rails_3.2.gemfile
20
- - rvm: 2.5.1
33
+ - rvm: 2.6.2
21
34
  gemfile: gemfiles/rails_3.2.gemfile
22
- - rvm: 2.4.4
35
+ - rvm: 2.5.5
36
+ gemfile: gemfiles/rails_3.2.gemfile
37
+ - rvm: 2.4.5
23
38
  gemfile: gemfiles/rails_3.2.gemfile
24
39
  allow_failures:
25
40
  - rvm: ruby-head
data/Appraisals CHANGED
@@ -1,3 +1,7 @@
1
+ appraise "rails-6.0" do
2
+ gem "rails", "6.0.0.rc1"
3
+ end
4
+
1
5
  appraise "rails-5.2" do
2
6
  gem "rails", "~> 5.2.0"
3
7
  end
@@ -11,7 +15,7 @@ appraise "rails-5.0" do
11
15
  end
12
16
 
13
17
  appraise "rails-4.2" do
14
- gem "rails", github: 'rails/rails', branch: '4-2-stable'
18
+ gem "rails", "~> 4.2.0"
15
19
  end
16
20
 
17
21
  appraise "rails-3.2" do
@@ -2,6 +2,11 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file.
4
4
 
5
+ ## [0.12.1]
6
+
7
+ - Clear timestamp stored in `session[:invisible_captcha_timestamp]` (#50)
8
+ - Rails 6 support
9
+
5
10
  ## [0.12.0]
6
11
 
7
12
  - Honeypot input with autocomplete="off" by default (#42)
@@ -92,6 +97,7 @@ All notable changes to this project will be documented in this file.
92
97
 
93
98
  - First version of controller filters
94
99
 
100
+ [0.12.1]: https://github.com/markets/invisible_captcha/compare/v0.12.0...v0.12.1
95
101
  [0.12.0]: https://github.com/markets/invisible_captcha/compare/v0.11.0...v0.12.0
96
102
  [0.11.0]: https://github.com/markets/invisible_captcha/compare/v0.10.0...v0.11.0
97
103
  [0.10.0]: https://github.com/markets/invisible_captcha/compare/v0.9.3...v0.10.0
data/README.md CHANGED
@@ -21,18 +21,12 @@ It also comes with a time-sensitive :hourglass: form submission.
21
21
 
22
22
  Invisible Captcha is tested against Rails `>= 3.2` and Ruby `>= 2.2`.
23
23
 
24
- Add this line to you Gemfile:
24
+ Add this line to your Gemfile and then execute `bundle install`:
25
25
 
26
- ```
26
+ ```ruby
27
27
  gem 'invisible_captcha'
28
28
  ```
29
29
 
30
- Or install the gem manually:
31
-
32
- ```
33
- $ gem install invisible_captcha
34
- ```
35
-
36
30
  ## Usage
37
31
 
38
32
  View code:
@@ -166,6 +160,26 @@ You can override the english ones in your own i18n config files as well as add n
166
160
 
167
161
  If you intend to use I18n with `invisible_captcha`, you _must not_ set `sentence_for_humans` or `timestamp_error_message` to strings in the setup phase.
168
162
 
163
+ ## Testing your controllers
164
+
165
+ If you're encountering unexpected behaviour while testing controllers that use the `invisible_captcha` action filter, you may want to disable timestamp check for the test environment:
166
+
167
+ ```ruby
168
+ # test/test_helper.rb, spec/rails_helper.rb, ...
169
+ InvisibleCaptcha.timestamp_enabled = false
170
+ ```
171
+
172
+ Another option is to wait for the timestamp check to be valid:
173
+
174
+ ```ruby
175
+ # Maybe in a before block
176
+ InvisibleCaptcha.init!
177
+ InvisibleCaptcha.timestamp_threshold = 1
178
+
179
+ # Before testing your controller action
180
+ sleep InvisibleCaptcha.timestamp_threshold
181
+ ```
182
+
169
183
  ## Contribute
170
184
 
171
185
  Any kind of idea, feedback or bug report are welcome! Open an [issue](https://github.com/markets/invisible_captcha/issues) or send a [pull request](https://github.com/markets/invisible_captcha/pulls).
@@ -4,4 +4,4 @@ source "https://rubygems.org"
4
4
 
5
5
  gem "rails", "~> 3.2.0"
6
6
 
7
- gemspec :path => "../"
7
+ gemspec path: "../"
@@ -2,6 +2,6 @@
2
2
 
3
3
  source "https://rubygems.org"
4
4
 
5
- gem "rails", :github => "rails/rails", :branch => "4-2-stable"
5
+ gem "rails", "~> 4.2.0"
6
6
 
7
- gemspec :path => "../"
7
+ gemspec path: "../"
@@ -4,4 +4,4 @@ source "https://rubygems.org"
4
4
 
5
5
  gem "rails", "~> 5.0.0"
6
6
 
7
- gemspec :path => "../"
7
+ gemspec path: "../"
@@ -4,4 +4,4 @@ source "https://rubygems.org"
4
4
 
5
5
  gem "rails", "~> 5.1.0"
6
6
 
7
- gemspec :path => "../"
7
+ gemspec path: "../"
@@ -4,4 +4,4 @@ source "https://rubygems.org"
4
4
 
5
5
  gem "rails", "~> 5.2.0"
6
6
 
7
- gemspec :path => "../"
7
+ gemspec path: "../"
@@ -0,0 +1,7 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "rails", "6.0.0.rc1"
6
+
7
+ gemspec path: "../"
@@ -22,6 +22,8 @@ module InvisibleCaptcha
22
22
  elsif honeypot_spam?(options)
23
23
  on_spam(options)
24
24
  end
25
+
26
+ clear_session
25
27
  end
26
28
 
27
29
  def on_timestamp_spam(options = {})
@@ -73,6 +75,10 @@ module InvisibleCaptcha
73
75
  false
74
76
  end
75
77
 
78
+ def clear_session
79
+ session.delete(:invisible_captcha_timestamp) if session[:invisible_captcha_timestamp]
80
+ end
81
+
76
82
  def honeypot_spam?(options = {})
77
83
  honeypot = options[:honeypot]
78
84
  scope = options[:scope] || controller_name.singularize
@@ -1,3 +1,3 @@
1
1
  module InvisibleCaptcha
2
- VERSION = "0.12.0"
2
+ VERSION = "0.12.1"
3
3
  end
@@ -1,6 +1,4 @@
1
- require 'spec_helper'
2
-
3
- describe InvisibleCaptcha::ControllerExt, type: :controller do
1
+ RSpec.describe InvisibleCaptcha::ControllerExt, type: :controller do
4
2
  render_views
5
3
 
6
4
  def switchable_post(action, params = {})
@@ -60,6 +58,9 @@ describe InvisibleCaptcha::ControllerExt, type: :controller do
60
58
 
61
59
  expect(response).to redirect_to 'http://test.host/topics'
62
60
  expect(flash[:error]).to eq(InvisibleCaptcha.timestamp_error_message)
61
+
62
+ # Make sure session is cleared
63
+ expect(session[:invisible_captcha_timestamp]).to be_nil
63
64
  end
64
65
 
65
66
  it 'allow a custom on_timestamp_spam callback' do
@@ -72,10 +73,17 @@ describe InvisibleCaptcha::ControllerExt, type: :controller do
72
73
  it 'passes if submission on or after timestamp_threshold' do
73
74
  sleep InvisibleCaptcha.timestamp_threshold
74
75
 
75
- switchable_post :create, topic: { title: 'foo' }
76
+ switchable_post :create, topic: {
77
+ title: 'foobar',
78
+ author: 'author',
79
+ body: 'body that passes validation'
80
+ }
76
81
 
77
82
  expect(flash[:error]).not_to be_present
78
83
  expect(response.body).to be_present
84
+
85
+ # Make sure session is cleared
86
+ expect(session[:invisible_captcha_timestamp]).to be_nil
79
87
  end
80
88
 
81
89
  it 'allow to set a custom timestamp_threshold per action' do
@@ -1,6 +1,4 @@
1
- require 'spec_helper'
2
-
3
- describe InvisibleCaptcha do
1
+ RSpec.describe InvisibleCaptcha do
4
2
  it 'initialize with defaults' do
5
3
  InvisibleCaptcha.init!
6
4
 
@@ -1,12 +1,28 @@
1
1
  ENV['RAILS_ENV'] = 'test'
2
+
2
3
  require File.expand_path("../dummy/config/environment.rb", __FILE__)
3
4
  require 'rspec/rails'
4
5
  require 'invisible_captcha'
5
6
 
6
7
  RSpec.configure do |config|
7
- config.order = 'random'
8
+ config.disable_monkey_patching!
9
+ config.order = :random
8
10
  config.expect_with :rspec
9
11
  config.mock_with :rspec do |mocks|
10
12
  mocks.verify_partial_doubles = true
11
13
  end
12
14
  end
15
+
16
+ # Rails 4.2 call `initialize` inside `recycle!`. However Ruby 2.6 doesn't allow calling `initialize` twice.
17
+ # More info: https://github.com/rails/rails/issues/34790
18
+ if RUBY_VERSION >= "2.6.0" && Rails.version < "5"
19
+ module ActionController
20
+ class TestResponse < ActionDispatch::TestResponse
21
+ def recycle!
22
+ @mon_mutex_owner_object_id = nil
23
+ @mon_mutex = nil
24
+ initialize
25
+ end
26
+ end
27
+ end
28
+ end
@@ -1,6 +1,4 @@
1
- require 'spec_helper'
2
-
3
- describe InvisibleCaptcha::ViewHelpers, type: :helper do
1
+ RSpec.describe InvisibleCaptcha::ViewHelpers, type: :helper do
4
2
  before(:each) do
5
3
  allow(Time.zone).to receive(:now).and_return(Time.zone.parse('Feb 19 1986'))
6
4
  allow(InvisibleCaptcha).to receive(:css_strategy).and_return("display:none;")
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.12.0
4
+ version: 0.12.1
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: 2018-12-03 00:00:00.000000000 Z
11
+ date: 2019-05-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -89,6 +89,7 @@ extensions: []
89
89
  extra_rdoc_files: []
90
90
  files:
91
91
  - ".gitignore"
92
+ - ".rspec"
92
93
  - ".travis.yml"
93
94
  - Appraisals
94
95
  - CHANGELOG.md
@@ -101,6 +102,7 @@ files:
101
102
  - gemfiles/rails_5.0.gemfile
102
103
  - gemfiles/rails_5.1.gemfile
103
104
  - gemfiles/rails_5.2.gemfile
105
+ - gemfiles/rails_6.0.gemfile
104
106
  - invisible_captcha.gemspec
105
107
  - lib/invisible_captcha.rb
106
108
  - lib/invisible_captcha/controller_ext.rb
@@ -170,8 +172,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
170
172
  - !ruby/object:Gem::Version
171
173
  version: '0'
172
174
  requirements: []
173
- rubyforge_project:
174
- rubygems_version: 2.6.13
175
+ rubygems_version: 3.0.3
175
176
  signing_key:
176
177
  specification_version: 4
177
178
  summary: Simple honeypot protection for RoR apps