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.
@@ -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 like so. This generates a new spam question on the 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
- render :action => 'new'
58
+ render :action => 'new'
59
59
  end
60
60
  end
61
61
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.1.1
1
+ 1.1.2
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{acts_as_textcaptcha}
8
- s.version = "1.1.1"
8
+ s.version = "1.1.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Matthew Hutchinson"]
@@ -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
- super
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!(:skip_spam_check?).and_return(true)
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
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 1
7
7
  - 1
8
- - 1
9
- version: 1.1.1
8
+ - 2
9
+ version: 1.1.2
10
10
  platform: ruby
11
11
  authors:
12
12
  - Matthew Hutchinson