闭社主体 forked from https://github.com/tootsuite/mastodon
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

52 lines
1.3 KiB

  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) { double acceptable?: true, resource_owner_id: user.id }
  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
  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