@@ -5,11 +5,7 @@ module Agents |
||
| 5 | 5 |
cannot_receive_events! |
| 6 | 6 |
|
| 7 | 7 |
description <<-MD |
| 8 |
- There are two options in using the Twitter User Agent. |
|
| 9 |
- |
|
| 10 |
- The first option is to follow the timeline of a specific Twitter user. |
|
| 11 |
- |
|
| 12 |
- The second option is to follow your own home timeline including both your tweets and tweets from people whom you are following. |
|
| 8 |
+ The Twitter User Agent either follows the timeline of a specific Twitter user or follow your own home timeline including both your tweets and tweets from people whom you are following. |
|
| 13 | 9 |
|
| 14 | 10 |
#{twitter_dependencies_missing if dependencies_missing?}
|
| 15 | 11 |
|
@@ -70,7 +66,10 @@ module Agents |
||
| 70 | 66 |
|
| 71 | 67 |
def validate_options |
| 72 | 68 |
errors.add(:base, "expected_update_period_in_days is required") unless options['expected_update_period_in_days'].present? |
| 73 |
- |
|
| 69 |
+ |
|
| 70 |
+ if options[:choose_home_time_line] == 'false' |
|
| 71 |
+ errors.add(:base, "username is required") |
|
| 72 |
+ end |
|
| 74 | 73 |
if options[:include_retweets].present? && !%w[true false].include?(options[:include_retweets]) |
| 75 | 74 |
errors.add(:base, "include_retweets must be a boolean value string (true/false)") |
| 76 | 75 |
end |
@@ -89,7 +88,7 @@ module Agents |
||
| 89 | 88 |
end |
| 90 | 89 |
|
| 91 | 90 |
def choose_home_time_line? |
| 92 |
- interpolated[:choose_home_time_line] != "false" |
|
| 91 |
+ interpolated[:choose_home_time_line] == "true" |
|
| 93 | 92 |
end |
| 94 | 93 |
|
| 95 | 94 |
def include_retweets? |
@@ -107,7 +106,6 @@ module Agents |
||
| 107 | 106 |
|
| 108 | 107 |
if choose_home_time_line? |
| 109 | 108 |
|
| 110 |
- # http://rdoc.info/gems/twitter/Twitter/REST/Timelines#user_timeline-instance_method |
|
| 111 | 109 |
tweets = twitter.home_timeline(opts) |
| 112 | 110 |
|
| 113 | 111 |
tweets.each do |tweet| |
@@ -45,7 +45,7 @@ describe Agents::TwitterUserAgent do |
||
| 45 | 45 |
|
| 46 | 46 |
describe "#check that home timeline works" do |
| 47 | 47 |
before do |
| 48 |
- stub_request(:any, //).to_return(:body => File.read(Rails.root.join("spec/data_fixtures/user_tweets.json")), :status => 200)
|
|
| 48 |
+ stub_request(:any, "https://api.twitter.com/1.1/statuses/home_timeline.json?contributor_details=true&count=200&exclude_replies=false&include_entities=true&include_rts=true").to_return(:body => File.read(Rails.root.join("spec/data_fixtures/user_tweets.json")), :status => 200)
|
|
| 49 | 49 |
end |
| 50 | 50 |
|
| 51 | 51 |
it "should check that event changed with timeline sets to true" do |