logo

mastofe

My custom branche(s) on git.pleroma.social/pleroma/mastofe git clone https://hacktivis.me/git/mastofe.git

follow_requests_controller_spec.rb (1359B)


  1. require 'rails_helper'
  2. RSpec.describe Api::V1::FollowRequestsController, type: :controller do
  3. render_views
  4. let(:user) { Fabricate(:user, account: Fabricate(:account, username: 'alice', locked: true)) }
  5. let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id, scopes: 'follow') }
  6. let(:follower) { Fabricate(:account, username: 'bob') }
  7. before do
  8. FollowService.new.call(follower, user.account.acct)
  9. allow(controller).to receive(:doorkeeper_token) { token }
  10. end
  11. describe 'GET #index' do
  12. before do
  13. get :index, params: { limit: 1 }
  14. end
  15. it 'returns http success' do
  16. expect(response).to have_http_status(:success)
  17. end
  18. end
  19. describe 'POST #authorize' do
  20. before do
  21. post :authorize, params: { id: follower.id }
  22. end
  23. it 'returns http success' do
  24. expect(response).to have_http_status(:success)
  25. end
  26. it 'allows follower to follow' do
  27. expect(follower.following?(user.account)).to be true
  28. end
  29. end
  30. describe 'POST #reject' do
  31. before do
  32. post :reject, params: { id: follower.id }
  33. end
  34. it 'returns http success' do
  35. expect(response).to have_http_status(:success)
  36. end
  37. it 'removes follow request' do
  38. expect(FollowRequest.where(target_account: user.account, account: follower).count).to eq 0
  39. end
  40. end
  41. end