Add API datetime/format matcher for serialization specs, reduce factories (#33325)
This commit is contained in:
parent
978142ac9e
commit
ce5c33c65d
26 changed files with 127 additions and 96 deletions
|
@ -10,24 +10,15 @@ RSpec.describe REST::ReportSerializer do
|
|||
)
|
||||
end
|
||||
|
||||
let(:status) { Fabricate(:status) }
|
||||
let(:report) { Fabricate(:report, status_ids: [status.id]) }
|
||||
|
||||
context 'with created_at' do
|
||||
it 'is serialized as RFC 3339 datetime' do
|
||||
expect { DateTime.rfc3339(subject['created_at']) }.to_not raise_error
|
||||
end
|
||||
end
|
||||
|
||||
context 'with action_taken_at' do
|
||||
let(:acting_account) { Fabricate(:account) }
|
||||
|
||||
before do
|
||||
report.resolve!(acting_account)
|
||||
end
|
||||
context 'with timestamps' do
|
||||
let(:report) { Fabricate(:report, action_taken_at: 3.days.ago) }
|
||||
|
||||
it 'is serialized as RFC 3339 datetime' do
|
||||
expect { DateTime.rfc3339(subject['action_taken_at']) }.to_not raise_error
|
||||
expect(subject)
|
||||
.to include(
|
||||
'created_at' => match_api_datetime_format,
|
||||
'action_taken_at' => match_api_datetime_format
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue