merge_request_serializer_spec.rb 1.09 KB
Newer Older
1 2 3
require 'spec_helper'

describe MergeRequestSerializer do
4 5 6
  let(:user) { create(:user) }
  let(:resource) { create(:merge_request) }
  let(:json_entity) do
7
    described_class.new(current_user: user)
8 9
      .represent(resource, serializer: serializer)
      .with_indifferent_access
10 11
  end

12 13
  context 'widget merge request serialization' do
    let(:serializer) { 'widget' }
14

15 16 17 18
    it 'matches issue json schema' do
      expect(json_entity).to match_schema('entities/merge_request_widget')
    end
  end
19

20 21
  context 'sidebar merge request serialization' do
    let(:serializer) { 'sidebar' }
22

23 24
    it 'matches basic merge request json schema' do
      expect(json_entity).to match_schema('entities/merge_request_basic')
25
    end
26
  end
27

28 29 30 31 32 33 34
  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
35

36 37
  context 'no serializer' do
    let(:serializer) { nil }
38

39 40
    it 'raises an error' do
      expect { json_entity }.to raise_error(NoMethodError)
41 42 43
    end
  end
end