summaryrefslogtreecommitdiff
path: root/spec/models/work_items
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2023-02-03 15:07:39 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2023-02-03 15:07:39 +0000
commit3cda3d43aef1e92e2eedf7383122c6db9c61149f (patch)
tree1b4dd068a449d050afafa403de54a00a63e9bfc4 /spec/models/work_items
parent83916cf0a2f9254455a08a723961db34f0840df4 (diff)
downloadgitlab-ce-3cda3d43aef1e92e2eedf7383122c6db9c61149f.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/models/work_items')
-rw-r--r--spec/models/work_items/widgets/hierarchy_spec.rb30
1 files changed, 28 insertions, 2 deletions
diff --git a/spec/models/work_items/widgets/hierarchy_spec.rb b/spec/models/work_items/widgets/hierarchy_spec.rb
index 43670b30645..7ff3088d9ec 100644
--- a/spec/models/work_items/widgets/hierarchy_spec.rb
+++ b/spec/models/work_items/widgets/hierarchy_spec.rb
@@ -36,14 +36,40 @@ RSpec.describe WorkItems::Widgets::Hierarchy, feature_category: :team_planning d
it { is_expected.to contain_exactly(parent_link1.work_item, parent_link2.work_item) }
- context 'with default order by created_at' do
+ context 'when ordered by relative position and created_at' do
let_it_be(:oldest_child) { create(:work_item, :task, project: project, created_at: 5.minutes.ago) }
+ let_it_be(:newest_child) { create(:work_item, :task, project: project, created_at: 5.minutes.from_now) }
let_it_be_with_reload(:link_to_oldest_child) do
create(:parent_link, work_item_parent: work_item_parent, work_item: oldest_child)
end
- it { is_expected.to eq([link_to_oldest_child, parent_link1, parent_link2].map(&:work_item)) }
+ let_it_be_with_reload(:link_to_newest_child) do
+ create(:parent_link, work_item_parent: work_item_parent, work_item: newest_child)
+ end
+
+ let(:parent_links_ordered) { [link_to_oldest_child, parent_link1, parent_link2, link_to_newest_child] }
+
+ context 'when children relative positions are nil' do
+ it 'orders by created_at' do
+ is_expected.to eq(parent_links_ordered.map(&:work_item))
+ end
+ end
+
+ context 'when children relative positions are present' do
+ let(:first_position) { 10 }
+ let(:second_position) { 20 }
+ let(:parent_links_ordered) { [link_to_oldest_child, link_to_newest_child, parent_link1, parent_link2] }
+
+ before do
+ link_to_oldest_child.update!(relative_position: first_position)
+ link_to_newest_child.update!(relative_position: second_position)
+ end
+
+ it 'orders by relative_position and by created_at' do
+ is_expected.to eq(parent_links_ordered.map(&:work_item))
+ end
+ end
end
end
end