unfollow_follow_worker_spec.rb 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. # frozen_string_literal: true
  2. require 'rails_helper'
  3. RSpec.describe UnfollowFollowWorker do
  4. subject { described_class.new }
  5. let(:local_follower) { Fabricate(:account) }
  6. let(:source_account) { Fabricate(:account) }
  7. let(:target_account) { Fabricate(:account) }
  8. let(:show_reblogs) { true }
  9. before do
  10. local_follower.follow!(source_account, reblogs: show_reblogs)
  11. end
  12. context 'when show_reblogs is true' do
  13. let(:show_reblogs) { true }
  14. describe 'perform' do
  15. it 'unfollows source account and follows target account' do
  16. subject.perform(local_follower.id, source_account.id, target_account.id)
  17. expect(local_follower.following?(source_account)).to be false
  18. expect(local_follower.following?(target_account)).to be true
  19. end
  20. it 'preserves show_reblogs' do
  21. subject.perform(local_follower.id, source_account.id, target_account.id)
  22. expect(Follow.find_by(account: local_follower, target_account: target_account).show_reblogs?).to be show_reblogs
  23. end
  24. end
  25. end
  26. context 'when show_reblogs is false' do
  27. let(:show_reblogs) { false }
  28. describe 'perform' do
  29. it 'unfollows source account and follows target account' do
  30. subject.perform(local_follower.id, source_account.id, target_account.id)
  31. expect(local_follower.following?(source_account)).to be false
  32. expect(local_follower.following?(target_account)).to be true
  33. end
  34. it 'preserves show_reblogs' do
  35. subject.perform(local_follower.id, source_account.id, target_account.id)
  36. expect(Follow.find_by(account: local_follower, target_account: target_account).show_reblogs?).to be show_reblogs
  37. end
  38. end
  39. end
  40. end