blob: 2c91e620dcd57164dd4408d9cfe9e37b807f73c4 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
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_extras' }
it 'matches sidebar merge request json schema' do
expect(json_entity).to match_schema('entities/merge_request_sidebar')
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
|