rakismet 1.5.1 → 1.5.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/CHANGELOG +2 -0
- data/lib/rakismet.rb +5 -1
- data/lib/rakismet/version.rb +1 -1
- data/rakismet.gemspec +1 -1
- data/spec/models/block_params_spec.rb +1 -1
- data/spec/models/rakismet_model_spec.rb +11 -10
- data/spec/models/request_params_spec.rb +1 -1
- data/spec/rakismet_spec.rb +15 -15
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
NzdlODJkNzk5YjAxYTgyNjkxZmMzYjc1NjMxZGQ3ZGY4OTFlZTMwMQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
Y2FhOTZjNzg5NDEyMWFmOGM2MTYwYzQ0NWJmM2ViNWM5OGVlZTA0YQ==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
MzY2YWU3N2E2NmNjNzU1MTBkNmYxNDAwNDdiM2ZhZmE4ODU2Y2ZkZTliNmFl
|
10
|
+
MGNjOWIwYmRhYWRhZGNmMDk5ZDdmYjQ0OTE3YjI3YWRjZTQzY2VhYzU2NTFl
|
11
|
+
N2EwNTFmNDRlZTY5ODE0ZDY2MTQ3M2JlNjA5MDQ0MGQyNTM1MDE=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
N2U0MmUzNTM0NTZmNjE3YjhjMDFjYmZmNmVhMmY2NjY4MjJiMmZhY2RlYmFi
|
14
|
+
ZjNmYzJlYzc5MzE2MDg1ZTgwMWE4NDg2NWNlOTBhY2Y1OTYzNjEwMGFhZmI5
|
15
|
+
NmE5ZDViZGMzZWFlMTBhZjhkY2NlYWVmMWY5YWQ0OWExM2Y2ZjE=
|
data/CHANGELOG
CHANGED
data/lib/rakismet.rb
CHANGED
@@ -42,7 +42,11 @@ module Rakismet
|
|
42
42
|
def headers
|
43
43
|
@headers ||= begin
|
44
44
|
user_agent = "Rakismet/#{Rakismet::VERSION}"
|
45
|
-
|
45
|
+
|
46
|
+
if defined?(Rails) && Rails.respond_to?(:version)
|
47
|
+
user_agent = "Rails/#{Rails.version} | " + user_agent
|
48
|
+
end
|
49
|
+
|
46
50
|
{ 'User-Agent' => user_agent, 'Content-Type' => 'application/x-www-form-urlencoded' }
|
47
51
|
end
|
48
52
|
end
|
data/lib/rakismet/version.rb
CHANGED
data/rakismet.gemspec
CHANGED
@@ -10,7 +10,7 @@ Gem::Specification.new do |s|
|
|
10
10
|
s.homepage = "http://github.com/joshfrench/rakismet"
|
11
11
|
s.summary = "Akismet and TypePad AntiSpam integration for Rails."
|
12
12
|
s.description = "Rakismet is the easiest way to integrate Akismet or TypePad's AntiSpam into your Rails app."
|
13
|
-
s.date = "
|
13
|
+
s.date = "2016-02-26"
|
14
14
|
|
15
15
|
s.rubyforge_project = "rakismet"
|
16
16
|
s.add_development_dependency "rake"
|
@@ -4,7 +4,7 @@ describe AkismetModel do
|
|
4
4
|
|
5
5
|
before do
|
6
6
|
@model = AkismetModel.new
|
7
|
-
comment_attrs.each_pair { |k,v| @model.stub
|
7
|
+
comment_attrs.each_pair { |k,v| @model.stub(k).and_return(v) }
|
8
8
|
end
|
9
9
|
|
10
10
|
it "should have default mappings" do
|
@@ -31,7 +31,7 @@ describe AkismetModel do
|
|
31
31
|
[:user_ip, :user_agent, :referrer].each do |field|
|
32
32
|
@model.should_not respond_to(:field)
|
33
33
|
end
|
34
|
-
Rakismet.stub
|
34
|
+
Rakismet.stub(:request).and_return(request)
|
35
35
|
Rakismet.should_receive(:akismet_call).
|
36
36
|
with('comment-check', akismet_attrs.merge(:user_ip => '127.0.0.1',
|
37
37
|
:user_agent => 'RSpec',
|
@@ -40,7 +40,7 @@ describe AkismetModel do
|
|
40
40
|
end
|
41
41
|
|
42
42
|
it "should send http_headers from Rakismet.request if present" do
|
43
|
-
Rakismet.stub
|
43
|
+
Rakismet.stub(:request).and_return(request_with_headers)
|
44
44
|
Rakismet.should_receive(:akismet_call).
|
45
45
|
with('comment-check', akismet_attrs.merge(:user_ip => '127.0.0.1',
|
46
46
|
:user_agent => 'RSpec',
|
@@ -57,24 +57,25 @@ describe AkismetModel do
|
|
57
57
|
end
|
58
58
|
|
59
59
|
it "should be true if comment is spam" do
|
60
|
-
Rakismet.stub
|
60
|
+
Rakismet.stub(:akismet_call).and_return('true')
|
61
61
|
@model.should be_spam
|
62
62
|
end
|
63
63
|
|
64
64
|
it "should be false if comment is not spam" do
|
65
|
-
Rakismet.stub
|
65
|
+
Rakismet.stub(:akismet_call).and_return('false')
|
66
66
|
@model.should_not be_spam
|
67
67
|
end
|
68
68
|
|
69
69
|
it "should set akismet_response" do
|
70
|
-
Rakismet.stub
|
70
|
+
Rakismet.stub(:akismet_call).and_return('response')
|
71
71
|
@model.spam?
|
72
72
|
@model.akismet_response.should eql('response')
|
73
73
|
end
|
74
74
|
|
75
75
|
it "should not throw an error if request vars are missing" do
|
76
|
-
Rakismet.stub
|
77
|
-
|
76
|
+
Rakismet.stub(:request).and_return(empty_request)
|
77
|
+
Rakismet.stub(:akismet_call).and_return('false')
|
78
|
+
lambda { @model.spam? }.should_not raise_error
|
78
79
|
end
|
79
80
|
end
|
80
81
|
|
@@ -86,7 +87,7 @@ describe AkismetModel do
|
|
86
87
|
end
|
87
88
|
|
88
89
|
it "should mutate #spam?" do
|
89
|
-
Rakismet.stub
|
90
|
+
Rakismet.stub(:akismet_call)
|
90
91
|
@model.instance_variable_set(:@_spam, false)
|
91
92
|
@model.spam!
|
92
93
|
@model.should be_spam
|
@@ -100,7 +101,7 @@ describe AkismetModel do
|
|
100
101
|
end
|
101
102
|
|
102
103
|
it "should mutate #spam?" do
|
103
|
-
Rakismet.stub
|
104
|
+
Rakismet.stub(:akismet_call)
|
104
105
|
@model.instance_variable_set(:@_spam, true)
|
105
106
|
@model.ham!
|
106
107
|
@model.should_not be_spam
|
@@ -9,7 +9,7 @@ describe RequestParams do
|
|
9
9
|
before do
|
10
10
|
@model = RequestParams.new
|
11
11
|
attrs = comment_attrs(:user_ip => '192.168.0.1', :user_agent => 'Rakismet', :referrer => 'http://localhost/referrer')
|
12
|
-
attrs.each_pair { |k,v| @model.stub
|
12
|
+
attrs.each_pair { |k,v| @model.stub(k).and_return(v) }
|
13
13
|
end
|
14
14
|
|
15
15
|
it "should use local values even if Rakismet.request is populated" do
|
data/spec/rakismet_spec.rb
CHANGED
@@ -35,44 +35,44 @@ describe Rakismet do
|
|
35
35
|
describe ".validate_config" do
|
36
36
|
it "should raise an error if key is not found" do
|
37
37
|
Rakismet.key = ''
|
38
|
-
lambda { Rakismet.send(:validate_config) }.should raise_error
|
38
|
+
lambda { Rakismet.send(:validate_config) }.should raise_error
|
39
39
|
end
|
40
40
|
|
41
41
|
it "should raise an error if url is not found" do
|
42
42
|
Rakismet.url = ''
|
43
|
-
lambda { Rakismet.send(:validate_config) }.should raise_error
|
43
|
+
lambda { Rakismet.send(:validate_config) }.should raise_error
|
44
44
|
end
|
45
45
|
|
46
46
|
it "should raise an error if host is not found" do
|
47
47
|
Rakismet.host = ''
|
48
|
-
lambda { Rakismet.send(:validate_config) }.should raise_error
|
48
|
+
lambda { Rakismet.send(:validate_config) }.should raise_error
|
49
49
|
end
|
50
50
|
end
|
51
51
|
|
52
52
|
describe ".validate_key" do
|
53
53
|
before (:each) do
|
54
|
-
@proxy =
|
55
|
-
Net::HTTP.stub
|
54
|
+
@proxy = double(Net::HTTP)
|
55
|
+
Net::HTTP.stub(:Proxy).and_return(@proxy)
|
56
56
|
end
|
57
57
|
|
58
58
|
it "should use proxy host and port" do
|
59
59
|
Rakismet.proxy_host = 'proxy_host'
|
60
60
|
Rakismet.proxy_port = 'proxy_port'
|
61
|
-
@proxy.stub
|
61
|
+
@proxy.stub(:start).and_return(mock_response('valid'))
|
62
62
|
Net::HTTP.should_receive(:Proxy).with('proxy_host', 'proxy_port').and_return(@proxy)
|
63
63
|
Rakismet.validate_key
|
64
64
|
end
|
65
65
|
|
66
66
|
it "should set @@valid_key = true if key is valid" do
|
67
|
-
@proxy.stub
|
67
|
+
@proxy.stub(:start).and_return(mock_response('valid'))
|
68
68
|
Rakismet.validate_key
|
69
|
-
Rakismet.valid_key?.should
|
69
|
+
Rakismet.valid_key?.should be_truthy
|
70
70
|
end
|
71
71
|
|
72
72
|
it "should set @@valid_key = false if key is invalid" do
|
73
|
-
@proxy.stub
|
73
|
+
@proxy.stub(:start).and_return(mock_response('invalid'))
|
74
74
|
Rakismet.validate_key
|
75
|
-
Rakismet.valid_key?.should
|
75
|
+
Rakismet.valid_key?.should be_falsey
|
76
76
|
end
|
77
77
|
|
78
78
|
it "should build url with host" do
|
@@ -82,7 +82,7 @@ describe Rakismet do
|
|
82
82
|
Rakismet.validate_key
|
83
83
|
end
|
84
84
|
end
|
85
|
-
|
85
|
+
|
86
86
|
describe '.excluded_headers' do
|
87
87
|
it "should default to ['HTTP_COOKIE']" do
|
88
88
|
Rakismet.excluded_headers.should eq ['HTTP_COOKIE']
|
@@ -91,15 +91,15 @@ describe Rakismet do
|
|
91
91
|
|
92
92
|
describe ".akismet_call" do
|
93
93
|
before do
|
94
|
-
@proxy =
|
95
|
-
Net::HTTP.stub
|
94
|
+
@proxy = double(Net::HTTP)
|
95
|
+
Net::HTTP.stub(:Proxy).and_return(@proxy)
|
96
96
|
@proxy.stub(:start).and_yield(http)
|
97
97
|
end
|
98
98
|
|
99
99
|
it "should use proxy host and port" do
|
100
100
|
Rakismet.proxy_host = 'proxy_host'
|
101
101
|
Rakismet.proxy_port = 'proxy_port'
|
102
|
-
@proxy.stub
|
102
|
+
@proxy.stub(:start).and_return(mock_response('valid'))
|
103
103
|
Net::HTTP.should_receive(:Proxy).with('proxy_host', 'proxy_port').and_return(@proxy)
|
104
104
|
Rakismet.send(:akismet_call, 'bogus-function')
|
105
105
|
end
|
@@ -134,7 +134,7 @@ describe Rakismet do
|
|
134
134
|
it "should build query string when params are nil" do
|
135
135
|
lambda {
|
136
136
|
Rakismet.send(:akismet_call, 'bogus-function', { :nil_param => nil })
|
137
|
-
}.should_not raise_error
|
137
|
+
}.should_not raise_error
|
138
138
|
end
|
139
139
|
end
|
140
140
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rakismet
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.5.
|
4
|
+
version: 1.5.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Josh French
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-02-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|