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)
|
||||
end
|
||||
|
||||
it "merges back into local followers' feeds" do
|
||||
it 'merges back into feeds of local followers and sends update' do
|
||||
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_list).with(account, list)
|
||||
end
|
||||
|
||||
it 'sends an update actor to followers and reporters' do
|
||||
subject
|
||||
def expect_updates_sent
|
||||
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
|
||||
end
|
||||
|
@ -73,19 +78,20 @@ RSpec.describe UnsuspendAccountService, type: :service do
|
|||
allow(resolve_account_service).to receive(:call).with(account).and_return(account)
|
||||
end
|
||||
|
||||
it 're-fetches the account' do
|
||||
subject
|
||||
it 're-fetches the account, merges feeds, and preserves suspended' do
|
||||
expect { subject }
|
||||
.to_not change_suspended_flag
|
||||
expect_feeds_merged
|
||||
expect(resolve_account_service).to have_received(:call).with(account)
|
||||
end
|
||||
|
||||
it "merges back into local followers' feeds" do
|
||||
subject
|
||||
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_list).with(account, list)
|
||||
end
|
||||
|
||||
it 'does not change the “suspended” flag' do
|
||||
expect { subject }.to_not change(account, :suspended?)
|
||||
def change_suspended_flag
|
||||
change(account, :suspended?)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -97,19 +103,20 @@ RSpec.describe UnsuspendAccountService, type: :service do
|
|||
end
|
||||
end
|
||||
|
||||
it 're-fetches the account' do
|
||||
subject
|
||||
it 're-fetches the account, does not merge feeds, marks suspended' do
|
||||
expect { subject }
|
||||
.to change_suspended_to_true
|
||||
expect(resolve_account_service).to have_received(:call).with(account)
|
||||
expect_feeds_not_merged
|
||||
end
|
||||
|
||||
it "does not merge back into local followers' feeds" do
|
||||
subject
|
||||
def expect_feeds_not_merged
|
||||
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)
|
||||
end
|
||||
|
||||
it 'marks account as suspended' do
|
||||
expect { subject }.to change(account, :suspended?).from(false).to(true)
|
||||
def change_suspended_to_true
|
||||
change(account, :suspended?).from(false).to(true)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -118,13 +125,14 @@ RSpec.describe UnsuspendAccountService, type: :service do
|
|||
allow(resolve_account_service).to receive(:call).with(account).and_return(nil)
|
||||
end
|
||||
|
||||
it 're-fetches the account' do
|
||||
it 're-fetches the account and does not merge feeds' do
|
||||
subject
|
||||
|
||||
expect(resolve_account_service).to have_received(:call).with(account)
|
||||
expect_feeds_not_merged
|
||||
end
|
||||
|
||||
it "does not merge back into local followers' feeds" do
|
||||
subject
|
||||
def expect_feeds_not_merged
|
||||
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)
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue