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

hierarchy_spec.rb « widgets « work_items « models « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 0141731529b496c355e803454ff7e0c57fffe11d (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 WorkItems::Widgets::Hierarchy do
  let_it_be(:work_item) { create(:work_item) }

  describe '.type' do
    subject { described_class.type }

    it { is_expected.to eq(:hierarchy) }
  end

  describe '#type' do
    subject { described_class.new(work_item).type }

    it { is_expected.to eq(:hierarchy) }
  end

  describe '#parent' do
    let_it_be(:parent_link) { create(:parent_link) }

    subject { described_class.new(parent_link.work_item).parent }

    it { is_expected.to eq parent_link.work_item_parent }

    context 'when work_items_hierarchy flag is disabled' do
      before do
        stub_feature_flags(work_items_hierarchy: false)
      end

      it { is_expected.to be_nil }
    end
  end

  describe '#children' do
    let_it_be(:parent_link1) { create(:parent_link, work_item_parent: work_item) }
    let_it_be(:parent_link2) { create(:parent_link, work_item_parent: work_item) }

    subject { described_class.new(work_item).children }

    it { is_expected.to match_array([parent_link1.work_item, parent_link2.work_item]) }

    context 'when work_items_hierarchy flag is disabled' do
      before do
        stub_feature_flags(work_items_hierarchy: false)
      end

      it { is_expected.to be_empty }
    end
  end
end