|
| 1 | +# frozen_string_literal: true |
| 2 | + |
| 3 | +require 'rails_helper' |
| 4 | + |
| 5 | +describe UnfollowFollowWorker do |
| 6 | + let(:local_follower) { Fabricate(:user, email: 'bob@example.com', account: Fabricate(:account, username: 'bob')).account } |
| 7 | + let(:source_account) { Fabricate(:account) } |
| 8 | + let(:target_account) { Fabricate(:account) } |
| 9 | + let(:show_reblogs) { true } |
| 10 | + |
| 11 | + subject { described_class.new } |
| 12 | + |
| 13 | + before do |
| 14 | + local_follower.follow!(source_account, reblogs: show_reblogs) |
| 15 | + end |
| 16 | + |
| 17 | + context 'when show_reblogs is true' do |
| 18 | + let(:show_reblogs) { true } |
| 19 | + |
| 20 | + describe 'perform' do |
| 21 | + it 'unfollows source account and follows target account' do |
| 22 | + subject.perform(local_follower.id, source_account.id, target_account.id) |
| 23 | + expect(local_follower.following?(source_account)).to be false |
| 24 | + expect(local_follower.following?(target_account)).to be true |
| 25 | + end |
| 26 | + |
| 27 | + it 'preserves show_reblogs' do |
| 28 | + subject.perform(local_follower.id, source_account.id, target_account.id) |
| 29 | + expect(Follow.find_by(account: local_follower, target_account: target_account).show_reblogs?).to be show_reblogs |
| 30 | + end |
| 31 | + end |
| 32 | + end |
| 33 | + |
| 34 | + context 'when show_reblogs is false' do |
| 35 | + let(:show_reblogs) { false } |
| 36 | + |
| 37 | + describe 'perform' do |
| 38 | + it 'unfollows source account and follows target account' do |
| 39 | + subject.perform(local_follower.id, source_account.id, target_account.id) |
| 40 | + expect(local_follower.following?(source_account)).to be false |
| 41 | + expect(local_follower.following?(target_account)).to be true |
| 42 | + end |
| 43 | + |
| 44 | + it 'preserves show_reblogs' do |
| 45 | + subject.perform(local_follower.id, source_account.id, target_account.id) |
| 46 | + expect(Follow.find_by(account: local_follower, target_account: target_account).show_reblogs?).to be show_reblogs |
| 47 | + end |
| 48 | + end |
| 49 | + end |
| 50 | +end |
0 commit comments