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.

39 lines
1.5 KiB

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