]> cat aescling's git repositories - mastodon.git/blob - spec/controllers/follower_accounts_controller_spec.rb
Fix sanitizer making block level elements unreadable (#10836)
[mastodon.git] / spec / controllers / follower_accounts_controller_spec.rb
1 require 'rails_helper'
2
3 describe FollowerAccountsController do
4 render_views
5
6 let(:alice) { Fabricate(:account, username: 'alice') }
7 let(:follower0) { Fabricate(:account) }
8 let(:follower1) { Fabricate(:account) }
9
10 describe 'GET #index' do
11 let!(:follow0) { follower0.follow!(alice) }
12 let!(:follow1) { follower1.follow!(alice) }
13
14 context 'when format is html' do
15 subject(:response) { get :index, params: { account_username: alice.username, format: :html } }
16
17 it 'assigns follows' do
18 expect(response).to have_http_status(200)
19
20 assigned = assigns(:follows).to_a
21 expect(assigned.size).to eq 2
22 expect(assigned[0]).to eq follow1
23 expect(assigned[1]).to eq follow0
24 end
25 end
26
27 context 'when format is json' do
28 subject(:response) { get :index, params: { account_username: alice.username, page: page, format: :json } }
29 subject(:body) { JSON.parse(response.body) }
30
31 context 'with page' do
32 let(:page) { 1 }
33
34 it 'returns followers' do
35 expect(response).to have_http_status(200)
36 expect(body['totalItems']).to eq 2
37 expect(body['partOf']).to be_present
38 end
39 end
40
41 context 'without page' do
42 let(:page) { nil }
43
44 it 'returns followers' do
45 expect(response).to have_http_status(200)
46 expect(body['totalItems']).to eq 2
47 expect(body['partOf']).to be_blank
48 end
49 end
50 end
51 end
52 end
This page took 0.078989 seconds and 4 git commands to generate.