summaryrefslogtreecommitdiff
path: root/spec/lib/gitlab/import_export/group_object_builder_spec.rb
blob: 7950a9376085bb2ba3b674a21983c438b6d8a79a (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
# frozen_string_literal: true

require 'spec_helper'

describe Gitlab::ImportExport::GroupObjectBuilder 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
  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