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

object_builder_spec.rb « group « import_export « gitlab « lib « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 25d9858dd4cbcb02f4db041733736b562fd2b320 (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
53
54
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe Gitlab::ImportExport::Group::ObjectBuilder do
  let(:group) { create(:group) }
  let(:base_attributes) do
    {
      'title' => 'title',
      'description' => 'description',
      'group' => group
    }
  end

  context 'labels' do
    let(:label_attributes) { base_attributes.merge('type' => 'GroupLabel') }

    it 'finds the existing group label' do
      group_label = create(:group_label, base_attributes)

      expect(described_class.build(Label, label_attributes)).to eq(group_label)
    end

    it 'creates a new label' do
      label = described_class.build(Label, label_attributes)

      expect(label.persisted?).to be true
    end

    context 'when description is an empty string' do
      let(:label_attributes) { base_attributes.merge('type' => 'GroupLabel', 'description' => '') }

      it 'finds the existing group label' do
        group_label = create(:group_label, label_attributes)

        expect(described_class.build(Label, label_attributes)).to eq(group_label)
      end
    end
  end

  context 'milestones' do
    it 'finds the existing group milestone' do
      milestone = create(:milestone, base_attributes)

      expect(described_class.build(Milestone, base_attributes)).to eq(milestone)
    end

    it 'creates a new milestone' do
      milestone = described_class.build(Milestone, base_attributes)

      expect(milestone.persisted?).to be true
    end
  end
end