acts_as_textcaptcha 1.1.1 → 1.1.2
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.
- data/README.rdoc +3 -3
- data/VERSION +1 -1
- data/acts_as_textcaptcha.gemspec +1 -1
- data/lib/acts_as_textcaptcha.rb +4 -3
- data/spec/acts_as_textcaptcha_spec.rb +1 -1
- metadata +2 -2
data/README.rdoc
CHANGED
@@ -42,7 +42,7 @@ Next configure your models to be spam protected like so; (this is the most basic
|
|
42
42
|
acts_as_textcaptcha({'api_key' => 'your_textcaptcha_api_key'})
|
43
43
|
end
|
44
44
|
|
45
|
-
Next in your controller *new* and *create* actions you'll want to _spamify_ your model
|
45
|
+
Next in your controller *new* and *create* actions you'll want to _spamify_ your model and merge the answers. Like so;
|
46
46
|
|
47
47
|
def new
|
48
48
|
@comment = Comment.new
|
@@ -50,12 +50,12 @@ Next in your controller *new* and *create* actions you'll want to _spamify_ your
|
|
50
50
|
end
|
51
51
|
|
52
52
|
def create
|
53
|
-
@comment = Comment.new(params[:comment])
|
53
|
+
@comment = Comment.new(params[:comment].merge(:possible_answers => session[:possible_answers]))
|
54
54
|
if @comment.save
|
55
55
|
...
|
56
56
|
else
|
57
57
|
spamify(@comment)
|
58
|
-
|
58
|
+
render :action => 'new'
|
59
59
|
end
|
60
60
|
end
|
61
61
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.1.
|
1
|
+
1.1.2
|
data/acts_as_textcaptcha.gemspec
CHANGED
data/lib/acts_as_textcaptcha.rb
CHANGED
@@ -37,7 +37,8 @@ module ActsAsTextcaptcha #:nodoc:
|
|
37
37
|
# if returning false model.validate will always be false with errors on base
|
38
38
|
def allowed?; true end
|
39
39
|
|
40
|
-
def validate
|
40
|
+
def validate
|
41
|
+
super
|
41
42
|
if new_record?
|
42
43
|
if allowed?
|
43
44
|
if possible_answers && perform_spam_check? && !validate_spam_answer
|
@@ -49,11 +50,11 @@ module ActsAsTextcaptcha #:nodoc:
|
|
49
50
|
return false
|
50
51
|
end
|
51
52
|
end
|
52
|
-
|
53
|
+
true
|
53
54
|
end
|
54
55
|
|
55
56
|
def validate_spam_answer
|
56
|
-
spam_answer ? possible_answers.include?(encrypt_answer(Digest::MD5.hexdigest(spam_answer.strip.downcase.to_s))) : false
|
57
|
+
(spam_answer && possible_answers) ? possible_answers.include?(encrypt_answer(Digest::MD5.hexdigest(spam_answer.strip.downcase.to_s))) : false
|
57
58
|
end
|
58
59
|
|
59
60
|
def encrypt_answers(answers)
|
@@ -91,7 +91,7 @@ describe 'ActsAsTextcaptcha' do
|
|
91
91
|
it 'should always be valid if skip_spam_check? is true' do
|
92
92
|
@comment.generate_spam_question
|
93
93
|
@comment.validate.should be_false
|
94
|
-
@comment.stub!(:
|
94
|
+
@comment.stub!(:perform_spam_check?).and_return(false)
|
95
95
|
@comment.validate.should be_true
|
96
96
|
@comment.should be_valid
|
97
97
|
end
|