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 CHANGED
@@ -1,3 +1,5 @@
1
+ = 1.2.1
2
+ * Fix deprecated usage of HTTPResponse for Ruby 1.9.3 [Leonid Shevtsov]
1
3
  = 1.2.0
2
4
  * Rakismet attribute mappings are now inheritable
3
5
  = 1.1.2
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
- _, valid = Net::HTTP::Proxy(proxy_host, proxy_port).start(akismet.host) do |http|
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 = (valid == 'valid')
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
- _, response = Net::HTTP::Proxy(proxy_host, proxy_port).start(akismet.host) do |http|
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
@@ -1,3 +1,3 @@
1
1
  module Rakismet
2
- VERSION = "1.2.0"
2
+ VERSION = "1.2.1"
3
3
  end
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-19"
14
+ s.date = "2012-04-22"
15
15
 
16
16
  s.rubyforge_project = "rakismet"
17
17
 
@@ -15,7 +15,6 @@ describe BlockAkismetModel do
15
15
  end
16
16
 
17
17
  it "should accept a block" do
18
- puts BlockAkismetModel.akismet_attrs.inspect
19
18
  BlockAkismetModel.akismet_attrs[:comment_author].should eql(PROC)
20
19
  end
21
20
 
@@ -2,7 +2,10 @@ require File.dirname(__FILE__) + '/spec_helper'
2
2
 
3
3
  describe Rakismet do
4
4
 
5
- let(:http) { double(:http, :to_ary => [nil, 'akismet response']).as_null_object }
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([nil, 'valid'])
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([nil, 'valid'])
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([nil, 'invalid'])
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([nil, 'valid'])
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.0
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-19 00:00:00.000000000 Z
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.