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/widgets/hierarchy_spec.rb')
-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