<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -4,12 +4,13 @@ class AssetsController &lt; ApplicationController
   
   # we check to see if the current_user is authorized based on the asset.user
   before_filter :login_required, :except =&gt; [:index, :show, :latest, :radio]
-  before_filter :find_referer, :prevent_abuse, :only =&gt; :show
+  before_filter :set_user_agent, :find_referer, :prevent_abuse, :only =&gt; :show
   
   #rescue_from NoMethodError, :with =&gt; :user_not_found
   #rescue_from ActiveRecord::RecordNotFound, :with =&gt; :not_found
   
   @@valid_listeners = ['msie','webkit','gecko','mozilla','netscape','itunes','chrome','opera']
+  @@bots = ['bot','spider','baidu']
   
   # GET /assets
   # GET /assets.xml
@@ -259,7 +260,6 @@ class AssetsController &lt; ApplicationController
   end
   
   def register_listen
-    @agent = request.user_agent.downcase
     @asset.listens.create(
       :listener     =&gt; current_user || nil, 
       :track_owner  =&gt; @asset.user, 
@@ -270,15 +270,22 @@ class AssetsController &lt; ApplicationController
   
   def bot?
     return true unless present? request.user_agent 
-    not browser? or @agent.include?('bot')
+    not browser? or @@bots.any?{|bot_agent| @agent.include? bot_agent}
   end
   
   def browser?
     @@valid_listeners.any?{|valid_agent| @agent.include? valid_agent} 
   end
   
+  def set_user_agent
+    @agent = request.user_agent.downcase    
+  end
+  
   def prevent_abuse
-    render(:text =&gt; &quot;Denied due to abuse&quot;, :status =&gt; 403) if abuser?    
+    if bot? 
+      Rails.logger.error &quot;#{@asset.filename} #{@agent} #{request.remote_ip} #{@referer} #{current_user || nil}&quot;
+      render(:text =&gt; &quot;Denied due to abuse&quot;, :status =&gt; 403)    
+    end
   end
   
   def abuser?</diff>
      <filename>app/controllers/assets_controller.rb</filename>
    </modified>
    <modified>
      <diff>@@ -15,6 +15,9 @@ Rails::Initializer.run do |config|
   config.gem 'hpricot' # for comment processing / markdown fixing
   config.gem 'mislav-will_paginate', :lib =&gt; 'will_paginate'
   
+  config.gem &quot;rspec&quot;, :lib =&gt; false, :version =&gt; &quot;&gt;= 1.2.0&quot;
+  config.gem &quot;rspec-rails&quot;, :lib =&gt; false, :version =&gt; &quot;&gt;= 1.2.0&quot;  
+  
   # Rmagick is *not* required (for example, sudara uses imagescience)
   # config.gem 'rmagick',       :lib =&gt; 'RMagick'
 </diff>
      <filename>config/environment.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,4 +1,6 @@
 #!/usr/bin/env ruby
+gem 'test-unit', '1.2.3' if RUBY_VERSION.to_f &gt;= 1.9
 ENV['RSPEC'] = 'true'     # allows autotest to discover rspec
 ENV['AUTOTEST'] = 'true'  # allows autotest to run w/ color on linux
-system (RUBY_PLATFORM =~ /mswin|mingw/ ? 'autotest.bat' : 'autotest'), *ARGV
\ No newline at end of file
+system((RUBY_PLATFORM =~ /mswin|mingw/ ? 'autotest.bat' : 'autotest'), *ARGV) ||
+  $stderr.puts(&quot;Unable to find autotest.  Please install ZenTest or fix your PATH&quot;)</diff>
      <filename>script/autospec</filename>
    </modified>
    <modified>
      <diff>@@ -1,4 +1,10 @@
 #!/usr/bin/env ruby
-$LOAD_PATH.unshift(File.expand_path(File.dirname(__FILE__) + &quot;/../vendor/plugins/rspec/lib&quot;))
-require 'spec'
-exit ::Spec::Runner::CommandLine.run(::Spec::Runner::OptionParser.parse(ARGV, STDERR, STDOUT))
+if ARGV.any? {|arg| %w[--drb -X --generate-options -G --help -h --version -v].include?(arg)}
+  require 'rubygems' unless ENV['NO_RUBYGEMS']
+else
+  gem 'test-unit', '1.2.3' if RUBY_VERSION.to_f &gt;= 1.9
+  ENV[&quot;RAILS_ENV&quot;] ||= 'test'
+  require File.expand_path(File.dirname(__FILE__) + &quot;/../config/environment&quot;) unless defined?(RAILS_ROOT)
+end
+require 'spec/autorun'
+exit ::Spec::Runner::CommandLine.run</diff>
      <filename>script/spec</filename>
    </modified>
    <modified>
      <diff>@@ -1,99 +1,9 @@
 #!/usr/bin/env ruby
-$LOAD_PATH.unshift File.dirname(__FILE__) + '/../../rspec/lib' # For svn
-$LOAD_PATH.unshift File.dirname(__FILE__) + '/../vendor/plugins/rspec/lib' # For rspec installed as plugin
-require 'rubygems'
-require 'drb/drb'
-require 'rbconfig'
-require 'spec'
-require 'optparse'
-
-# This is based on Florian Weber's TDDMate
-module Spec
-  module Runner
-    class RailsSpecServer
-      def run(argv, stderr, stdout)
-        $stdout = stdout
-        $stderr = stderr
-
-        base = ActiveRecord::Base
-        def base.clear_reloadable_connections!
-          active_connections.each do |name, conn|
-            if conn.requires_reloading?
-              conn.disconnect!
-              active_connections.delete(name)
-            end
-          end
-        end        
+gem 'test-unit', '1.2.3' if RUBY_VERSION.to_f &gt;= 1.9
 
-        if ::Dispatcher.respond_to?(:cleanup_application)
-          ::Dispatcher.cleanup_application
-        elsif ::Dispatcher.respond_to?(:reset_application!)
-          ::Dispatcher.reset_application!
-        end
-        ::Dependencies.mechanism = :load
-        require_dependency('application.rb') unless Object.const_defined?(:ApplicationController)
-        load File.dirname(__FILE__) + '/../spec/spec_helper.rb'
-
-        ::Spec::Runner::CommandLine.run(
-          ::Spec::Runner::OptionParser.parse(
-            argv,
-            $stderr,
-            $stdout
-          )
-        )
-      end
-    end
-  end
-end
 puts &quot;Loading Rails environment&quot;
+ENV[&quot;RAILS_ENV&quot;] ||= 'test'
+require File.expand_path(File.dirname(__FILE__) + &quot;/../config/environment&quot;) unless defined?(RAILS_ROOT)
 
-ENV[&quot;RAILS_ENV&quot;] = &quot;test&quot;
-require File.expand_path(File.dirname(__FILE__) + &quot;/../config/environment&quot;)
-require 'dispatcher'
-
-def restart_test_server
-  puts &quot;restarting&quot;
-  config       = ::Config::CONFIG
-  ruby         = File::join(config['bindir'], config['ruby_install_name']) + config['EXEEXT']
-  command_line = [ruby, $0, ARGV].flatten.join(' ')
-  exec(command_line)
-end
-
-def daemonize(pid_file = nil)
-  return yield if $DEBUG
-  pid = Process.fork{
-    Process.setsid
-    Dir.chdir(RAILS_ROOT)
-    trap(&quot;SIGINT&quot;){ exit! 0 }
-    trap(&quot;SIGTERM&quot;){ exit! 0 }
-    trap(&quot;SIGHUP&quot;){ restart_test_server }
-    File.open(&quot;/dev/null&quot;){|f|
-      STDERR.reopen f
-      STDIN.reopen  f
-      STDOUT.reopen f
-    }
-    yield
-  }
-  puts &quot;spec_server launched. (PID: %d)&quot; % pid
-  File.open(pid_file,&quot;w&quot;){|f| f.puts pid } if pid_file
-  exit! 0
-end
-
-options = Hash.new
-opts = OptionParser.new
-opts.on(&quot;-d&quot;, &quot;--daemon&quot;){|v| options[:daemon] = true }
-opts.on(&quot;-p&quot;, &quot;--pid PIDFILE&quot;){|v| options[:pid] = v }
-opts.parse!(ARGV)
-
-puts &quot;Ready&quot;
-exec_server = lambda {
-  trap(&quot;USR2&quot;) { restart_test_server } if Signal.list.has_key?(&quot;USR2&quot;)
-  DRb.start_service(&quot;druby://localhost:8989&quot;, Spec::Runner::RailsSpecServer.new)
-  DRb.thread.join
-}
-
-if options[:daemon]
-  daemonize(options[:pid], &amp;exec_server)
-else
-  exec_server.call
-end
+require 'optparse'
+require 'spec/rails/spec_server'</diff>
      <filename>script/spec_server</filename>
    </modified>
    <modified>
      <diff>@@ -10,7 +10,6 @@ describe AssetsController do
     &quot;Mozilla/4.0 (compatible; MSIE 7.0b; Windows NT 6.0)&quot;,
     &quot;msie&quot;,
     'webkit'
-        
     ]
     
   @bad_user_agents = [
@@ -18,6 +17,8 @@ describe AssetsController do
     &quot;&quot;,
     &quot;Googlebot/2.1 (+http://www.google.com/bot.html)&quot;,
     &quot;you're momma's so bot...&quot;
+    &quot;Baiduspider+(+http://www.baidu.jp/spider/) &quot;,
+    &quot;baidu/Nutch-1.0 &quot;
   ]
   
   </diff>
      <filename>spec/controllers/assets_controller_spec.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,7 +1,4 @@
 --colour
---format
-progress
---loadby
-mtime
+--format progress
+--loadby mtime
 --reverse
---backtrace
\ No newline at end of file</diff>
      <filename>spec/spec.opts</filename>
    </modified>
    <modified>
      <diff>@@ -1,14 +1,19 @@
 # This file is copied to ~/spec when you run 'ruby script/generate rspec'
 # from the project root directory.
-ENV[&quot;RAILS_ENV&quot;] = &quot;test&quot;
-require File.expand_path(File.dirname(__FILE__) + &quot;/../config/environment&quot;)
-require 'spec'
+ENV[&quot;RAILS_ENV&quot;] ||= 'test'
+require File.dirname(__FILE__) + &quot;/../config/environment&quot; unless defined?(RAILS_ROOT)
+require 'spec/autorun'
 require 'spec/rails'
 
 Spec::Runner.configure do |config|
+  # If you're not using ActiveRecord you should remove these
+  # lines, delete config/database.yml and disable :active_record
+  # in your config/boot.rb
   config.use_transactional_fixtures = true
   config.use_instantiated_fixtures  = false
   config.fixture_path = RAILS_ROOT + '/spec/fixtures/'
+  config.global_fixtures = :users
+  config.mock_with :mocha
 
 
   # == Fixtures
@@ -21,20 +26,28 @@ Spec::Runner.configure do |config|
   # do so right here. Just uncomment the next line and replace the fixture
   # names with your fixtures.
   #
-  config.global_fixtures = :users
+  # config.global_fixtures = :table_a, :table_b
   #
   # If you declare global fixtures, be aware that they will be declared
   # for all of your examples, even those that don't use them.
   #
+  # You can also declare which fixtures to use (for example fixtures for test/fixtures):
+  #
+  # config.fixture_path = RAILS_ROOT + '/spec/fixtures/'
+  #
   # == Mock Framework
   #
   # RSpec uses it's own mocking framework by default. If you prefer to
   # use mocha, flexmock or RR, uncomment the appropriate line:
   #
-  config.mock_with :mocha
+  # config.mock_with :mocha
   # config.mock_with :flexmock
   # config.mock_with :rr
-  def login_as(user)
+  #
+  # == Notes
+  # 
+  # For more information take a look at Spec::Runner::Configuration and Spec::Runner
+def login_as(user)
     request.session[:user] = user ? users(user).id : nil
   end
   </diff>
      <filename>spec/spec_helper.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>1a7f1055ae24941759f7d21a408ac9e219c01708</id>
    </parent>
  </parents>
  <author>
    <name>Sudara</name>
    <email>sudara@alonetone.com</email>
  </author>
  <url>http://github.com/sudara/alonetone/commit/72babf85d0a1515f1f4bba25c65f30f5a8f8a7cf</url>
  <id>72babf85d0a1515f1f4bba25c65f30f5a8f8a7cf</id>
  <committed-date>2009-06-03T12:09:12-07:00</committed-date>
  <authored-date>2009-06-03T12:09:12-07:00</authored-date>
  <message>Add back rpsec. And bots beware! No more free mp3s for you.</message>
  <tree>17f1df4ceb9b75bfc545e00db1439c67efbce5f8</tree>
  <committer>
    <name>Sudara</name>
    <email>sudara@alonetone.com</email>
  </committer>
</commit>
