debian-mirror-gitlab/spec/models/work_items/widgets/hierarchy_spec.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

72 lines
2 KiB
Ruby
Raw Normal View History

2022-07-23 23:45:48 +05:30
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe WorkItems::Widgets::Hierarchy do
2022-08-13 15:12:31 +05:30
let_it_be(:group) { create(:group) }
let_it_be(:project) { create(:project, group: group) }
let_it_be(:task) { create(:work_item, :task, project: project) }
let_it_be(:work_item_parent) { create(:work_item, project: project) }
2022-07-23 23:45:48 +05:30
describe '.type' do
subject { described_class.type }
it { is_expected.to eq(:hierarchy) }
end
describe '#type' do
2022-08-13 15:12:31 +05:30
subject { described_class.new(task).type }
2022-07-23 23:45:48 +05:30
it { is_expected.to eq(:hierarchy) }
end
describe '#parent' do
2022-08-27 11:52:29 +05:30
let_it_be(:parent_link) { create(:parent_link, work_item: task, work_item_parent: work_item_parent).reload }
2022-07-23 23:45:48 +05:30
subject { described_class.new(parent_link.work_item).parent }
2022-08-13 15:12:31 +05:30
it { is_expected.to eq(parent_link.work_item_parent) }
2022-07-23 23:45:48 +05:30
2022-08-13 15:12:31 +05:30
context 'when work_items flag is disabled' do
2022-07-23 23:45:48 +05:30
before do
2022-08-13 15:12:31 +05:30
stub_feature_flags(work_items: false)
2022-07-23 23:45:48 +05:30
end
it { is_expected.to be_nil }
end
2022-08-13 15:12:31 +05:30
context 'when work_items flag is enabled for the parent group' do
before do
stub_feature_flags(work_items: group)
end
it { is_expected.to eq(parent_link.work_item_parent) }
end
2022-07-23 23:45:48 +05:30
end
describe '#children' do
2022-08-27 11:52:29 +05:30
let_it_be(:parent_link1) { create(:parent_link, work_item_parent: work_item_parent, work_item: task).reload }
let_it_be(:parent_link2) { create(:parent_link, work_item_parent: work_item_parent).reload }
2022-07-23 23:45:48 +05:30
2022-08-13 15:12:31 +05:30
subject { described_class.new(work_item_parent).children }
2022-07-23 23:45:48 +05:30
2022-08-13 15:12:31 +05:30
it { is_expected.to contain_exactly(parent_link1.work_item, parent_link2.work_item) }
2022-07-23 23:45:48 +05:30
2022-08-13 15:12:31 +05:30
context 'when work_items flag is disabled' do
2022-07-23 23:45:48 +05:30
before do
2022-08-13 15:12:31 +05:30
stub_feature_flags(work_items: false)
2022-07-23 23:45:48 +05:30
end
it { is_expected.to be_empty }
end
2022-08-13 15:12:31 +05:30
context 'when work_items flag is enabled for the parent group' do
before do
stub_feature_flags(work_items: group)
end
it { is_expected.to contain_exactly(parent_link1.work_item, parent_link2.work_item) }
end
2022-07-23 23:45:48 +05:30
end
end