gitlab-org--gitlab-foss/spec/serializers/merge_request_serializer_spec.rb
Bob Van Landuyt c27c65f97a Fall back to the MergeRequestWidgetEntity
When no serializer was passed.
2017-12-21 15:35:54 +01:00

43 lines
1.1 KiB
Ruby

require 'spec_helper'
describe MergeRequestSerializer do
let(:user) { create(:user) }
let(:resource) { create(:merge_request) }
let(:json_entity) do
described_class.new(current_user: user)
.represent(resource, serializer: serializer)
.with_indifferent_access
end
context 'widget merge request serialization' do
let(:serializer) { 'widget' }
it 'matches issue json schema' do
expect(json_entity).to match_schema('entities/merge_request_widget')
end
end
context 'sidebar merge request serialization' do
let(:serializer) { 'sidebar' }
it 'matches basic merge request json schema' do
expect(json_entity).to match_schema('entities/merge_request_basic')
end
end
context 'basic merge request serialization' do
let(:serializer) { 'basic' }
it 'matches basic merge request json schema' do
expect(json_entity).to match_schema('entities/merge_request_basic')
end
end
context 'no serializer' do
let(:serializer) { nil }
it 'falls back to the widget entity' do
expect(json_entity).to match_schema('entities/merge_request_widget')
end
end
end