Reduce `RSpec/MultipleExpectations` in post_status_service spec (#29225)

pull/29241/head
Matt Jankowski 2024-02-16 02:52:29 -05:00 committed by GitHub
parent 1c93d625c6
commit 4b7f04e3ea
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 14 additions and 14 deletions

View File

@ -32,27 +32,27 @@ RSpec.describe PostStatusService, type: :service do
let!(:future) { Time.now.utc + 2.hours }
let!(:previous_status) { Fabricate(:status, account: account) }
it 'schedules a status' do
status = subject.call(account, text: 'Hi future!', scheduled_at: future)
expect(status).to be_a ScheduledStatus
expect(status.scheduled_at).to eq future
expect(status.params['text']).to eq 'Hi future!'
end
it 'does not immediately create a status' do
it 'schedules a status for future creation and does not create one immediately' do
media = Fabricate(:media_attachment, account: account)
status = subject.call(account, text: 'Hi future!', media_ids: [media.id], scheduled_at: future)
expect(status).to be_a ScheduledStatus
expect(status.scheduled_at).to eq future
expect(status.params['text']).to eq 'Hi future!'
expect(status.params['media_ids']).to eq [media.id]
expect(status)
.to be_a(ScheduledStatus)
.and have_attributes(
scheduled_at: eq(future),
params: include(
'text' => eq('Hi future!'),
'media_ids' => contain_exactly(media.id)
)
)
expect(media.reload.status).to be_nil
expect(Status.where(text: 'Hi future!')).to_not exist
end
it 'does not change statuses count' do
expect { subject.call(account, text: 'Hi future!', scheduled_at: future, thread: previous_status) }.to_not(change { [account.statuses_count, previous_status.replies_count] })
it 'does not change statuses_count of account or replies_count of thread previous status' do
expect { subject.call(account, text: 'Hi future!', scheduled_at: future, thread: previous_status) }
.to not_change { account.statuses_count }
.and(not_change { previous_status.replies_count })
end
end