validates_against_stopforumspam 0.0.2 → 1.0

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.
Files changed (46) hide show
  1. data/MIT-LICENSE +1 -1
  2. data/README.md +51 -0
  3. data/Rakefile +30 -16
  4. data/lib/tasks/validates_against_stopforumspam_tasks.rake +4 -0
  5. data/lib/validates_against_stopforumspam/version.rb +3 -0
  6. data/lib/validates_against_stopforumspam.rb +30 -26
  7. data/test/dummy/README.rdoc +261 -0
  8. data/test/dummy/Rakefile +7 -0
  9. data/test/dummy/app/assets/javascripts/application.js +15 -0
  10. data/test/dummy/app/assets/stylesheets/application.css +13 -0
  11. data/test/dummy/app/controllers/application_controller.rb +3 -0
  12. data/test/dummy/app/helpers/application_helper.rb +2 -0
  13. data/test/dummy/app/models/comment.rb +5 -0
  14. data/test/dummy/app/views/layouts/application.html.erb +14 -0
  15. data/test/dummy/config/application.rb +59 -0
  16. data/test/dummy/config/boot.rb +10 -0
  17. data/test/dummy/config/database.yml +25 -0
  18. data/test/dummy/config/environment.rb +5 -0
  19. data/test/dummy/config/environments/development.rb +37 -0
  20. data/test/dummy/config/environments/production.rb +67 -0
  21. data/test/dummy/config/environments/test.rb +37 -0
  22. data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
  23. data/test/dummy/config/initializers/inflections.rb +15 -0
  24. data/test/dummy/config/initializers/mime_types.rb +5 -0
  25. data/test/dummy/config/initializers/secret_token.rb +7 -0
  26. data/test/dummy/config/initializers/session_store.rb +8 -0
  27. data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
  28. data/test/dummy/config/locales/en.yml +5 -0
  29. data/test/dummy/config/routes.rb +58 -0
  30. data/test/dummy/config.ru +4 -0
  31. data/test/dummy/db/development.sqlite3 +0 -0
  32. data/test/dummy/db/migrate/20121106005832_create_comments.rb +12 -0
  33. data/test/dummy/db/schema.rb +25 -0
  34. data/test/dummy/db/test.sqlite3 +0 -0
  35. data/test/dummy/log/development.log +91 -0
  36. data/test/dummy/log/test.log +611 -0
  37. data/test/dummy/public/404.html +26 -0
  38. data/test/dummy/public/422.html +26 -0
  39. data/test/dummy/public/500.html +25 -0
  40. data/test/dummy/public/favicon.ico +0 -0
  41. data/test/dummy/script/rails +6 -0
  42. data/test/test_helper.rb +12 -13
  43. data/test/validates_against_stopforumspam_test.rb +21 -37
  44. metadata +128 -48
  45. data/README +0 -60
  46. data/test/schema.rb +0 -8
@@ -0,0 +1,26 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>The page you were looking for doesn't exist (404)</title>
5
+ <style type="text/css">
6
+ body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
7
+ div.dialog {
8
+ width: 25em;
9
+ padding: 0 4em;
10
+ margin: 4em auto 0 auto;
11
+ border: 1px solid #ccc;
12
+ border-right-color: #999;
13
+ border-bottom-color: #999;
14
+ }
15
+ h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
16
+ </style>
17
+ </head>
18
+
19
+ <body>
20
+ <!-- This file lives in public/404.html -->
21
+ <div class="dialog">
22
+ <h1>The page you were looking for doesn't exist.</h1>
23
+ <p>You may have mistyped the address or the page may have moved.</p>
24
+ </div>
25
+ </body>
26
+ </html>
@@ -0,0 +1,26 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>The change you wanted was rejected (422)</title>
5
+ <style type="text/css">
6
+ body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
7
+ div.dialog {
8
+ width: 25em;
9
+ padding: 0 4em;
10
+ margin: 4em auto 0 auto;
11
+ border: 1px solid #ccc;
12
+ border-right-color: #999;
13
+ border-bottom-color: #999;
14
+ }
15
+ h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
16
+ </style>
17
+ </head>
18
+
19
+ <body>
20
+ <!-- This file lives in public/422.html -->
21
+ <div class="dialog">
22
+ <h1>The change you wanted was rejected.</h1>
23
+ <p>Maybe you tried to change something you didn't have access to.</p>
24
+ </div>
25
+ </body>
26
+ </html>
@@ -0,0 +1,25 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>We're sorry, but something went wrong (500)</title>
5
+ <style type="text/css">
6
+ body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
7
+ div.dialog {
8
+ width: 25em;
9
+ padding: 0 4em;
10
+ margin: 4em auto 0 auto;
11
+ border: 1px solid #ccc;
12
+ border-right-color: #999;
13
+ border-bottom-color: #999;
14
+ }
15
+ h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
16
+ </style>
17
+ </head>
18
+
19
+ <body>
20
+ <!-- This file lives in public/500.html -->
21
+ <div class="dialog">
22
+ <h1>We're sorry, but something went wrong.</h1>
23
+ </div>
24
+ </body>
25
+ </html>
File without changes
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby19
2
+ # This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
3
+
4
+ APP_PATH = File.expand_path('../../config/application', __FILE__)
5
+ require File.expand_path('../../config/boot', __FILE__)
6
+ require 'rails/commands'
data/test/test_helper.rb CHANGED
@@ -1,17 +1,16 @@
1
- require 'rubygems'
2
- require 'logger'
3
- require 'test/unit'
4
- require 'active_record'
5
- require 'active_support'
1
+ # Configure Rails Environment
2
+ ENV["RAILS_ENV"] = "test"
6
3
 
7
- ENV['RAILS_ENV'] = 'test'
4
+ require File.expand_path("../dummy/config/environment.rb", __FILE__)
5
+ require "rails/test_help"
8
6
 
9
- def load_schema
10
- ActiveRecord::Base.logger = Logger.new(File.dirname(__FILE__) + "/debug.log")
11
- ActiveRecord::Base.establish_connection({
12
- :adapter => 'sqlite3',
13
- :database => ':memory:'
14
- })
15
- load(File.dirname(__FILE__) + "/schema.rb")
7
+ Rails.backtrace_cleaner.remove_silencers!
8
+
9
+ # Load support files
10
+ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
11
+
12
+ # Load fixtures from the engine
13
+ if ActiveSupport::TestCase.method_defined?(:fixture_path=)
14
+ ActiveSupport::TestCase.fixture_path = File.expand_path("../fixtures", __FILE__)
16
15
  end
17
16
 
@@ -1,47 +1,31 @@
1
- require File.dirname(__FILE__) + '/test_helper'
2
- require File.dirname(__FILE__) + '/../rails/init'
1
+ require 'test_helper'
3
2
 
4
- class ValidatesAgainstStopForumSpamTest < ActiveSupport::TestCase
5
- load_schema
6
-
7
- class Comment < ActiveRecord::Base
8
- validates_against_stopforumspam :fields => { :email => :email, :ip => :ip, :username => :name }
3
+ class ValidatesAgainstStopforumspamTest < ActiveSupport::TestCase
4
+ test "ham email" do
5
+ assert Comment.new(:email => 'surely@not-spam-but-ham.com').valid?
9
6
  end
10
7
 
11
- # test data: see http://www.stopforumspam.com/forum/viewtopic.php?pid=14680
12
-
13
- test "empty comment" do
14
- comment = Comment.new
15
- assert comment.valid?
8
+ test "ham ip" do
9
+ assert Comment.new(:ip => '127.0.0.1').valid?
16
10
  end
17
11
 
18
- test "ham email" do
19
- comment = Comment.create(:email => 'this-is-not-a@spammer-but-a-hammer.com')
20
- assert comment.valid?
21
- end
22
-
23
- test "ham email and IP" do
24
- comment = Comment.create(:email => 'this-is-not-a@spammer-but-a-hammer.com', :ip => '127.0.0.1')
25
- assert comment.valid?
26
- end
12
+ test "ham username" do
13
+ assert Comment.new(:user_name => 'i-only-submit-ham').valid?
14
+ end
27
15
 
28
- test "spam email" do
29
- comment = Comment.create(:email => 'test@test.com')
30
- assert comment.invalid?
31
- end
16
+ test "spam email" do
17
+ assert Comment.new(:email => 'test@test.com').invalid?
18
+ end
32
19
 
33
- test "spam email and ip" do
34
- comment = Comment.create(:email => 'test@test.com', :ip => '1.2.3.4')
35
- assert comment.invalid?
36
- end
20
+ test "spam email and ip" do
21
+ assert Comment.new(:email => 'test@test.com', :ip => '1.2.3.4').invalid?
22
+ end
37
23
 
38
- test "spam ip" do
39
- comment = Comment.create(:ip => '1.2.3.4')
40
- assert comment.invalid?
41
- end
24
+ test "spam ip" do
25
+ assert Comment.new(:ip => '1.2.3.4').invalid?
26
+ end
42
27
 
43
- test "spam username" do
44
- comment = Comment.create(:name => 'spammer')
45
- assert comment.invalid?
46
- end
28
+ test "spam username" do
29
+ assert Comment.new(:user_name => 'spammer').invalid?
30
+ end
47
31
  end
metadata CHANGED
@@ -1,73 +1,153 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: validates_against_stopforumspam
3
- version: !ruby/object:Gem::Version
4
- hash: 27
5
- prerelease: false
6
- segments:
7
- - 0
8
- - 0
9
- - 2
10
- version: 0.0.2
3
+ version: !ruby/object:Gem::Version
4
+ version: '1.0'
5
+ prerelease:
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - Richard Hirner
14
9
  autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
-
18
- date: 2011-02-02 00:00:00 +01:00
19
- default_executable:
20
- dependencies: []
21
-
12
+ date: 2012-11-06 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rails
16
+ requirement: &17198389540 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>'
20
+ - !ruby/object:Gem::Version
21
+ version: '3.0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *17198389540
25
+ - !ruby/object:Gem::Dependency
26
+ name: sqlite3
27
+ requirement: &17198388500 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ type: :development
34
+ prerelease: false
35
+ version_requirements: *17198388500
22
36
  description:
23
- email: hirner@bitfire.at
37
+ email:
38
+ - hirner@bitfire.at
24
39
  executables: []
25
-
26
40
  extensions: []
27
-
28
- extra_rdoc_files:
29
- - README
30
- files:
41
+ extra_rdoc_files: []
42
+ files:
43
+ - lib/validates_against_stopforumspam.rb
44
+ - lib/validates_against_stopforumspam/version.rb
45
+ - lib/tasks/validates_against_stopforumspam_tasks.rake
31
46
  - MIT-LICENSE
32
- - README
33
47
  - Rakefile
34
- - lib/validates_against_stopforumspam.rb
35
- - test/schema.rb
36
- - test/test_helper.rb
48
+ - README.md
37
49
  - test/validates_against_stopforumspam_test.rb
38
- has_rdoc: true
50
+ - test/test_helper.rb
51
+ - test/dummy/public/404.html
52
+ - test/dummy/public/favicon.ico
53
+ - test/dummy/public/500.html
54
+ - test/dummy/public/422.html
55
+ - test/dummy/Rakefile
56
+ - test/dummy/log/development.log
57
+ - test/dummy/log/test.log
58
+ - test/dummy/config.ru
59
+ - test/dummy/config/environments/production.rb
60
+ - test/dummy/config/environments/development.rb
61
+ - test/dummy/config/environments/test.rb
62
+ - test/dummy/config/initializers/backtrace_silencers.rb
63
+ - test/dummy/config/initializers/inflections.rb
64
+ - test/dummy/config/initializers/secret_token.rb
65
+ - test/dummy/config/initializers/session_store.rb
66
+ - test/dummy/config/initializers/wrap_parameters.rb
67
+ - test/dummy/config/initializers/mime_types.rb
68
+ - test/dummy/config/routes.rb
69
+ - test/dummy/config/database.yml
70
+ - test/dummy/config/boot.rb
71
+ - test/dummy/config/application.rb
72
+ - test/dummy/config/locales/en.yml
73
+ - test/dummy/config/environment.rb
74
+ - test/dummy/db/migrate/20121106005832_create_comments.rb
75
+ - test/dummy/db/schema.rb
76
+ - test/dummy/db/development.sqlite3
77
+ - test/dummy/db/test.sqlite3
78
+ - test/dummy/app/controllers/application_controller.rb
79
+ - test/dummy/app/views/layouts/application.html.erb
80
+ - test/dummy/app/helpers/application_helper.rb
81
+ - test/dummy/app/assets/javascripts/application.js
82
+ - test/dummy/app/assets/stylesheets/application.css
83
+ - test/dummy/app/models/comment.rb
84
+ - test/dummy/README.rdoc
85
+ - test/dummy/script/rails
39
86
  homepage: http://github.com/rfc2822/validates_against_stopforumspam
40
87
  licenses: []
41
-
42
88
  post_install_message:
43
89
  rdoc_options: []
44
-
45
- require_paths:
90
+ require_paths:
46
91
  - lib
47
- required_ruby_version: !ruby/object:Gem::Requirement
92
+ required_ruby_version: !ruby/object:Gem::Requirement
48
93
  none: false
49
- requirements:
50
- - - ">="
51
- - !ruby/object:Gem::Version
52
- hash: 3
53
- segments:
94
+ requirements:
95
+ - - ! '>='
96
+ - !ruby/object:Gem::Version
97
+ version: '0'
98
+ segments:
54
99
  - 0
55
- version: "0"
56
- required_rubygems_version: !ruby/object:Gem::Requirement
100
+ hash: -2829581439600051850
101
+ required_rubygems_version: !ruby/object:Gem::Requirement
57
102
  none: false
58
- requirements:
59
- - - ">="
60
- - !ruby/object:Gem::Version
61
- hash: 3
62
- segments:
103
+ requirements:
104
+ - - ! '>='
105
+ - !ruby/object:Gem::Version
106
+ version: '0'
107
+ segments:
63
108
  - 0
64
- version: "0"
109
+ hash: -2829581439600051850
65
110
  requirements: []
66
-
67
111
  rubyforge_project:
68
- rubygems_version: 1.3.7
112
+ rubygems_version: 1.8.11
69
113
  signing_key:
70
114
  specification_version: 3
71
- summary: ActiveRecord model validation against stopforumspam.com
72
- test_files: []
73
-
115
+ summary: ActiveRecord model validation against stopforumspam.com (Rails 3)
116
+ test_files:
117
+ - test/validates_against_stopforumspam_test.rb
118
+ - test/test_helper.rb
119
+ - test/dummy/public/404.html
120
+ - test/dummy/public/favicon.ico
121
+ - test/dummy/public/500.html
122
+ - test/dummy/public/422.html
123
+ - test/dummy/Rakefile
124
+ - test/dummy/log/development.log
125
+ - test/dummy/log/test.log
126
+ - test/dummy/config.ru
127
+ - test/dummy/config/environments/production.rb
128
+ - test/dummy/config/environments/development.rb
129
+ - test/dummy/config/environments/test.rb
130
+ - test/dummy/config/initializers/backtrace_silencers.rb
131
+ - test/dummy/config/initializers/inflections.rb
132
+ - test/dummy/config/initializers/secret_token.rb
133
+ - test/dummy/config/initializers/session_store.rb
134
+ - test/dummy/config/initializers/wrap_parameters.rb
135
+ - test/dummy/config/initializers/mime_types.rb
136
+ - test/dummy/config/routes.rb
137
+ - test/dummy/config/database.yml
138
+ - test/dummy/config/boot.rb
139
+ - test/dummy/config/application.rb
140
+ - test/dummy/config/locales/en.yml
141
+ - test/dummy/config/environment.rb
142
+ - test/dummy/db/migrate/20121106005832_create_comments.rb
143
+ - test/dummy/db/schema.rb
144
+ - test/dummy/db/development.sqlite3
145
+ - test/dummy/db/test.sqlite3
146
+ - test/dummy/app/controllers/application_controller.rb
147
+ - test/dummy/app/views/layouts/application.html.erb
148
+ - test/dummy/app/helpers/application_helper.rb
149
+ - test/dummy/app/assets/javascripts/application.js
150
+ - test/dummy/app/assets/stylesheets/application.css
151
+ - test/dummy/app/models/comment.rb
152
+ - test/dummy/README.rdoc
153
+ - test/dummy/script/rails
data/README DELETED
@@ -1,60 +0,0 @@
1
- ValidatesAgainstStopforumspam
2
- =============================
3
-
4
- Rails gem for ActiveRecord comment model validation against StopForumSpam.com.
5
- No API key required. Respect their terms of use: http://www.stopforumspam.com/apis
6
-
7
- Compatibility: Rails 3, tested with Ruby 1.8.7
8
-
9
-
10
- Installation
11
- ============
12
-
13
- Specify the gem in your Gemfile:
14
-
15
- gem "validates_against_stopforumspam"
16
-
17
- or for the current edge version:
18
-
19
- gem "validates_against_stopforumspam", :git => 'git://github.com/rfc2822/validates_against_stopforumspam'
20
-
21
- and install it with bundler.
22
-
23
-
24
- Example
25
- =======
26
-
27
- Assuming that you have a model +Comment+ with the following fields:
28
-
29
- t.string :name, :null => false
30
- t.string :email
31
- t.string :ip_address
32
- t.string :comment, :null => false
33
-
34
- You can use validates_against_stopforumspam to validate new comments:
35
-
36
- class Comment < ActiveRecord::Base
37
- validates_against_stopforumspam :fields => { :username => name, :email => :email, :ip => :ip_address }
38
- end
39
-
40
- The +fields+ parameter is required. It must define at least one of these parameters:
41
-
42
- * :username
43
- * :email
44
- * :ip
45
-
46
- These parameters are used to query StopForumSpam. When the comment may be spam (because at
47
- least one of the parameters appear on stopforumspam.com), an error is added to the model instance.
48
-
49
-
50
- To do
51
- =====
52
-
53
- If you like and/or use this plug-in, please consider extending it. What is needed:
54
-
55
- * i18n'ed error message
56
-
57
- Please submit patches via Github.
58
-
59
-
60
- Copyright (c) 2011 Richard Hirner <hirner@bitfire.at>, released under the MIT license
data/test/schema.rb DELETED
@@ -1,8 +0,0 @@
1
- ActiveRecord::Schema.define(:version => 0) do
2
- create_table :comments do |t|
3
- t.string :name
4
- t.string :email
5
- t.string :ip
6
- t.string :comment
7
- end
8
- end