require 'test_helper' class TimelinesTest < Totter::TestCase def test_global VCR.use_cassette 'timelines/global' do response = Totter.global_timeline(:limit => 15) assert_equal 15, response.items.length assert_equal 'timeline-global', response.pusher_channel end end def test_random_global VCR.use_cassette 'timelines/random/global' do client = unauthenticated_monkeybars_production_client response = client.random_timeline_decision next_response = client.random_timeline_decision refute_equal response, next_response end end def test_random_hashtag VCR.use_cassette 'timelines/random/hashtag' do client = unauthenticated_monkeybars_production_client response = client.random_timeline_decision({:hashtag => 'mycloset'}) hashtags = response.meta.question_entities.map { |ent| ent.hashtag } assert_equal 'hashtag', response.meta.question_entities.first.type assert_includes hashtags, 'mycloset' end end def test_random_sticker VCR.use_cassette 'timelines/random/sticker' do client = unauthenticated_monkeybars_production_client response = client.random_timeline_decision({:sticker => 'featured'}) assert response.user.stickers.include? 'featured' end end def test_hashtags VCR.use_cassette 'timelines/hashtags' do client = local_client response = local_client.hashtag_timeline('test') assert_equal 1, response.items.length assert_equal 'timeline-hashtag-test', response.pusher_channel end end def test_stickers VCR.use_cassette 'timelines/stickers' do client = local_client response = local_client.sticker_timeline('test') assert_equal 1, response.items.length assert_equal 'timeline-sticker-test', response.pusher_channel end end def test_search VCR.use_cassette 'timelines/search' do client = local_client response = local_client.search_timeline('bacon') assert_equal 2, response.items.length end end def test_flagged VCR.use_cassette 'timelines/flagged' do client = local_client response = local_client.flagged_timeline assert_equal 1, response.items.length assert_equal 'timeline-flagged', response.pusher_channel end end def test_user VCR.use_cassette 'timelines/user' do client = local_client response = local_client.user_timeline(4) assert_equal 0, response.items.length assert_equal 'timeline-user-4', response.pusher_channel end end end