summaryrefslogtreecommitdiff
path: root/spec/serializers/deployment_serializer_spec.rb
blob: 67fccaa3f25142355e3906585f6bec72da052633 (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
# frozen_string_literal: true

require 'spec_helper'

describe DeploymentSerializer do
  let_it_be(:project) { create(:project, :repository) }
  let_it_be(:user) { create(:user, email: project.commit.author_email) }
  let(:resource) { create(:deployment, project: project, sha: project.commit.id) }
  let(:serializer) { described_class.new(request) }

  shared_examples 'json schema' do
    let(:json_entity) { subject.as_json }

    it 'matches deployment entity schema' do
      expect(json_entity).to match_schema('deployment')
    end
  end

  describe '#represent' do
    subject { serializer.represent(resource) }

    let(:request) { { project: project, current_user: user } }

    it_behaves_like 'json schema'
  end

  describe '#represent_concise' do
    subject { serializer.represent_concise(resource) }

    let(:request) { { project: project } }

    it_behaves_like 'json schema'
  end
end