2024-11-07 15:37:26 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'rails_helper'
|
|
|
|
|
|
|
|
RSpec.describe REST::ExtendedDescriptionSerializer do
|
|
|
|
subject { serialized_record_json(record, described_class) }
|
|
|
|
|
2024-12-14 15:50:41 +00:00
|
|
|
let(:default_datetime) { DateTime.new(2024, 11, 28, 16, 20, 0) }
|
|
|
|
|
2024-11-07 15:37:26 +00:00
|
|
|
describe 'serialization' do
|
|
|
|
context 'with text present' do
|
2024-12-14 15:50:41 +00:00
|
|
|
let(:record) { ExtendedDescription.new text: 'Hello world', updated_at: default_datetime }
|
2024-11-07 15:37:26 +00:00
|
|
|
|
|
|
|
it 'returns expected values' do
|
|
|
|
expect(subject)
|
|
|
|
.to include(
|
|
|
|
'content' => eq(<<~HTML),
|
|
|
|
<p>Hello world</p>
|
|
|
|
HTML
|
2024-12-14 15:50:41 +00:00
|
|
|
'updated_at' => eq('2024-11-28T16:20:00+00:00')
|
2024-11-07 15:37:26 +00:00
|
|
|
)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'with text missing' do
|
2024-12-14 15:50:41 +00:00
|
|
|
let(:record) { ExtendedDescription.new text: nil, updated_at: default_datetime }
|
2024-11-07 15:37:26 +00:00
|
|
|
|
|
|
|
it 'returns expected values' do
|
|
|
|
expect(subject)
|
|
|
|
.to include(
|
|
|
|
'content' => eq(''),
|
2024-12-14 15:50:41 +00:00
|
|
|
'updated_at' => eq('2024-11-28T16:20:00+00:00')
|
2024-11-07 15:37:26 +00:00
|
|
|
)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|