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

main-rebase-security-fix
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!(:future) { Time.now.utc + 2.hours }
let!(:previous_status) { Fabricate(:status, account: account) } let!(:previous_status) { Fabricate(:status, account: account) }
it 'schedules a status' do it 'schedules a status for future creation and does not create one immediately' 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
media = Fabricate(:media_attachment, account: account) media = Fabricate(:media_attachment, account: account)
status = subject.call(account, text: 'Hi future!', media_ids: [media.id], scheduled_at: future) status = subject.call(account, text: 'Hi future!', media_ids: [media.id], scheduled_at: future)
expect(status).to be_a ScheduledStatus expect(status)
expect(status.scheduled_at).to eq future .to be_a(ScheduledStatus)
expect(status.params['text']).to eq 'Hi future!' .and have_attributes(
expect(status.params['media_ids']).to eq [media.id] scheduled_at: eq(future),
params: include(
'text' => eq('Hi future!'),
'media_ids' => contain_exactly(media.id)
)
)
expect(media.reload.status).to be_nil expect(media.reload.status).to be_nil
expect(Status.where(text: 'Hi future!')).to_not exist expect(Status.where(text: 'Hi future!')).to_not exist
end end
it 'does not change statuses count' do 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, previous_status.replies_count] }) 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
end end