Remove double subject call in `services/unsuspend_account_service` spec (#28215)
This commit is contained in:
		
							parent
							
								
									3b710b96cf
								
							
						
					
					
						commit
						faffd81976
					
				|  | @ -45,14 +45,19 @@ RSpec.describe UnsuspendAccountService, type: :service do | ||||||
|         remote_follower.follow!(account) |         remote_follower.follow!(account) | ||||||
|       end |       end | ||||||
| 
 | 
 | ||||||
|       it "merges back into local followers' feeds" do |       it 'merges back into feeds of local followers and sends update' do | ||||||
|         subject |         subject | ||||||
|  | 
 | ||||||
|  |         expect_feeds_merged | ||||||
|  |         expect_updates_sent | ||||||
|  |       end | ||||||
|  | 
 | ||||||
|  |       def expect_feeds_merged | ||||||
|         expect(FeedManager.instance).to have_received(:merge_into_home).with(account, local_follower) |         expect(FeedManager.instance).to have_received(:merge_into_home).with(account, local_follower) | ||||||
|         expect(FeedManager.instance).to have_received(:merge_into_list).with(account, list) |         expect(FeedManager.instance).to have_received(:merge_into_list).with(account, list) | ||||||
|       end |       end | ||||||
| 
 | 
 | ||||||
|       it 'sends an update actor to followers and reporters' do |       def expect_updates_sent | ||||||
|         subject |  | ||||||
|         expect(a_request(:post, remote_follower.inbox_url).with { |req| match_update_actor_request(req, account) }).to have_been_made.once |         expect(a_request(:post, remote_follower.inbox_url).with { |req| match_update_actor_request(req, account) }).to have_been_made.once | ||||||
|         expect(a_request(:post, remote_reporter.inbox_url).with { |req| match_update_actor_request(req, account) }).to have_been_made.once |         expect(a_request(:post, remote_reporter.inbox_url).with { |req| match_update_actor_request(req, account) }).to have_been_made.once | ||||||
|       end |       end | ||||||
|  | @ -73,19 +78,20 @@ RSpec.describe UnsuspendAccountService, type: :service do | ||||||
|           allow(resolve_account_service).to receive(:call).with(account).and_return(account) |           allow(resolve_account_service).to receive(:call).with(account).and_return(account) | ||||||
|         end |         end | ||||||
| 
 | 
 | ||||||
|         it 're-fetches the account' do |         it 're-fetches the account, merges feeds, and preserves suspended' do | ||||||
|           subject |           expect { subject } | ||||||
|  |             .to_not change_suspended_flag | ||||||
|  |           expect_feeds_merged | ||||||
|           expect(resolve_account_service).to have_received(:call).with(account) |           expect(resolve_account_service).to have_received(:call).with(account) | ||||||
|         end |         end | ||||||
| 
 | 
 | ||||||
|         it "merges back into local followers' feeds" do |         def expect_feeds_merged | ||||||
|           subject |  | ||||||
|           expect(FeedManager.instance).to have_received(:merge_into_home).with(account, local_follower) |           expect(FeedManager.instance).to have_received(:merge_into_home).with(account, local_follower) | ||||||
|           expect(FeedManager.instance).to have_received(:merge_into_list).with(account, list) |           expect(FeedManager.instance).to have_received(:merge_into_list).with(account, list) | ||||||
|         end |         end | ||||||
| 
 | 
 | ||||||
|         it 'does not change the “suspended” flag' do |         def change_suspended_flag | ||||||
|           expect { subject }.to_not change(account, :suspended?) |           change(account, :suspended?) | ||||||
|         end |         end | ||||||
|       end |       end | ||||||
| 
 | 
 | ||||||
|  | @ -97,19 +103,20 @@ RSpec.describe UnsuspendAccountService, type: :service do | ||||||
|           end |           end | ||||||
|         end |         end | ||||||
| 
 | 
 | ||||||
|         it 're-fetches the account' do |         it 're-fetches the account, does not merge feeds, marks suspended' do | ||||||
|           subject |           expect { subject } | ||||||
|  |             .to change_suspended_to_true | ||||||
|           expect(resolve_account_service).to have_received(:call).with(account) |           expect(resolve_account_service).to have_received(:call).with(account) | ||||||
|  |           expect_feeds_not_merged | ||||||
|         end |         end | ||||||
| 
 | 
 | ||||||
|         it "does not merge back into local followers' feeds" do |         def expect_feeds_not_merged | ||||||
|           subject |  | ||||||
|           expect(FeedManager.instance).to_not have_received(:merge_into_home).with(account, local_follower) |           expect(FeedManager.instance).to_not have_received(:merge_into_home).with(account, local_follower) | ||||||
|           expect(FeedManager.instance).to_not have_received(:merge_into_list).with(account, list) |           expect(FeedManager.instance).to_not have_received(:merge_into_list).with(account, list) | ||||||
|         end |         end | ||||||
| 
 | 
 | ||||||
|         it 'marks account as suspended' do |         def change_suspended_to_true | ||||||
|           expect { subject }.to change(account, :suspended?).from(false).to(true) |           change(account, :suspended?).from(false).to(true) | ||||||
|         end |         end | ||||||
|       end |       end | ||||||
| 
 | 
 | ||||||
|  | @ -118,13 +125,14 @@ RSpec.describe UnsuspendAccountService, type: :service do | ||||||
|           allow(resolve_account_service).to receive(:call).with(account).and_return(nil) |           allow(resolve_account_service).to receive(:call).with(account).and_return(nil) | ||||||
|         end |         end | ||||||
| 
 | 
 | ||||||
|         it 're-fetches the account' do |         it 're-fetches the account and does not merge feeds' do | ||||||
|           subject |           subject | ||||||
|  | 
 | ||||||
|           expect(resolve_account_service).to have_received(:call).with(account) |           expect(resolve_account_service).to have_received(:call).with(account) | ||||||
|  |           expect_feeds_not_merged | ||||||
|         end |         end | ||||||
| 
 | 
 | ||||||
|         it "does not merge back into local followers' feeds" do |         def expect_feeds_not_merged | ||||||
|           subject |  | ||||||
|           expect(FeedManager.instance).to_not have_received(:merge_into_home).with(account, local_follower) |           expect(FeedManager.instance).to_not have_received(:merge_into_home).with(account, local_follower) | ||||||
|           expect(FeedManager.instance).to_not have_received(:merge_into_list).with(account, list) |           expect(FeedManager.instance).to_not have_received(:merge_into_list).with(account, list) | ||||||
|         end |         end | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue