Welcome to mirror list, hosted at ThFree Co, Russian Federation.

build_entity_spec.rb « serializers « jira_connect « atlassian « lib « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 52e475d20cae00ac4cdb7535fca88e617e3a1c66 (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
44
45
46
47
48
49
50
51
52
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe Atlassian::JiraConnect::Serializers::BuildEntity do
  let_it_be(:user) { create_default(:user) }
  let_it_be(:project) { create_default(:project) }

  subject { described_class.represent(pipeline) }

  context 'when the pipeline does not belong to any Jira issue' do
    let_it_be(:pipeline) { create(:ci_pipeline) }

    describe '#issue_keys' do
      it 'is empty' do
        expect(subject.issue_keys).to be_empty
      end
    end

    describe '#to_json' do
      it 'can encode the object' do
        expect(subject.to_json).to be_valid_json
      end

      it 'is invalid, since it has no issue keys' do
        expect(subject.to_json).not_to be_valid_json.according_to_schema(Atlassian::Schemata.build_info)
      end
    end
  end

  context 'when the pipeline does belong to a Jira issue' do
    let(:pipeline) { create(:ci_pipeline, merge_request: merge_request) }

    %i[jira_branch jira_title].each do |trait|
      context "because it belongs to an MR with a #{trait}" do
        let(:merge_request) { create(:merge_request, trait) }

        describe '#issue_keys' do
          it 'is not empty' do
            expect(subject.issue_keys).not_to be_empty
          end
        end

        describe '#to_json' do
          it 'is valid according to the build info schema' do
            expect(subject.to_json).to be_valid_json.according_to_schema(Atlassian::Schemata.build_info)
          end
        end
      end
    end
  end
end