2017-05-09 00:15:34 -04:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe MergeRequestSerializer do
|
2017-12-07 16:56:59 -05:00
|
|
|
let(:user) { create(:user) }
|
|
|
|
let(:resource) { create(:merge_request) }
|
|
|
|
let(:json_entity) do
|
2017-05-09 00:15:34 -04:00
|
|
|
described_class.new(current_user: user)
|
2017-12-07 16:56:59 -05:00
|
|
|
.represent(resource, serializer: serializer)
|
|
|
|
.with_indifferent_access
|
2017-05-09 00:15:34 -04:00
|
|
|
end
|
|
|
|
|
2017-12-07 16:56:59 -05:00
|
|
|
context 'widget merge request serialization' do
|
|
|
|
let(:serializer) { 'widget' }
|
2017-05-09 00:15:34 -04:00
|
|
|
|
2017-12-07 16:56:59 -05: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
|
|
|
|
2017-12-07 16:56:59 -05:00
|
|
|
context 'sidebar merge request serialization' do
|
|
|
|
let(:serializer) { 'sidebar' }
|
2017-05-09 00:15:34 -04:00
|
|
|
|
2017-12-07 16:56:59 -05:00
|
|
|
it 'matches basic merge request json schema' do
|
|
|
|
expect(json_entity).to match_schema('entities/merge_request_basic')
|
2017-05-09 00:15:34 -04:00
|
|
|
end
|
2017-12-07 16:56:59 -05:00
|
|
|
end
|
2017-05-09 00:15:34 -04:00
|
|
|
|
2017-12-07 16:56:59 -05:00
|
|
|
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
|
|
|
|
2017-12-07 16:56:59 -05:00
|
|
|
context 'no serializer' do
|
|
|
|
let(:serializer) { nil }
|
2017-05-09 00:15:34 -04:00
|
|
|
|
2017-12-21 08:03:15 -05: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
|