Skip to content
Browse files

Ensure that we provide integer user ids to the streaming API connection

  • Loading branch information...
1 parent c82c6b9 commit cdc3a90b6b13a32e733e7e1d3c152c7bbdc67615 @lukemelia committed May 15, 2012
Showing with 10 additions and 9 deletions.
  1. +4 −3 lib/weeter/twitter/tweet_consumer.rb
  2. +6 −6 spec/weeter/twitter/tweet_consumer_spec.rb
View
7 lib/weeter/twitter/tweet_consumer.rb
@@ -46,15 +46,16 @@ def reconnect(filter_params)
end
protected
-
+
def clean_filter_params(p)
return {} if p.nil?
cleaned_params = {}
cleaned_params['follow'] = p['follow'] if (p['follow'] || []).any?
+ cleaned_params['follow'] = cleaned_params['follow'].map(&:to_i)
cleaned_params['track'] = p['track'] if (p['track'] || []).any?
cleaned_params
end
-
+
def ignore_tweet(tweet_item)
id = tweet_item['id_str']
text = tweet_item['text']
@@ -64,4 +65,4 @@ def ignore_tweet(tweet_item)
end
end
-end
+end
View
12 spec/weeter/twitter/tweet_consumer_spec.rb
@@ -27,7 +27,7 @@
@client_proxy = mock('NotificationPlugin', :publish_tweet => nil)
@consumer = Weeter::Twitter::TweetConsumer.new(Weeter::Configuration::TwitterConfig.instance, @client_proxy)
end
-
+
after(:each) do
@consumer.connect(@filter_params)
end
@@ -39,26 +39,26 @@
it "should connect to a Twitter JSON stream" do
Twitter::JSONStream.should_receive(:connect).
- with(:ssl => true, :foo => :bar, :params => @filter_params, :method => 'POST')
+ with(:ssl => true, :foo => :bar, :params => {'follow' => [1,2,3]}, :method => 'POST')
end
-
+
it "should publish new tweet if publishable" do
mock_tweet = mock('tweet', :deletion? => false, :publishable? => true)
tweet_item = Weeter::TweetItem.stub!(:new).and_return mock_tweet
@client_proxy.should_receive(:publish_tweet).with(mock_tweet)
end
-
+
it "should not publish unpublishable tweets" do
mock_tweet = mock('tweet', :deletion? => false, :publishable? => false, :[] => '')
tweet_item = Weeter::TweetItem.stub!(:new).and_return mock_tweet
@client_proxy.should_not_receive(:publish_tweet).with(mock_tweet)
end
-
+
it "should delete deletion tweets" do
mock_tweet = mock('tweet', :deletion? => true, :publishable? => false)
tweet_item = Weeter::TweetItem.stub!(:new).and_return mock_tweet
@client_proxy.should_receive(:delete_tweet).with(mock_tweet)
end
end
-end
+end

0 comments on commit cdc3a90

Please sign in to comment.
Something went wrong with that request. Please try again.