Skip to content

Commit

Permalink
Merge git://github.com/jwhitmire/feedzirra into jwhitmire_timeout
Browse files Browse the repository at this point in the history
Conflicts:
	spec/feedzirra/feed_spec.rb
  • Loading branch information
archiloque committed Nov 2, 2011
2 parents 12b63ee + faa0e35 commit f7f5397
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
1 change: 1 addition & 0 deletions lib/feedzirra/feed.rb
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,7 @@ def self.add_feed_to_multi(multi, feed, feed_queue, responses, options)
easy = Curl::Easy.new(feed.feed_url) do |curl|
setup_easy curl, options
curl.headers["If-Modified-Since"] = feed.last_modified.httpdate if feed.last_modified
curl.headers["If-Modified-Since"] = options[:if_modified_since] if options[:if_modified_since] && (!feed.last_modified || (Time.parse(options[:if_modified_since].to_s) > feed.last_modified))
curl.headers["If-None-Match"] = feed.etag if feed.etag

curl.on_success do |c|
Expand Down
20 changes: 17 additions & 3 deletions spec/feedzirra/feed_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ def self.able_to_parse?(val)

describe "#add_url_to_multi" do
before(:each) do
@multi = Curl::Multi.new
@multi = Curl::Multi.get(@paul_feed[:url])
@multi.stub!(:add)
@easy_curl = Curl::Easy.new(@paul_feed[:url])

Expand Down Expand Up @@ -396,7 +396,7 @@ def self.able_to_parse?(val)

describe "#add_feed_to_multi" do
before(:each) do
@multi = Curl::Multi.new
@multi = Curl::Multi.get(@paul_feed[:url])
@multi.stub!(:add)
@easy_curl = Curl::Easy.new(@paul_feed[:url])
@feed = Feedzirra::Feed.parse(sample_feedburner_atom_feed)
Expand All @@ -414,7 +414,13 @@ def self.able_to_parse?(val)
@easy_curl.headers["User-Agent"].should == Feedzirra::Feed::USER_AGENT
end

it "should set if modified since as an option if passed"
it "should set if modified since as an option if passed" do
modified_time = Time.parse("Wed, 28 Jan 2009 04:10:32 GMT")
Feedzirra::Feed.add_feed_to_multi(@multi, @feed, [], {}, {:if_modified_since => modified_time})
modified_time.should be > @feed.last_modified

@easy_curl.headers["If-Modified-Since"].should == modified_time
end

it 'should set follow location to true' do
@easy_curl.should_receive(:follow_location=).with(true)
Expand Down Expand Up @@ -528,6 +534,14 @@ def self.able_to_parse?(val)
it 'should slice the feeds into groups of thirty for processing'
it "should return a feed object if a single feed is passed in"
it "should return an return an array of feed objects if multiple feeds are passed in"

it "should set if modified since as an option if passed" do
modified_time = Time.parse("Wed, 28 Jan 2009 04:10:32 GMT")
Feedzirra::Feed.should_receive(:add_url_to_multi).with(anything, anything, anything, anything, {:if_modified_since => modified_time}).any_number_of_times

@feed = Feedzirra::Feed.fetch_and_parse(sample_feedburner_atom_feed, {:if_modified_since => modified_time})
end

end

describe "#decode_content" do
Expand Down

0 comments on commit f7f5397

Please sign in to comment.