rakismet 1.2.0 → 1.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +2 -0
- data/lib/rakismet.rb +4 -4
- data/lib/rakismet/version.rb +1 -1
- data/rakismet.gemspec +1 -1
- data/spec/models/block_params_spec.rb +0 -1
- data/spec/rakismet_spec.rb +8 -5
- metadata +2 -2
data/CHANGELOG
CHANGED
data/lib/rakismet.rb
CHANGED
@@ -39,11 +39,11 @@ module Rakismet
|
|
39
39
|
def validate_key
|
40
40
|
validate_config
|
41
41
|
akismet = URI.parse(verify_url)
|
42
|
-
|
42
|
+
response = Net::HTTP::Proxy(proxy_host, proxy_port).start(akismet.host) do |http|
|
43
43
|
data = "key=#{Rakismet.key}&blog=#{Rakismet.url}"
|
44
44
|
http.post(akismet.path, data, Rakismet.headers)
|
45
45
|
end
|
46
|
-
@valid_key = (
|
46
|
+
@valid_key = (response.body == 'valid')
|
47
47
|
end
|
48
48
|
|
49
49
|
def valid_key?
|
@@ -54,14 +54,14 @@ module Rakismet
|
|
54
54
|
validate_config
|
55
55
|
args.merge!(:blog => Rakismet.url)
|
56
56
|
akismet = URI.parse(call_url(function))
|
57
|
-
|
57
|
+
response = Net::HTTP::Proxy(proxy_host, proxy_port).start(akismet.host) do |http|
|
58
58
|
params = args.map do |k,v|
|
59
59
|
param = v.class < String ? v.to_str : v.to_s # for ActiveSupport::SafeBuffer and Nil, respectively
|
60
60
|
"#{k}=#{CGI.escape(param)}"
|
61
61
|
end
|
62
62
|
http.post(akismet.path, params.join('&'), Rakismet.headers)
|
63
63
|
end
|
64
|
-
response
|
64
|
+
response.body
|
65
65
|
end
|
66
66
|
|
67
67
|
protected
|
data/lib/rakismet/version.rb
CHANGED
data/rakismet.gemspec
CHANGED
@@ -11,7 +11,7 @@ Gem::Specification.new do |s|
|
|
11
11
|
s.homepage = "http://github.com/joshfrench/rakismet"
|
12
12
|
s.summary = "Akismet and TypePad AntiSpam integration for Rails."
|
13
13
|
s.description = "Rakismet is the easiest way to integrate Akismet or TypePad's AntiSpam into your Rails app."
|
14
|
-
s.date = "2012-04-
|
14
|
+
s.date = "2012-04-22"
|
15
15
|
|
16
16
|
s.rubyforge_project = "rakismet"
|
17
17
|
|
data/spec/rakismet_spec.rb
CHANGED
@@ -2,7 +2,10 @@ require File.dirname(__FILE__) + '/spec_helper'
|
|
2
2
|
|
3
3
|
describe Rakismet do
|
4
4
|
|
5
|
-
|
5
|
+
def mock_response(body)
|
6
|
+
double(:response, :body => body)
|
7
|
+
end
|
8
|
+
let(:http) { double(:http, :post => mock_response('akismet response')) }
|
6
9
|
|
7
10
|
after do
|
8
11
|
Rakismet.key = 'dummy-key'
|
@@ -43,19 +46,19 @@ describe Rakismet do
|
|
43
46
|
it "should use proxy host and port" do
|
44
47
|
Rakismet.proxy_host = 'proxy_host'
|
45
48
|
Rakismet.proxy_port = 'proxy_port'
|
46
|
-
@proxy.stub!(:start).and_return(
|
49
|
+
@proxy.stub!(:start).and_return(mock_response('valid'))
|
47
50
|
Net::HTTP.should_receive(:Proxy).with('proxy_host', 'proxy_port').and_return(@proxy)
|
48
51
|
Rakismet.validate_key
|
49
52
|
end
|
50
53
|
|
51
54
|
it "should set @@valid_key = true if key is valid" do
|
52
|
-
@proxy.stub!(:start).and_return(
|
55
|
+
@proxy.stub!(:start).and_return(mock_response('valid'))
|
53
56
|
Rakismet.validate_key
|
54
57
|
Rakismet.valid_key?.should be_true
|
55
58
|
end
|
56
59
|
|
57
60
|
it "should set @@valid_key = false if key is invalid" do
|
58
|
-
@proxy.stub!(:start).and_return(
|
61
|
+
@proxy.stub!(:start).and_return(mock_response('invalid'))
|
59
62
|
Rakismet.validate_key
|
60
63
|
Rakismet.valid_key?.should be_false
|
61
64
|
end
|
@@ -78,7 +81,7 @@ describe Rakismet do
|
|
78
81
|
it "should use proxy host and port" do
|
79
82
|
Rakismet.proxy_host = 'proxy_host'
|
80
83
|
Rakismet.proxy_port = 'proxy_port'
|
81
|
-
@proxy.stub!(:start).and_return(
|
84
|
+
@proxy.stub!(:start).and_return(mock_response('valid'))
|
82
85
|
Net::HTTP.should_receive(:Proxy).with('proxy_host', 'proxy_port').and_return(@proxy)
|
83
86
|
Rakismet.send(:akismet_call, 'bogus-function')
|
84
87
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rakismet
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-04-
|
12
|
+
date: 2012-04-22 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: Rakismet is the easiest way to integrate Akismet or TypePad's AntiSpam
|
15
15
|
into your Rails app.
|