1
0

follower_accounts_controller_spec.rb 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. # frozen_string_literal: true
  2. require 'rails_helper'
  3. describe FollowerAccountsController do
  4. render_views
  5. let(:alice) { Fabricate(:account, username: 'alice') }
  6. let(:follower_bob) { Fabricate(:account, username: 'bob') }
  7. let(:follower_chris) { Fabricate(:account, username: 'curt') }
  8. describe 'GET #index' do
  9. let!(:follow_from_bob) { follower_bob.follow!(alice) }
  10. let!(:follow_from_chris) { follower_chris.follow!(alice) }
  11. context 'when format is html' do
  12. subject(:response) { get :index, params: { account_username: alice.username, format: :html } }
  13. context 'when account is permanently suspended' do
  14. before do
  15. alice.suspend!
  16. alice.deletion_request.destroy
  17. end
  18. it 'returns http gone' do
  19. expect(response).to have_http_status(410)
  20. end
  21. end
  22. context 'when account is temporarily suspended' do
  23. before do
  24. alice.suspend!
  25. end
  26. it 'returns http forbidden' do
  27. expect(response).to have_http_status(403)
  28. end
  29. end
  30. end
  31. context 'when format is json' do
  32. subject(:body) { response.parsed_body }
  33. let(:response) { get :index, params: { account_username: alice.username, page: page, format: :json } }
  34. context 'with page' do
  35. let(:page) { 1 }
  36. it 'returns followers' do
  37. expect(response).to have_http_status(200)
  38. expect(body['totalItems']).to eq 2
  39. expect(body['partOf']).to be_present
  40. end
  41. context 'when account is permanently suspended' do
  42. before do
  43. alice.suspend!
  44. alice.deletion_request.destroy
  45. end
  46. it 'returns http gone' do
  47. expect(response).to have_http_status(410)
  48. end
  49. end
  50. context 'when account is temporarily suspended' do
  51. before do
  52. alice.suspend!
  53. end
  54. it 'returns http forbidden' do
  55. expect(response).to have_http_status(403)
  56. end
  57. end
  58. end
  59. context 'without page' do
  60. let(:page) { nil }
  61. it 'returns followers' do
  62. expect(response).to have_http_status(200)
  63. expect(body['totalItems']).to eq 2
  64. expect(body['partOf']).to be_blank
  65. end
  66. context 'when account hides their network' do
  67. before do
  68. alice.update(hide_collections: true)
  69. end
  70. it 'returns followers count' do
  71. expect(body['totalItems']).to eq 2
  72. end
  73. it 'does not return items' do
  74. expect(body['items']).to be_blank
  75. expect(body['orderedItems']).to be_blank
  76. expect(body['first']).to be_blank
  77. expect(body['last']).to be_blank
  78. end
  79. end
  80. context 'when account is permanently suspended' do
  81. before do
  82. alice.suspend!
  83. alice.deletion_request.destroy
  84. end
  85. it 'returns http gone' do
  86. expect(response).to have_http_status(410)
  87. end
  88. end
  89. context 'when account is temporarily suspended' do
  90. before do
  91. alice.suspend!
  92. end
  93. it 'returns http forbidden' do
  94. expect(response).to have_http_status(403)
  95. end
  96. end
  97. end
  98. end
  99. end
  100. end