mirror of
https://github.com/mastodon/mastodon.git
synced 2024-12-13 22:12:35 +00:00
42 lines
1,002 B
Ruby
42 lines
1,002 B
Ruby
|
# frozen_string_literal: true
|
||
|
|
||
|
require 'rails_helper'
|
||
|
|
||
|
RSpec.describe REST::PreviewCardSerializer do
|
||
|
subject do
|
||
|
serialized_record_json(
|
||
|
preview_card,
|
||
|
described_class
|
||
|
)
|
||
|
end
|
||
|
|
||
|
context 'when preview card does not have author data' do
|
||
|
let(:preview_card) { Fabricate.build :preview_card }
|
||
|
|
||
|
it 'includes empty authors array' do
|
||
|
expect(subject.deep_symbolize_keys)
|
||
|
.to include(
|
||
|
authors: be_an(Array).and(be_empty)
|
||
|
)
|
||
|
end
|
||
|
end
|
||
|
|
||
|
context 'when preview card has author data' do
|
||
|
let(:preview_card) { Fabricate.build :preview_card, author_name: 'Name', author_url: 'https://host.example/123' }
|
||
|
|
||
|
it 'includes populated authors array' do
|
||
|
expect(subject.deep_symbolize_keys)
|
||
|
.to include(
|
||
|
authors: be_an(Array).and(
|
||
|
contain_exactly(
|
||
|
include(
|
||
|
name: 'Name',
|
||
|
url: 'https://host.example/123'
|
||
|
)
|
||
|
)
|
||
|
)
|
||
|
)
|
||
|
end
|
||
|
end
|
||
|
end
|