diff --git a/vendor/plugins/rakismet/CHANGELOG b/vendor/plugins/rakismet/CHANGELOG deleted file mode 100644 index 5e8de96..0000000 --- a/vendor/plugins/rakismet/CHANGELOG +++ /dev/null @@ -1,35 +0,0 @@ -* Clean up gemspec and load paths [Steven Harman] -* Add Akismet is_test param [Steven Harman] -* Add Akismet user_role attribute [Steven Harman] -= 1.2.1 -* Fix deprecated usage of HTTPResponse for Ruby 1.9.3 [Leonid Shevtsov] -= 1.2.0 -* Rakismet attribute mappings are now inheritable -= 1.1.2 -* Explicitly load version -= 1.1.1 -* Fix SafeBuffer error under Rails 3.0.8 and 3.0.9 [Brandon Ferguson] -* Readme cleanup [Zeke Sikelianos] -* Drop Jeweler in favor of Bundler's gem tasks -= 1.1.0 -* Add HTTP Proxy support [Francisco Trindade] -= 1.0.1 -* Fix hash access for Ruby 1.9 [Alex Crichton] -= 1.0.0 -* Update for Rails 3 -* Remove filters and replace with middleware -* Remove initializers and replace with Railtie -= 0.4.0 -* Rakismet is no longer injected into ActiveRecord or ActionController -* API changes to support newly decoupled modules -* Use Jeweler to manage gemspec -= 0.3.6 -* Allow attributes to fall through to methods or AR attributes -= 0.3.5 -* Added gemspec and rails/init.rb so rakismet can work as a gem [Michael Air] -* Added generator template and manifest [Michael Air] -= 0.3.0 -* Abstract out Rakismet version string -* Set default Akismet Host -* Abstract out the Akismet host [Mike Burns] -* Started keeping a changelog :P diff --git a/vendor/plugins/rakismet/Gemfile b/vendor/plugins/rakismet/Gemfile deleted file mode 100644 index c80ee36..0000000 --- a/vendor/plugins/rakismet/Gemfile +++ /dev/null @@ -1,3 +0,0 @@ -source "http://rubygems.org" - -gemspec diff --git a/vendor/plugins/rakismet/MIT-LICENSE b/vendor/plugins/rakismet/MIT-LICENSE deleted file mode 100644 index b77c480..0000000 --- a/vendor/plugins/rakismet/MIT-LICENSE +++ /dev/null @@ -1,20 +0,0 @@ -Copyright (c) 2008 Josh French - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/vendor/plugins/rakismet/README.md b/vendor/plugins/rakismet/README.md deleted file mode 100644 index 17ba2bd..0000000 --- a/vendor/plugins/rakismet/README.md +++ /dev/null @@ -1,229 +0,0 @@ -Rakismet -======== - -**Akismet** () is a collaborative spam filtering service. -**Rakismet** is easy Akismet integration with Rails and rack apps. TypePad's -AntiSpam service and generic Akismet endpoints are supported. - -Compatibility -============= - -**Rakismet >= 1.0.0** work with Rails 3 and other Rack-based frameworks. - -**Rakismet <= 0.4.2** is compatible with Rails 2. - -Getting Started -=============== - -Once you've installed the Rakismet gem and added it to your application's Gemfile, -you'll need an API key. Head on over to http://akismet.com/signup/ and sign up -for a new username. - -Configure the Rakismet key and the URL of your application by setting the following -in application.rb: - -```ruby -config.rakismet.key = 'your wordpress key' -config.rakismet.url = 'http://yourdomain.com/' -``` - -or an initializer, for example `config/initializers/rakismet.rb`: - -```ruby -YourApp::Application.config.rakismet.key = 'your wordpress key' -YourApp::Application.config.rakismet.url = 'http://yourdomain.com/' -``` - -If you wish to use another Akismet-compatible API provider such as TypePad's -antispam service, you'll also need to set `config.rakismet.host` to your service -provider's endpoint. - -If you want to use a proxy to access akismet (i.e. your application is behind a -firewall), set the proxy_host and proxy_port option. - -```ruby -config.rakismet.proxy_host = 'http://yourdomain.com/' -config.rakismet.proxy_port = '8080' -``` - -Checking For Spam ------------------ - -First, introduce Rakismet to your model: - -```ruby -class Comment - include Rakismet::Model -end -``` - -With Rakismet mixed in to your model, you'll get three instance methods for interacting with -Akismet: - - * `spam?` submits the comment to Akismet and returns true if Akismet thinks the comment is spam, false if not. - * `ham!` resubmits a valid comment that Akismet erroneously marked as spam (marks it as a false positive.) - * `spam!` resubmits a spammy comment that Akismet missed (marks it as a false negative.) - -The `ham!` and `spam!` methods will change the value of `spam?` but their -primary purpose is to send feedback to Akismet. The service works best when you -help correct the rare mistake; please consider using these methods if you're -moderating comments or otherwise reviewing the Akismet responses. - -Configuring Your Model ----------------------- - -Rakismet sends the following information to the spam-hungry robots at Akismet: - - author : name submitted with the comment - author_url : URL submitted with the comment - author_email : email submitted with the comment - comment_type : Defaults to comment but you can set it to trackback, pingback, or something more appropriate - content : the content submitted - permalink : the permanent URL for the entry the comment belongs to - user_ip : IP address used to submit this comment - user_agent : user agent string - referrer : referring URL (note the spelling) - -By default, Rakismet just looks for attributes or methods on your class that -match these names. You don't have to have accessors that match these exactly, -however. If yours differ, just tell Rakismet what to call them: - -```ruby -class Comment - include Rakismet::Model - attr_accessor :commenter_name, :commenter_email - rakismet_attrs :author => :commenter_name, :author_email => :commenter_email -end -``` - -Or you can pass in a proc, to access associations: - -```ruby -class Comment < ActiveRecord::Base - include Rakismet::Model - belongs_to :author - rakismet_attrs :author => proc { author.name }, - :author_email => proc { author.email } -end -``` - -You can even hard-code specific fields: - -```ruby -class Trackback - include Rakismet::Model - rakismet_attrs :comment_type => "trackback" -end -``` - -Optional Request Variables --------------------------- - -Akismet wants certain information about the request environment: remote IP, the -user agent string, and the HTTP referer when available. Normally, Rakismet -asks your model for these. Storing this information on your model allows you to -call the `spam?` method at a later time. For instance, maybe you're storing your -comments in an administrative queue or processing them with a background job. - -You don't need to have these three attributes on your model, however. If you -choose to omit them, Rakismet will instead look at the current request (if one -exists) and take the values from the request object instead. - -This means that if you are **not storing the request variables**, you must call -`spam?` from within the controller action that handles comment submissions. That -way the IP, user agent, and referer will belong to the person submitting the -comment. If you're not storing the request variables and you call `spam?` at a -later time, the request information will be missing or invalid and Akismet won't -be able to do its job properly. - -If you've decided to handle the request variables yourself, you can disable the -middleware responsible for tracking the request information by adding this to -your app initialization: - -```ruby -config.rakismet.use_middleware = false -``` - -Testing -------- - -Rakismet can be configued to tell Akismet that it should operate in test mode - -so Akismet will not change its behavior based on any test API calls, meaning -they will have no training effect. That means your tests can be somewhat -repeatable in the sense that one test won't influence subsequent calls. - -You can configure Rakismet for test mode via application.rb: - -```ruby -config.rakismet.test = false # <- default -config.rakismet.test = true -``` - -Or via an initializer: - -```ruby -YourApp::Application.config.rakismet.test = false # <- default -YourApp::Application.config.rakismet.test = true -``` - -**NOTE**: When running in Rails, Rakismet will run in test mode when your Rails -environment is `test` or `development`, unless explictly configured otherwise. -Outside of Rails Rakismet defaults to test mode turned **off**. - - -Verifying Responses -------------------- - -If you want to see what's happening behind the scenes, after you call one of -`@comment.spam?`, `@comment.spam!` or `@comment.ham!` you can check -`@comment.akismet_response`. - -This will contain the last response from the Akismet server. In the case of -`spam?` it should be `true` or `false.` For `spam!` and `ham!` it should be -`Feedback received.` If Akismet returned an error instead (e.g. if you left out -some required information) this will contain the error message. - -FAQ -=== - -Why does Akismet think all of my test data is spam? ---------------------------------------------------- - -Akismet needs enough information to decide if your test data is spam or not. -Try to supply as much as possible, especially the author name and request -variables. - -How can I simulate a spam submission? -------------------------------------- - -Most people have the opposite problem, where Akismet doesn't think anything is -spam. The only guaranteed way to trigger a positive spam response is to set the -comment author to "viagra-test-123". - -If you've done this and `spam?` is still returning false, you're probably -missing the user IP or one of the key/url config variables. One way to check is -to call `@comment.akismet_response`. If you are missing a required field or -there was another error, this will hold the Akismet error message. If your comment -was processed normally, this value will simply be `true` or `false`. - -Can I use Rakismet with a different ORM or framework? ------------------------------------------------------ - -Sure. Rakismet doesn't care what your persistence layer is. It will work with -Datamapper, a NoSQL store, or whatever next month's DB flavor is. - -Rakismet also has no dependencies on Rails or any of its components, and only -uses a small Rack middleware object to do some of its magic. Depending on your -framework, you may have to modify this slightly and/or manually place it in your -stack. - -You'll also need to set a few config variables by hand. Instead of -`config.rakismet.key`, `config.rakismet.url`, and `config.rakismet.host`, set -these values directly with `Rakismet.key`, `Rakismet.url`, and `Rakismet.host`. - ---------------------------------------------------------------------------- - -If you have any implementation or usage questions, don't hesitate to get in -touch: josh@vitamin-j.com. - -Copyright (c) 2008 Josh French, released under the MIT license diff --git a/vendor/plugins/rakismet/Rakefile b/vendor/plugins/rakismet/Rakefile deleted file mode 100644 index 3e99fab..0000000 --- a/vendor/plugins/rakismet/Rakefile +++ /dev/null @@ -1,9 +0,0 @@ -require 'bundler' -Bundler::GemHelper.install_tasks - -require 'rspec/core/rake_task' -RSpec::Core::RakeTask.new do |spec| - spec.rspec_opts = ["--color", "--format progress"] -end - -task :default => :spec \ No newline at end of file diff --git a/vendor/plugins/rakismet/lib/rakismet.rb b/vendor/plugins/rakismet/lib/rakismet.rb deleted file mode 100644 index f95e8fa..0000000 --- a/vendor/plugins/rakismet/lib/rakismet.rb +++ /dev/null @@ -1,92 +0,0 @@ -require 'net/http' -require 'uri' -require 'cgi' -require 'yaml' - -require 'rakismet/model' -require 'rakismet/middleware' -require 'rakismet/version' - -if defined?(Rails) && Rails::VERSION::STRING > '3.2.0' - require 'rakismet/railtie.rb' - $stderr.puts "W: on Rails 3, this vendored version of rakismet should be replaced by a proper dependency" -end - -module Rakismet - Request = Struct.new(:user_ip, :user_agent, :referrer) - Undefined = Class.new(NameError) - - class << self - attr_accessor :key, :url, :host, :proxy_host, :proxy_port, :test - - def request - @request ||= Request.new - end - - def set_request_vars(env) - request.user_ip, request.user_agent, request.referrer = - env['REMOTE_ADDR'], env['HTTP_USER_AGENT'], env['HTTP_REFERER'] - end - - def clear_request - @request = Request.new - end - - def headers - @headers ||= begin - user_agent = "Rakismet/#{Rakismet::VERSION}" - user_agent = "Rails/#{Rails.version} | " + user_agent if defined?(Rails) - { 'User-Agent' => user_agent, 'Content-Type' => 'application/x-www-form-urlencoded' } - end - end - - def validate_key - validate_config - akismet = URI.parse(verify_url) - response = Net::HTTP::Proxy(proxy_host, proxy_port).start(akismet.host) do |http| - data = "key=#{Rakismet.key}&blog=#{Rakismet.url}" - http.post(akismet.path, data, Rakismet.headers) - end - @valid_key = (response.body == 'valid') - end - - def valid_key? - @valid_key == true - end - - def akismet_call(function, args={}) - validate_config - args.merge!(:blog => Rakismet.url, :is_test => Rakismet.test_mode) - akismet = URI.parse(call_url(function)) - response = Net::HTTP::Proxy(proxy_host, proxy_port).start(akismet.host) do |http| - params = args.map do |k,v| - param = v.class < String ? v.to_str : v.to_s # for ActiveSupport::SafeBuffer and Nil, respectively - "#{k}=#{CGI.escape(param)}" - end - http.post(akismet.path, params.join('&'), Rakismet.headers) - end - response.body - end - - protected - - def verify_url - "http://#{Rakismet.host}/1.1/verify-key" - end - - def call_url(function) - "http://#{Rakismet.key}.#{Rakismet.host}/1.1/#{function}" - end - - def validate_config - raise Undefined, "Rakismet.key is not defined" if Rakismet.key.nil? || Rakismet.key.empty? - raise Undefined, "Rakismet.url is not defined" if Rakismet.url.nil? || Rakismet.url.empty? - raise Undefined, "Rakismet.host is not defined" if Rakismet.host.nil? || Rakismet.host.empty? - end - - def test_mode - test ? 1 : 0 - end - end - -end diff --git a/vendor/plugins/rakismet/lib/rakismet/middleware.rb b/vendor/plugins/rakismet/lib/rakismet/middleware.rb deleted file mode 100644 index f884692..0000000 --- a/vendor/plugins/rakismet/lib/rakismet/middleware.rb +++ /dev/null @@ -1,16 +0,0 @@ -module Rakismet - class Middleware - - def initialize(app) - @app = app - end - - def call(env) - Rakismet.set_request_vars(env) - response = @app.call(env) - Rakismet.clear_request - response - end - - end -end diff --git a/vendor/plugins/rakismet/lib/rakismet/model.rb b/vendor/plugins/rakismet/lib/rakismet/model.rb deleted file mode 100644 index 056abc2..0000000 --- a/vendor/plugins/rakismet/lib/rakismet/model.rb +++ /dev/null @@ -1,86 +0,0 @@ -module Rakismet - module Model - - def self.included(base) - base.class_eval do - attr_accessor :akismet_response - class << self; attr_accessor :akismet_attrs; end - extend ClassMethods - include InstanceMethods - self.rakismet_attrs - end - end - - module ClassMethods - def rakismet_attrs(args={}) - self.akismet_attrs ||= {} - [:comment_type, :author, :author_url, :author_email, :content, :user_role].each do |field| - # clunky, but throwing around +type+ will break your heart - fieldname = field.to_s =~ %r(^comment_) ? field : "comment_#{field}".intern - self.akismet_attrs[fieldname] = args.delete(field) || field - end - [:user_ip, :user_agent, :referrer].each do |field| - self.akismet_attrs[field] = args.delete(field) || field - end - args.each_pair do |f,v| - self.akismet_attrs[f] = v - end - end - - def inherited(subclass) - super - subclass.rakismet_attrs akismet_attrs.dup - end - end - - module InstanceMethods - def spam? - if instance_variable_defined? :@_spam - @_spam - else - data = akismet_data - self.akismet_response = Rakismet.akismet_call('comment-check', data) - @_spam = self.akismet_response == 'true' - end - end - - def spam! - Rakismet.akismet_call('submit-spam', akismet_data) - @_spam = true - end - - def ham! - Rakismet.akismet_call('submit-ham', akismet_data) - @_spam = false - end - - private - - def akismet_data - akismet = self.class.akismet_attrs.keys.inject({}) do |data,attr| - mapped_field = self.class.akismet_attrs[attr] - data.merge attr => if mapped_field.is_a?(Proc) - instance_eval(&mapped_field) - elsif !mapped_field.nil? && respond_to?(mapped_field) - send(mapped_field) - elsif not [:comment_type, :author, :author_email, - :author_url, :content, :user_role, - :user_ip, :referrer, - :user_agent].include?(mapped_field) - # we've excluded any fields that appear to - # have their default unmapped values - mapped_field - elsif respond_to?(attr) - send(attr) - elsif Rakismet.request.respond_to?(attr) - Rakismet.request.send(attr) - end - end - akismet.delete_if { |k,v| v.nil? || v.empty? } - akismet[:comment_type] ||= 'comment' - akismet - end - end - - end -end diff --git a/vendor/plugins/rakismet/lib/rakismet/railtie.rb b/vendor/plugins/rakismet/lib/rakismet/railtie.rb deleted file mode 100644 index d6839bb..0000000 --- a/vendor/plugins/rakismet/lib/rakismet/railtie.rb +++ /dev/null @@ -1,22 +0,0 @@ -require 'rails' -require 'rakismet' - -module Rakismet - class Railtie < Rails::Railtie - - config.rakismet = ActiveSupport::OrderedOptions.new - config.rakismet.host = 'rest.akismet.com' - config.rakismet.use_middleware = true - - initializer 'rakismet.setup', :after => :load_config_initializers do |app| - Rakismet.key = app.config.rakismet[:key] - Rakismet.url = app.config.rakismet[:url] - Rakismet.host = app.config.rakismet[:host] - Rakismet.proxy_host = app.config.rakismet[:proxy_host] - Rakismet.proxy_port = app.config.rakismet[:proxy_port] - Rakismet.test = app.config.rakismet.fetch(:test) { Rails.env.test? || Rails.env.development? } - app.middleware.use Rakismet::Middleware if app.config.rakismet.use_middleware - end - - end -end diff --git a/vendor/plugins/rakismet/lib/rakismet/version.rb b/vendor/plugins/rakismet/lib/rakismet/version.rb deleted file mode 100644 index 9f69b59..0000000 --- a/vendor/plugins/rakismet/lib/rakismet/version.rb +++ /dev/null @@ -1,3 +0,0 @@ -module Rakismet - VERSION = "1.2.1" -end diff --git a/vendor/plugins/rakismet/rakismet.gemspec b/vendor/plugins/rakismet/rakismet.gemspec deleted file mode 100644 index 546a788..0000000 --- a/vendor/plugins/rakismet/rakismet.gemspec +++ /dev/null @@ -1,25 +0,0 @@ -# -*- encoding: utf-8 -*- -require File.expand_path('../lib/rakismet/version', __FILE__) - -Gem::Specification.new do |s| - s.name = "rakismet" - s.version = Rakismet::VERSION - s.platform = Gem::Platform::RUBY - s.authors = ["Josh French"] - s.email = "josh@vitamin-j.com" - s.homepage = "http://github.com/joshfrench/rakismet" - s.summary = "Akismet and TypePad AntiSpam integration for Rails." - s.description = "Rakismet is the easiest way to integrate Akismet or TypePad's AntiSpam into your Rails app." - s.date = "2012-04-22" - - s.rubyforge_project = "rakismet" - s.add_development_dependency "rake" - s.add_development_dependency "rspec", "~> 2.11" - - s.files = `git ls-files`.split("\n") - s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n") - s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) } - s.require_paths = ["lib"] - s.extra_rdoc_files = ["README.md"] -end - diff --git a/vendor/plugins/rakismet/spec/.rspec b/vendor/plugins/rakismet/spec/.rspec deleted file mode 100644 index 4e1e0d2..0000000 --- a/vendor/plugins/rakismet/spec/.rspec +++ /dev/null @@ -1 +0,0 @@ ---color diff --git a/vendor/plugins/rakismet/spec/models/block_params_spec.rb b/vendor/plugins/rakismet/spec/models/block_params_spec.rb deleted file mode 100644 index 4681e5b..0000000 --- a/vendor/plugins/rakismet/spec/models/block_params_spec.rb +++ /dev/null @@ -1,25 +0,0 @@ -require 'spec_helper' - -PROC = proc { author.reverse } - -class BlockAkismetModel - include Rakismet::Model - rakismet_attrs :author => PROC -end - -describe BlockAkismetModel do - - before do - @block = BlockAkismetModel.new - comment_attrs.each_pair { |k,v| @block.stub!(k).and_return(v) } - end - - it "should accept a block" do - BlockAkismetModel.akismet_attrs[:comment_author].should eql(PROC) - end - - it "should eval block with self = instance" do - data = @block.send(:akismet_data) - data[:comment_author].should eql(comment_attrs[:author].reverse) - end -end diff --git a/vendor/plugins/rakismet/spec/models/custom_params_spec.rb b/vendor/plugins/rakismet/spec/models/custom_params_spec.rb deleted file mode 100644 index caf5109..0000000 --- a/vendor/plugins/rakismet/spec/models/custom_params_spec.rb +++ /dev/null @@ -1,20 +0,0 @@ -require 'spec_helper' - -MAPPED_PARAMS = { :comment_type => :type2, :author => :author2, :content => :content2, - :author_email => :author_email2, :author_url => :author_url2, - :user_role => :user_role2 } - -class CustomAkismetModel - include Rakismet::Model - rakismet_attrs MAPPED_PARAMS.dup -end - - -describe CustomAkismetModel do - it "should override default mappings" do - [:comment_type, :author, :author_url, :author_email, :content, :user_role].each do |field| - fieldname = field.to_s =~ %r(^comment_) ? field : "comment_#{field}".intern - CustomAkismetModel.akismet_attrs[fieldname].should eql(MAPPED_PARAMS[field]) - end - end -end diff --git a/vendor/plugins/rakismet/spec/models/extended_params_spec.rb b/vendor/plugins/rakismet/spec/models/extended_params_spec.rb deleted file mode 100644 index a898194..0000000 --- a/vendor/plugins/rakismet/spec/models/extended_params_spec.rb +++ /dev/null @@ -1,16 +0,0 @@ -require 'spec_helper' - -EXTRA = { :extra => :extra, :another => lambda { } } - -class ExtendedAkismetModel - include Rakismet::Model - rakismet_attrs EXTRA.dup -end - -describe ExtendedAkismetModel do - it "should include additional attributes" do - [:extra, :another].each do |field| - ExtendedAkismetModel.akismet_attrs[field].should eql(EXTRA[field]) - end - end -end diff --git a/vendor/plugins/rakismet/spec/models/rakismet_model_spec.rb b/vendor/plugins/rakismet/spec/models/rakismet_model_spec.rb deleted file mode 100644 index 084baf6..0000000 --- a/vendor/plugins/rakismet/spec/models/rakismet_model_spec.rb +++ /dev/null @@ -1,98 +0,0 @@ -require 'spec_helper' - -describe AkismetModel do - - before do - @model = AkismetModel.new - comment_attrs.each_pair { |k,v| @model.stub!(k).and_return(v) } - end - - it "should have default mappings" do - [:comment_type, :author, :author_email, :author_url, :content, :user_role].each do |field| - fieldname = field.to_s =~ %r(^comment_) ? field : "comment_#{field}".intern - AkismetModel.akismet_attrs[fieldname].should eql(field) - end - end - - it "should have request mappings" do - [:user_ip, :user_agent, :referrer].each do |field| - AkismetModel.akismet_attrs[field].should eql(field) - end - end - - it "should populate comment type" do - @model.send(:akismet_data)[:comment_type].should == comment_attrs[:comment_type] - end - - describe ".spam?" do - - it "should use request variables from Rakismet.request if absent in model" do - [:user_ip, :user_agent, :referrer].each do |field| - @model.should_not respond_to(:field) - end - Rakismet.stub!(:request).and_return(request) - Rakismet.should_receive(:akismet_call). - with('comment-check', akismet_attrs.merge(:user_ip => '127.0.0.1', - :user_agent => 'RSpec', - :referrer => 'http://test.host/referrer')) - @model.spam? - end - - it "should cache result of #spam?" do - Rakismet.should_receive(:akismet_call).once - @model.spam? - @model.spam? - end - - it "should be true if comment is spam" do - Rakismet.stub!(:akismet_call).and_return('true') - @model.should be_spam - end - - it "should be false if comment is not spam" do - Rakismet.stub!(:akismet_call).and_return('false') - @model.should_not be_spam - end - - it "should set akismet_response" do - Rakismet.stub!(:akismet_call).and_return('response') - @model.spam? - @model.akismet_response.should eql('response') - end - - it "should not throw an error if request vars are missing" do - Rakismet.stub!(:request).and_return(empty_request) - lambda { @model.spam? }.should_not raise_error(NoMethodError) - end - end - - - describe ".spam!" do - it "should call Base.akismet_call with submit-spam" do - Rakismet.should_receive(:akismet_call).with('submit-spam', akismet_attrs) - @model.spam! - end - - it "should mutate #spam?" do - Rakismet.stub!(:akismet_call) - @model.instance_variable_set(:@_spam, false) - @model.spam! - @model.should be_spam - end - end - - describe ".ham!" do - it "should call Base.akismet_call with submit-ham" do - Rakismet.should_receive(:akismet_call).with('submit-ham', akismet_attrs) - @model.ham! - end - - it "should mutate #spam?" do - Rakismet.stub!(:akismet_call) - @model.instance_variable_set(:@_spam, true) - @model.ham! - @model.should_not be_spam - end - end - -end diff --git a/vendor/plugins/rakismet/spec/models/request_params_spec.rb b/vendor/plugins/rakismet/spec/models/request_params_spec.rb deleted file mode 100644 index b0dfaaa..0000000 --- a/vendor/plugins/rakismet/spec/models/request_params_spec.rb +++ /dev/null @@ -1,23 +0,0 @@ -require 'spec_helper' - -class RequestParams - include Rakismet::Model - attr_accessor :user_ip, :user_agent, :referrer -end - -describe RequestParams do - before do - @model = RequestParams.new - attrs = comment_attrs(:user_ip => '192.168.0.1', :user_agent => 'Rakismet', :referrer => 'http://localhost/referrer') - attrs.each_pair { |k,v| @model.stub!(k).and_return(v) } - end - - it "should use local values even if Rakismet.request is populated" do - Rakismet.stub(:request).and_return(request) - Rakismet.should_receive(:akismet_call). - with('comment-check', akismet_attrs.merge(:user_ip => '192.168.0.1', - :user_agent => 'Rakismet', - :referrer => 'http://localhost/referrer')) - @model.spam? - end -end diff --git a/vendor/plugins/rakismet/spec/models/subclass_spec.rb b/vendor/plugins/rakismet/spec/models/subclass_spec.rb deleted file mode 100644 index 54ab702..0000000 --- a/vendor/plugins/rakismet/spec/models/subclass_spec.rb +++ /dev/null @@ -1,14 +0,0 @@ -require 'spec_helper' - -class Subclass < AkismetModel -end - -describe Subclass do - it "should inherit parent's rakismet attrs" do - Subclass.akismet_attrs.should eql AkismetModel.akismet_attrs # key/value equality - end - - it "should get a new copy of parent's rakismet attrs" do - Subclass.akismet_attrs.should_not equal AkismetModel.akismet_attrs # object equality - end -end diff --git a/vendor/plugins/rakismet/spec/rakismet_middleware_spec.rb b/vendor/plugins/rakismet/spec/rakismet_middleware_spec.rb deleted file mode 100644 index 3697726..0000000 --- a/vendor/plugins/rakismet/spec/rakismet_middleware_spec.rb +++ /dev/null @@ -1,27 +0,0 @@ -require 'spec_helper' - -describe Rakismet::Middleware do - - let(:env) { { 'REMOTE_ADDR' => '127.0.0.1', 'HTTP_USER_AGENT' => 'RSpec', 'HTTP_REFERER' => 'http://test.host/referrer' } } - let(:app) { double(:app, :call => nil) } - let(:request) { double(:request).as_null_object } - - before do - @middleware = Rakismet::Middleware.new(app) - end - - it "should set set Rakismet.request variables" do - Rakismet.stub(:request).and_return(request) - request.should_receive(:user_ip=).with('127.0.0.1') - request.should_receive(:user_agent=).with('RSpec') - request.should_receive(:referrer=).with('http://test.host/referrer') - @middleware.call(env) - end - - it "should clear Rakismet.request after request is complete" do - @middleware.call(env) - Rakismet.request.user_ip.should be_nil - Rakismet.request.user_agent.should be_nil - Rakismet.request.referrer.should be_nil - end -end diff --git a/vendor/plugins/rakismet/spec/rakismet_spec.rb b/vendor/plugins/rakismet/spec/rakismet_spec.rb deleted file mode 100644 index 9d93bea..0000000 --- a/vendor/plugins/rakismet/spec/rakismet_spec.rb +++ /dev/null @@ -1,123 +0,0 @@ -require 'spec_helper' - -describe Rakismet do - - def mock_response(body) - double(:response, :body => body) - end - let(:http) { double(:http, :post => mock_response('akismet response')) } - - before do - Rakismet.key = 'dummy-key' - Rakismet.url = 'test.localhost' - Rakismet.host = 'endpoint.localhost' - end - - describe "proxy host" do - it "should have proxy host and port as nil by default" do - Rakismet.proxy_host.should be_nil - Rakismet.proxy_port.should be_nil - end - end - - describe ".validate_config" do - it "should raise an error if key is not found" do - Rakismet.key = '' - lambda { Rakismet.send(:validate_config) }.should raise_error(Rakismet::Undefined) - end - - it "should raise an error if url is not found" do - Rakismet.url = '' - lambda { Rakismet.send(:validate_config) }.should raise_error(Rakismet::Undefined) - end - - it "should raise an error if host is not found" do - Rakismet.host = '' - lambda { Rakismet.send(:validate_config) }.should raise_error(Rakismet::Undefined) - end - end - - describe ".validate_key" do - before (:each) do - @proxy = mock(Net::HTTP) - Net::HTTP.stub!(:Proxy).and_return(@proxy) - end - - it "should use proxy host and port" do - Rakismet.proxy_host = 'proxy_host' - Rakismet.proxy_port = 'proxy_port' - @proxy.stub!(:start).and_return(mock_response('valid')) - Net::HTTP.should_receive(:Proxy).with('proxy_host', 'proxy_port').and_return(@proxy) - Rakismet.validate_key - end - - it "should set @@valid_key = true if key is valid" do - @proxy.stub!(:start).and_return(mock_response('valid')) - Rakismet.validate_key - Rakismet.valid_key?.should be_true - end - - it "should set @@valid_key = false if key is invalid" do - @proxy.stub!(:start).and_return(mock_response('invalid')) - Rakismet.validate_key - Rakismet.valid_key?.should be_false - end - - it "should build url with host" do - host = "api.antispam.typepad.com" - Rakismet.host = host - @proxy.should_receive(:start).with(host).and_yield(http) - Rakismet.validate_key - end - end - - describe ".akismet_call" do - before do - @proxy = mock(Net::HTTP) - Net::HTTP.stub!(:Proxy).and_return(@proxy) - @proxy.stub(:start).and_yield(http) - end - - it "should use proxy host and port" do - Rakismet.proxy_host = 'proxy_host' - Rakismet.proxy_port = 'proxy_port' - @proxy.stub!(:start).and_return(mock_response('valid')) - Net::HTTP.should_receive(:Proxy).with('proxy_host', 'proxy_port').and_return(@proxy) - Rakismet.send(:akismet_call, 'bogus-function') - end - - it "should build url with API key for the correct host" do - host = 'api.antispam.typepad.com' - Rakismet.host = host - @proxy.should_receive(:start).with("#{Rakismet.key}.#{host}") - Rakismet.send(:akismet_call, 'bogus-function') - end - - it "should post data to named function" do - http.should_receive(:post).with('/1.1/bogus-function', %r(foo=#{CGI.escape 'escape//this'}), Rakismet.headers) - Rakismet.send(:akismet_call, 'bogus-function', { :foo => 'escape//this' }) - end - - it "should default to not being in test mode" do - http.should_receive(:post).with(anything, %r(is_test=0), anything) - Rakismet.send(:akismet_call, 'bogus-function') - end - - it "should be in test mode when configured" do - Rakismet.test = true - http.should_receive(:post).with(anything, %r(is_test=1), anything) - Rakismet.send(:akismet_call, 'bogus-function') - end - - it "should return response.body" do - Rakismet.send(:akismet_call, 'bogus-function').should eql('akismet response') - end - - it "should build query string when params are nil" do - lambda { - Rakismet.send(:akismet_call, 'bogus-function', { :nil_param => nil }) - }.should_not raise_error(NoMethodError) - end - end - -end diff --git a/vendor/plugins/rakismet/spec/spec_helper.rb b/vendor/plugins/rakismet/spec/spec_helper.rb deleted file mode 100644 index 112385c..0000000 --- a/vendor/plugins/rakismet/spec/spec_helper.rb +++ /dev/null @@ -1,34 +0,0 @@ -require File.expand_path "lib/rakismet" -require 'ostruct' - -RSpec.configure do |config| - config.mock_with :rspec -end - -class AkismetModel - include Rakismet::Model -end - -def comment_attrs(attrs={}) - { :comment_type => 'test', :author => 'Rails test', - :author_email => 'test@test.host', :author_url => 'test.host', - :content => 'comment content', :blog => Rakismet.url }.merge(attrs) -end - -def akismet_attrs(attrs={}) - { :comment_type => 'test', :comment_author_email => 'test@test.host', - :comment_author => 'Rails test', :comment_author_url => 'test.host', - :comment_content => 'comment content' }.merge(attrs) -end - -def request - OpenStruct.new(:user_ip => '127.0.0.1', - :user_agent => 'RSpec', - :referrer => 'http://test.host/referrer') -end - -def empty_request - OpenStruct.new(:user_ip => nil, - :user_agent => nil, - :referrer => nil) -end \ No newline at end of file -- libgit2 0.21.2