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

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'spec/models/work_items/parent_link_spec.rb')
-rw-r--r--spec/models/work_items/parent_link_spec.rb18
1 files changed, 13 insertions, 5 deletions
diff --git a/spec/models/work_items/parent_link_spec.rb b/spec/models/work_items/parent_link_spec.rb
index 9516baa7340..a16b15bbfc9 100644
--- a/spec/models/work_items/parent_link_spec.rb
+++ b/spec/models/work_items/parent_link_spec.rb
@@ -9,38 +9,46 @@ RSpec.describe WorkItems::ParentLink do
end
describe 'validations' do
+ subject { build(:parent_link) }
+
it { is_expected.to validate_presence_of(:work_item) }
it { is_expected.to validate_presence_of(:work_item_parent) }
+ it { is_expected.to validate_uniqueness_of(:work_item) }
describe 'hierarchy' do
let_it_be(:project) { create(:project) }
let_it_be(:issue) { build(:work_item, project: project) }
+ let_it_be(:incident) { build(:work_item, :incident, project: project) }
let_it_be(:task1) { build(:work_item, :task, project: project) }
let_it_be(:task2) { build(:work_item, :task, project: project) }
- it 'is valid if not-task parent has task child' do
+ it 'is valid if issue parent has task child' do
expect(build(:parent_link, work_item: task1, work_item_parent: issue)).to be_valid
end
+ it 'is valid if incident parent has task child' do
+ expect(build(:parent_link, work_item: task1, work_item_parent: incident)).to be_valid
+ end
+
it 'is not valid if child is not task' do
link = build(:parent_link, work_item: issue)
expect(link).not_to be_valid
- expect(link.errors[:work_item]).to include('Only Task can be assigned as a child in hierarchy.')
+ expect(link.errors[:work_item]).to include('only Task can be assigned as a child in hierarchy.')
end
it 'is not valid if parent is task' do
link = build(:parent_link, work_item_parent: task1)
expect(link).not_to be_valid
- expect(link.errors[:work_item_parent]).to include('Only Issue can be parent of Task.')
+ expect(link.errors[:work_item_parent]).to include('only Issue and Incident can be parent of Task.')
end
it 'is not valid if parent is in other project' do
link = build(:parent_link, work_item_parent: task1, work_item: build(:work_item))
expect(link).not_to be_valid
- expect(link.errors[:work_item_parent]).to include('Parent must be in the same project as child.')
+ expect(link.errors[:work_item_parent]).to include('parent must be in the same project as child.')
end
context 'when parent already has maximum number of links' do
@@ -54,7 +62,7 @@ RSpec.describe WorkItems::ParentLink do
link2 = build(:parent_link, work_item_parent: issue, work_item: task2)
expect(link2).not_to be_valid
- expect(link2.errors[:work_item_parent]).to include('Parent already has maximum number of children.')
+ expect(link2.errors[:work_item_parent]).to include('parent already has maximum number of children.')
end
it 'existing link is still valid' do