1
0

follower_accounts_controller_spec.rb 3.2 KB

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