Reduce RSpec/MultipleExpectations
in post_status_service spec (#29225)
This commit is contained in:
parent
1c93d625c6
commit
4b7f04e3ea
1 changed files with 14 additions and 14 deletions
|
@ -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
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue