BigW Consortium Gitlab

merge_request_serializer_spec.rb 1.01 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11
require 'spec_helper'

describe MergeRequestSerializer do
  let(:user) { build_stubbed(:user) }
  let(:merge_request) { build_stubbed(:merge_request) }

  let(:serializer) do
    described_class.new(current_user: user)
  end

  describe '#represent' do
12 13
    let(:opts) { { serializer: serializer_entity } }
    subject { serializer.represent(merge_request, serializer: serializer_entity) }
14

15 16
    context 'when passing basic serializer param' do
      let(:serializer_entity) { 'basic' }
17 18 19 20 21 22 23 24 25

      it 'calls super class #represent with correct params' do
        expect_any_instance_of(BaseSerializer).to receive(:represent)
          .with(merge_request, opts, MergeRequestBasicEntity)

        subject
      end
    end

26 27
    context 'when serializer param is falsy' do
      let(:serializer_entity) { nil }
28 29 30 31 32 33 34 35 36 37

      it 'calls super class #represent with correct params' do
        expect_any_instance_of(BaseSerializer).to receive(:represent)
          .with(merge_request, opts, MergeRequestEntity)

        subject
      end
    end
  end
end