Changeset 272

Show
Ignore:
Timestamp:
03/11/08 12:01:57 (6 months ago)
Author:
stu
Message:

handle proxies that don't set content type, and exclude forms via same rules as links

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • rubygems/tarantula/trunk/lib/relevance/core_extensions/response.rb

    r147 r272  
    11# dynamically mixed in to response objects 
    22module Relevance::CoreExtensions::Response  
    3   def html? 
    4     content_type == "text/html" 
     3  def html?                                            
     4    # some versions of Rails integration tests don't set content type 
     5    # so we are treating nil as html. A better fix would be welcome here. 
     6    ((content_type =~ %r{^text/html}) != nil)  || content_type == nil 
    57  end 
    68end 
  • rubygems/tarantula/trunk/lib/relevance/tarantula/crawler.rb

    r244 r272  
    125125    end 
    126126  end 
    127    
    128   def should_skip_link?(url) 
     127                
     128  def should_skip_url?(url) 
    129129    return true if url.blank? 
    130130    if @skip_uri_patterns.any? {|pattern| pattern =~ url} 
     
    136136      return true 
    137137    end 
    138     @links_queued.member?(url) 
     138  end 
     139 
     140  def should_skip_link?(url) 
     141    should_skip_url?(url) || @links_queued.member?(url) 
    139142  end 
    140143   
    141144  def should_skip_form_submission?(fs) 
    142     @form_signatures_queued.member?(fs.signature) 
     145    should_skip_url?(fs.action) || @form_signatures_queued.member?(fs.signature) 
    143146  end 
    144147   
  • rubygems/tarantula/trunk/test/relevance/tarantula/crawler_test.rb

    r244 r272  
    253253    crawler.queue_link("/blue-button").should == "/blue-button" 
    254254    crawler.queue_link("/the-red-button").should == nil 
     255  end    
     256   
     257  it "logs and skips form submissions that match a pattern" do 
     258    crawler = Crawler.new 
     259    crawler.expects(:log).with("Skipping /reset-password-form") 
     260    crawler.skip_uri_patterns << /reset-password/              
     261    fs = stub_everything(:action => "/reset-password-form") 
     262    crawler.should_skip_form_submission?(fs).should == true 
    255263  end 
    256264   
  • rubygems/tarantula/trunk/test/test_helper.rb

    r240 r272  
    99 
    1010require 'test/spec' 
    11 require 'mocha' 
     11require 'mocha'     
     12require 'ostruct' 
    1213require 'ruby-debug' 
    1314require 'activerecord'