gitlab-org--gitlab-foss/spec/serializers/merge_request_serializer_spec.rb

63 lines
1.7 KiB
Ruby
Raw Normal View History

# frozen_string_literal: true
2017-05-09 00:15:34 -04:00
require 'spec_helper'
describe MergeRequestSerializer do
set(:user) { create(:user) }
set(:resource) { create(:merge_request, description: "Description") }
let(:json_entity) do
2017-05-09 00:15:34 -04:00
described_class.new(current_user: user)
.represent(resource, serializer: serializer)
.with_indifferent_access
2017-05-09 00:15:34 -04:00
end
context 'widget merge request serialization' do
let(:serializer) { 'widget' }
2017-05-09 00:15:34 -04:00
it 'matches issue json schema' do
expect(json_entity).to match_schema('entities/merge_request_widget')
end
end
2017-05-09 00:15:34 -04:00
context 'sidebar merge request serialization' do
2018-11-29 22:16:40 -05:00
let(:serializer) { 'sidebar' }
2017-05-09 00:15:34 -04:00
2018-11-29 22:16:40 -05:00
it 'matches merge_request_sidebar json schema' do
expect(json_entity).to match_schema('entities/merge_request_sidebar')
2017-05-09 00:15:34 -04:00
end
end
2017-05-09 00:15:34 -04:00
2018-11-29 22:16:40 -05:00
context 'sidebar_extras merge request serialization' do
let(:serializer) { 'sidebar_extras' }
it 'matches merge_request_sidebar_extras json schema' do
expect(json_entity).to match_schema('entities/merge_request_sidebar_extras')
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
2017-05-09 00:15:34 -04:00
context 'noteable merge request serialization' do
let(:serializer) { 'noteable' }
it 'matches noteable merge request json schema' do
expect(json_entity).to match_schema('entities/merge_request_noteable', strict: true)
end
end
context 'no serializer' do
let(:serializer) { nil }
2017-05-09 00:15:34 -04:00
it 'falls back to the widget entity' do
expect(json_entity).to match_schema('entities/merge_request_widget')
2017-05-09 00:15:34 -04:00
end
end
end