]> cat aescling's git repositories - mastodon.git/blob - spec/controllers/api/v1/timelines_controller_spec.rb
Move timelines API from statuses to its own controller, add a check for
[mastodon.git] / spec / controllers / api / v1 / timelines_controller_spec.rb
1 require 'rails_helper'
2
3 RSpec.describe Api::V1::TimelinesController, type: :controller do
4 render_views
5
6 let(:user) { Fabricate(:user, account: Fabricate(:account, username: 'alice')) }
7
8 before do
9 stub_request(:post, "https://pubsubhubbub.superfeedr.com/").to_return(:status => 200, :body => "", :headers => {})
10 allow(controller).to receive(:doorkeeper_token) { token }
11 end
12
13 context 'with a user context' do
14 let(:token) { double acceptable?: true, resource_owner_id: user.id }
15
16 describe 'GET #home' do
17 it 'returns http success' do
18 get :home
19 expect(response).to have_http_status(:success)
20 end
21 end
22
23 describe 'GET #mentions' do
24 it 'returns http success' do
25 get :mentions
26 expect(response).to have_http_status(:success)
27 end
28 end
29
30 describe 'GET #public' do
31 it 'returns http success' do
32 get :public
33 expect(response).to have_http_status(:success)
34 end
35 end
36
37 describe 'GET #tag' do
38 before do
39 PostStatusService.new.call(user.account, 'It is a #test')
40 end
41
42 it 'returns http success' do
43 get :tag, params: { id: 'test' }
44 expect(response).to have_http_status(:success)
45 end
46 end
47 end
48
49 context 'without a user context' do
50 let(:token) { double acceptable?: true, resource_owner_id: nil }
51
52 describe 'GET #home' do
53 it 'returns http unprocessable entity' do
54 get :home
55 expect(response).to have_http_status(:unprocessable_entity)
56 end
57 end
58
59 describe 'GET #mentions' do
60 it 'returns http unprocessable entity' do
61 get :mentions
62 expect(response).to have_http_status(:unprocessable_entity)
63 end
64 end
65
66 describe 'GET #public' do
67 it 'returns http success' do
68 get :public
69 expect(response).to have_http_status(:success)
70 end
71 end
72
73 describe 'GET #tag' do
74 it 'returns http success' do
75 get :tag, params: { id: 'test' }
76 expect(response).to have_http_status(:success)
77 end
78 end
79 end
80 end
This page took 0.109427 seconds and 6 git commands to generate.