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.

37 lines
1.5 KiB

  1. require 'rails_helper'
  2. RSpec.describe FollowRequest, type: :model do
  3. describe '#authorize!' do
  4. let(:follow_request) { Fabricate(:follow_request, account: account, target_account: target_account) }
  5. let(:account) { Fabricate(:account) }
  6. let(:target_account) { Fabricate(:account) }
  7. it 'calls Account#follow!, MergeWorker.perform_async, and #destroy!' do
  8. expect(account).to receive(:follow!).with(target_account, reblogs: true, uri: follow_request.uri)
  9. expect(MergeWorker).to receive(:perform_async).with(target_account.id, account.id)
  10. expect(follow_request).to receive(:destroy!)
  11. follow_request.authorize!
  12. end
  13. it 'generates a Follow' do
  14. follow_request = Fabricate.create(:follow_request)
  15. follow_request.authorize!
  16. target = follow_request.target_account
  17. expect(follow_request.account.following?(target)).to be true
  18. end
  19. it 'correctly passes show_reblogs when true' do
  20. follow_request = Fabricate.create(:follow_request, show_reblogs: true)
  21. follow_request.authorize!
  22. target = follow_request.target_account
  23. expect(follow_request.account.muting_reblogs?(target)).to be false
  24. end
  25. it 'correctly passes show_reblogs when false' do
  26. follow_request = Fabricate.create(:follow_request, show_reblogs: false)
  27. follow_request.authorize!
  28. target = follow_request.target_account
  29. expect(follow_request.account.muting_reblogs?(target)).to be true
  30. end
  31. end
  32. end