Add coverage for misc serializers (#32781)
This commit is contained in:
parent
41227aeb95
commit
870bb06994
13 changed files with 344 additions and 0 deletions
|
@ -0,0 +1,35 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe REST::ExtendedDescriptionSerializer do
|
||||
subject { serialized_record_json(record, described_class) }
|
||||
|
||||
describe 'serialization' do
|
||||
context 'with text present' do
|
||||
let(:record) { ExtendedDescription.new text: 'Hello world', updated_at: Date.new(2024, 1, 1) }
|
||||
|
||||
it 'returns expected values' do
|
||||
expect(subject)
|
||||
.to include(
|
||||
'content' => eq(<<~HTML),
|
||||
<p>Hello world</p>
|
||||
HTML
|
||||
'updated_at' => eq('2024-01-01')
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
context 'with text missing' do
|
||||
let(:record) { ExtendedDescription.new text: nil, updated_at: Date.new(2024, 1, 1) }
|
||||
|
||||
it 'returns expected values' do
|
||||
expect(subject)
|
||||
.to include(
|
||||
'content' => eq(''),
|
||||
'updated_at' => eq('2024-01-01')
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue