acts_as_textcaptcha 3.0.6 → 3.0.7

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
2
  SHA1:
3
- metadata.gz: 7a05fc4f158974110a4488b74394b3b7fbd8085f
4
- data.tar.gz: 818abaed769b20d11370add99665c726f504a48e
3
+ metadata.gz: d0ed524bfc8d05da4dcdf2fb6a8b86a3f5d8e687
4
+ data.tar.gz: 60b3dcfd3c6fb65c71d5d096000b7c61c155e569
5
5
  SHA512:
6
- metadata.gz: 0d1efdc637a9a5ea7975bb342bff97868aae57969c5b8a4aed6450278a4fa26c977303bee4a92aa5e240f6d7ee391440e8b11ec527589cd4488cb3b1e35842a0
7
- data.tar.gz: be6d33e348f483bdb4c2711979b750209e3bf5132188ccf38273b035a1b67b83b4f7fd4c26989cd6c713082e8f8b1d1bb2541cf85dd79680f4cf7e47cdcf283a
6
+ metadata.gz: 6342b17c8d96acfe3cc00c1880ce041bcda55859c133099ecea51d3ec26b4c4ef11f3b92fbc8e5a67616c9f86a93152d1bf03d097af272da0fa40c30bc16326e
7
+ data.tar.gz: 3ec376171d993c203a4c13b463feb8fb815cfb5adc0ba9897cb79b58e8a105cfe6e85ca213a6d828490bd86e6d8cee5232fafec05a30e0fed81e9953b611b2e9
data/.travis.yml CHANGED
@@ -2,4 +2,6 @@ rvm:
2
2
  - 1.8.7
3
3
  - 1.9.2
4
4
  - 1.9.3
5
+ - 2.0.0
5
6
  - ree
7
+ - rbx
data/Gemfile CHANGED
@@ -1,2 +1,2 @@
1
- source 'http://rubygems.org'
1
+ source 'https://rubygems.org'
2
2
  gemspec
data/README.rdoc CHANGED
@@ -4,9 +4,9 @@
4
4
 
5
5
  ActsAsTextcaptcha provides spam protection for your Rails models using logic questions from the excellent {Text CAPTCHA}[http://textcaptcha.com/] web service (by {Rob Tuley}[http://openknot.com/me/] of {Openknot}[http://openknot.com/]). It is also possible to configure your own questions and answers instead of using this API (or as a fall back in the unlikely event of the web service being unavailable)
6
6
 
7
- The gem makes use of {bcrypt}[http://bcrypt-ruby.rubyforge.org/] encryption when comparing a guess with the correct answer(s). This gem is actively maintained, has good test coverage and is compatible with Rails 2.3.* and 3. If you have any issues {please report them here}[https://github.com/matthutchinson/acts_as_textcaptcha/issues].
7
+ The gem makes use of {bcrypt}[http://bcrypt-ruby.rubyforge.org/] encryption when comparing a guess with the correct answer(s). This gem is actively maintained, has good test coverage and is compatible with Rails 2.3.*, Rails 3 and 4. If you have any issues {please report them here}[https://github.com/matthutchinson/acts_as_textcaptcha/issues].
8
8
 
9
- Text CAPTCHA's logic questions are aimed at a child's age of 7, so can be solved easily by all but the most cognitively impaired users. As they involve human logic, such questions cannot be solved by a robot. There are both advantages and disadvantages for using logic questions over image based captchas, {find out more at Text CAPTCHA}[http://textcaptcha.com/why].
9
+ Text CAPTCHA's logic questions are aimed at a child's age of 7, so they can be solved easily by even the most cognitively impaired users. As they involve human logic, questions cannot be solved by a robot. There are both advantages and disadvantages for using logic questions over image based captchas, {find out more at Text CAPTCHA}[http://textcaptcha.com/why].
10
10
 
11
11
  == Demo
12
12
 
@@ -14,7 +14,7 @@ Here's a {fully working demo on heroku}[http://textcaptcha.heroku.com]!
14
14
 
15
15
  == Installing
16
16
 
17
- === Rails 3
17
+ === Rails
18
18
 
19
19
  Just add the following to your Gemfile, then `bundle install`;
20
20
 
@@ -26,13 +26,7 @@ Add this to your environment.rb file, then `gem install acts_as_textcaptcha`;
26
26
 
27
27
  config.gem 'acts_as_textcaptcha'
28
28
 
29
- === As a plugin
30
-
31
- Or install as a plugin with;
32
-
33
- rails plugin install git@github.com:matthutchinson/acts_as_textcaptcha.git
34
- OR
35
- script/plugin install git@github.com:matthutchinson/acts_as_textcaptcha.git
29
+ === Or as a plugin
36
30
 
37
31
  If you do decide to install this as a Rails plugin, you'll have to manually include the bcrypt-ruby gem in your Gemfile or environment config. Like so;
38
32
 
@@ -40,15 +34,21 @@ If you do decide to install this as a Rails plugin, you'll have to manually incl
40
34
  OR
41
35
  config.gem 'bcrypt-ruby', :lib => 'bcrypt'
42
36
 
37
+ Then install the plugin with rails or script/rails as follows;
38
+
39
+ rails plugin install git@github.com:matthutchinson/acts_as_textcaptcha.git
40
+ OR
41
+ script/plugin install git@github.com:matthutchinson/acts_as_textcaptcha.git
42
+
43
43
  == Setting up
44
44
 
45
45
  *NOTE:* The procedure for configuring your app *changed significantly* from v2.* to v3.* If you are having problems please carefully check the instructions below.
46
46
 
47
- First {grab an API key for your website}[http://textcaptcha.com/api] then open Rails console (or any irb session) and generate a new BCrypt salt by typing;
47
+ First {grab an API key for your website}[http://textcaptcha.com/api] then open you Rails console (or any irb session) and generate a new BCrypt salt by typing;
48
48
 
49
49
  require 'bcrypt';BCrypt::Engine.generate_salt
50
50
 
51
- Next configure which models are to be spam protected like so;
51
+ Next add the following code to models you'd like to spam protect;
52
52
 
53
53
  class Comment < ActiveRecord::Base
54
54
  # (this is the most basic way to configure the gem, with an API key and Salt only)
@@ -81,7 +81,7 @@ Finally, in your form view add the spam question and answer fields using the tex
81
81
  </div>
82
82
  <% end %>
83
83
 
84
- *NOTE:* If you'd rather NOT use this helper and prefer to write all your own view code, see the html produced from the textcaptcha_fields method in the gem source code.
84
+ *NOTE:* If you'd rather NOT use this helper and prefer to write your own view code, see the html produced from the textcaptcha_fields method in the source code.
85
85
 
86
86
  === Toggling Textcaptcha
87
87
 
@@ -173,8 +173,8 @@ For more details on the code please check the {documentation}[http://rdoc.info/p
173
173
 
174
174
  What do you need?
175
175
 
176
- * {Rails}[http://github.com/rails/rails] >= 2.3.2 (including Rails 3)
177
- * {Ruby}[http://ruby-lang.org/] >= 1.8.7 (also tested with REE and Ruby 1.9.2)
176
+ * {Rails}[http://github.com/rails/rails] >= 2.3.2 (including Rails 3 and 4)
177
+ * {Ruby}[http://ruby-lang.org/] >= 1.8.7 (also tested with REE, RBX, 1.9.2, 1.9.3, 2.0.0)
178
178
  * {bcrypt-ruby}[http://bcrypt-ruby.rubyforge.org/] gem (to securely encrypt spam answers)
179
179
  * {Text CAPTCHA API key}[http://textcaptcha.com/register] (_optional_, since you can define your own logic questions)
180
180
  * {MiniTest}[https://rubygems.org/gems/minitest] (_optional_ if you want to run the tests, built into Ruby 1.9)
@@ -199,14 +199,13 @@ What do you need?
199
199
  == Todo
200
200
 
201
201
  * Achieve 100% test coverage, currently at 93%
202
+ * Remove support for Rails 2.3.* in a future gem release (clean code and tests for this)
202
203
 
203
204
  == Usage
204
205
 
205
- This gem is used in a number of production websites and apps. It was originally extracted from code developed for {Bugle}[http://bugleblogs.com]
206
+ This gem is used in a number of production websites and apps. It was originally extracted from code developed for {Bugle}[http://bugleblogs.com]. If you're happily using acts_as_textcaptcha in production, let me know and I'll add you to this list!
206
207
 
207
208
  * {matthewhutchinson.net}[http://matthewhutchinson.net]
208
209
  * {pmFAQtory.com}[http://pmfaqtory.com]
209
210
  * {The FAQtory}[http://faqtory.heroku.com]
210
211
  * {DPT Watch, San Francisco}[http://www.dptwatch.com]
211
-
212
- (if you're happily using acts_as_textcaptcha in production, let me know and I'll add you to this list)
@@ -21,7 +21,7 @@ Gem::Specification.new do |s|
21
21
  s.test_files = `git ls-files -- {test}/*`.split("\n")
22
22
  s.require_paths = ["lib"]
23
23
 
24
- s.add_dependency('bcrypt-ruby')
24
+ s.add_dependency('bcrypt-ruby', '~> 3.0.1')
25
25
 
26
26
  s.add_development_dependency('rails')
27
27
  s.add_development_dependency('bundler')
@@ -30,4 +30,5 @@ Gem::Specification.new do |s|
30
30
  s.add_development_dependency('rdoc')
31
31
  s.add_development_dependency('sqlite3')
32
32
  s.add_development_dependency('fakeweb')
33
+ s.add_development_dependency('strong_parameters')
33
34
  end
@@ -35,10 +35,10 @@ module ActsAsTextcaptcha
35
35
  attr_accessor :spam_question, :spam_answers, :spam_answer, :skip_textcaptcha
36
36
 
37
37
  if respond_to?(:accessible_attributes)
38
- if accessible_attributes.nil?
38
+ if accessible_attributes.nil? && respond_to?(:attr_protected)
39
39
  attr_protected :spam_question
40
40
  attr_protected :skip_textcaptcha
41
- else
41
+ elsif respond_to?(:attr_accessible)
42
42
  attr_accessible :spam_answer, :spam_answers
43
43
  end
44
44
  end
@@ -1,3 +1,3 @@
1
1
  module ActsAsTextcaptcha
2
- VERSION = "3.0.6"
2
+ VERSION = "3.0.7"
3
3
  end
data/test/schema.rb CHANGED
@@ -19,4 +19,8 @@ ActiveRecord::Schema.define(:version => 0) do
19
19
  create_table :notes, :force => true do |t|
20
20
  t.string :name
21
21
  end
22
+
23
+ create_table :strong_widgets, :force => true do |t|
24
+ t.string :name
25
+ end
22
26
  end
data/test/test_helper.rb CHANGED
@@ -16,8 +16,7 @@ end
16
16
  require 'minitest/autorun'
17
17
  require 'fakeweb'
18
18
 
19
- require 'active_record'
20
- require 'rails'
19
+ require 'rails/all'
21
20
 
22
21
  require 'acts_as_textcaptcha'
23
22
  require './test/test_models'
data/test/test_models.rb CHANGED
@@ -49,3 +49,12 @@ class Contact
49
49
  acts_as_textcaptcha :questions => [{ :question => 'one+1', :answers => "2,two,апельсин" }],
50
50
  :bcrypt_salt => '$2a$10$j0bmycH.SVfD1b5mpEGPpe'
51
51
  end
52
+
53
+ # ActiveRecord model using the strong parameters gem
54
+ require 'strong_parameters'
55
+
56
+ class StrongWidget < ActiveRecord::Base
57
+ include ActiveModel::ForbiddenAttributesProtection
58
+ acts_as_textcaptcha 'questions' => [{ 'question' => '1+1', 'answers' => '2,two' }],
59
+ 'bcrypt_salt' => '$2a$10$j0bmycH.SVfD1b5mpEGPpe'
60
+ end
@@ -73,6 +73,25 @@ describe 'Textcaptcha' do
73
73
  end
74
74
  end
75
75
 
76
+ describe 'with strong parameters' do
77
+
78
+ before(:each) do
79
+ @widget = StrongWidget.new
80
+ end
81
+
82
+ it 'should work' do
83
+ @widget.spam_answers.must_be_nil
84
+ @widget.textcaptcha
85
+ @widget.spam_question.must_equal('1+1')
86
+ @widget.valid?.must_equal false
87
+ @widget.errors[:spam_answer].first.must_equal('is incorrect, try another question instead')
88
+
89
+ @widget.spam_answer = 'two'
90
+ @widget.valid?.must_equal true
91
+ @widget.errors[:spam_answer].must_be_empty
92
+ end
93
+ end
94
+
76
95
  describe 'encryption' do
77
96
 
78
97
  before(:each) do
metadata CHANGED
@@ -1,29 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: acts_as_textcaptcha
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.6
4
+ version: 3.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matthew Hutchinson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-03-15 00:00:00.000000000 Z
11
+ date: 2013-04-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bcrypt-ruby
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '>='
17
+ - - ~>
18
18
  - !ruby/object:Gem::Version
19
- version: '0'
19
+ version: 3.0.1
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - '>='
24
+ - - ~>
25
25
  - !ruby/object:Gem::Version
26
- version: '0'
26
+ version: 3.0.1
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rails
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -122,6 +122,20 @@ dependencies:
122
122
  - - '>='
123
123
  - !ruby/object:Gem::Version
124
124
  version: '0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: strong_parameters
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - '>='
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - '>='
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
125
139
  description: |-
126
140
  Simple question/answer based spam protection for your Rails models.
127
141
  You can define your own logic questions and/or fetch questions from the textcaptcha.com API.
checksums.yaml.gz.asc DELETED
@@ -1,12 +0,0 @@
1
- -----BEGIN PGP SIGNATURE-----
2
- Version: GnuPG/MacGPG2 v2.0.19 (Darwin)
3
- Comment: GPGTools - http://gpgtools.org
4
-
5
- iQEcBAABAgAGBQJRQyWJAAoJEN3AtSzXeMK41+oH/iiYyOzTRe+jd2tcUvxBREtX
6
- WEPaup/YfTYZ5lXcYC5fq8CCyFnHHf9cCypoRXkWTKFXicZ9je3I3P0aKohx94wO
7
- yYhvBGIPrh0ZtEAGGgXIzOT3oFoqyFUqk+Bdzdig2jBmC1RMLnN6Eyk9YE+YMe6G
8
- BFwKFeMyqtSL2i7Ch0L1VUX3u9UqkcOYiNnDp2viabkX7wF+tYVazjM5pD2e25Hh
9
- /tH5xg7shsB7s48uf/JFzuTHyK/K5xim8T2ymkSfrFslnN5ipqgypK0NJIehTDK0
10
- nxAPkKEj8LWVmy81xnYtA0iIY6VgzgLmbB/ynzK2kNLi3Q1tqYIqntmG6hFJR9I=
11
- =R7cK
12
- -----END PGP SIGNATURE-----
data.tar.gz.asc DELETED
@@ -1,12 +0,0 @@
1
- -----BEGIN PGP SIGNATURE-----
2
- Version: GnuPG/MacGPG2 v2.0.19 (Darwin)
3
- Comment: GPGTools - http://gpgtools.org
4
-
5
- iQEcBAABAgAGBQJRQyWJAAoJEN3AtSzXeMK4Ga4H/1nZEp/Bm2PYFsajQYVq725o
6
- J25M5G9KjBdLjBqtxSCHUWpSO9ZUDpjdju211WQ95H79PrnUiNKRkJd7U7+cGLtm
7
- hG1PjYn/xVqsY35enpQFnkTMHYElCUIOwxOsXygh137f810UWJ9Ekcfzaj7SAHXi
8
- mN/qtQ5Nzl4wfWXDLeAJArBQ8lwPcevqmZ6L0ChPsOywJkpWFa/X+apB5dCwe+GY
9
- Ri+lnU7ffHc/XM2evBXF710FxiEfjLkpuAu+ZHJsCM4ji46kcJ5ONqi7LF64WX/z
10
- 2jCayartkWVme9d/Ol5F75Cp7Jhqr9V4yU41zuOUK7CPaeUcGAEDVC3svsIQ+Z0=
11
- =VZFb
12
- -----END PGP SIGNATURE-----
metadata.gz.asc DELETED
@@ -1,12 +0,0 @@
1
- -----BEGIN PGP SIGNATURE-----
2
- Version: GnuPG/MacGPG2 v2.0.19 (Darwin)
3
- Comment: GPGTools - http://gpgtools.org
4
-
5
- iQEcBAABAgAGBQJRQyWJAAoJEN3AtSzXeMK4NZQH/0AYiZyO5bS/K5/u6AvRmOaY
6
- kCaEPuBI3kSHT55R89+4V3JKVo28UwRXK8OdbNHeiq3TSNyl/goWNPYXHoVrG8UW
7
- Am/SF7VPsxJGgzov/IlSMy3iRBD4ZXdV8rF75ngku5gB4/SXigHMB//Ni0IshLWY
8
- t0Q34TSFY1Tj3uH4PwXRPWG/H7nB0T48NH4qy2xheKIzzq5dK+sD7Qy2PYm4JRc/
9
- ZkjwZmBZNLzCR9GS8VwK/g9fvMLGwezsHz4UaXnFDY8iubq3CtWBbvrszvwss8/t
10
- kgiSsLrM7vMrkKlLIZghWpHPVj27N5YZTFFfn6anhBFZ89h5PIVrr2FF9iSPcTk=
11
- =wDji
12
- -----END PGP SIGNATURE-----