diff options
Diffstat (limited to 'spec/models')
| -rw-r--r-- | spec/models/bulk_imports/entity_spec.rb | 20 | ||||
| -rw-r--r-- | spec/models/pages_domain_spec.rb | 2 | ||||
| -rw-r--r-- | spec/models/work_item_spec.rb | 7 | ||||
| -rw-r--r-- | spec/models/work_items/widgets/hierarchy_spec.rb | 20 |
4 files changed, 43 insertions, 6 deletions
diff --git a/spec/models/bulk_imports/entity_spec.rb b/spec/models/bulk_imports/entity_spec.rb index f4f2b174a7b..b1c65c6b9ee 100644 --- a/spec/models/bulk_imports/entity_spec.rb +++ b/spec/models/bulk_imports/entity_spec.rb @@ -325,4 +325,24 @@ RSpec.describe BulkImports::Entity, type: :model do expect(project_entity.update_service).to eq(::Projects::UpdateService) end end + + describe '#full_path' do + it 'returns group full path for project entity' do + group_entity = build(:bulk_import_entity, :group_entity, group: build(:group)) + + expect(group_entity.full_path).to eq(group_entity.group.full_path) + end + + it 'returns project full path for project entity' do + project_entity = build(:bulk_import_entity, :project_entity, project: build(:project)) + + expect(project_entity.full_path).to eq(project_entity.project.full_path) + end + + it 'returns nil when not associated with group or project' do + entity = build(:bulk_import_entity, group: nil, project: nil) + + expect(entity.full_path).to eq(nil) + end + end end diff --git a/spec/models/pages_domain_spec.rb b/spec/models/pages_domain_spec.rb index e5f2e849a0a..f054fde78e7 100644 --- a/spec/models/pages_domain_spec.rb +++ b/spec/models/pages_domain_spec.rb @@ -567,7 +567,7 @@ RSpec.describe PagesDomain do it 'returns the virual domain when there are pages deployed for the project' do expect(virtual_domain).to be_an_instance_of(Pages::VirtualDomain) expect(virtual_domain.lookup_paths).not_to be_empty - expect(virtual_domain.cache_key).to match(/pages_domain_for_project_#{project.id}_/) + expect(virtual_domain.cache_key).to match(/pages_domain_for_domain_#{pages_domain.id}_/) end context 'when :cache_pages_domain_api is disabled' do diff --git a/spec/models/work_item_spec.rb b/spec/models/work_item_spec.rb index 1c34936c5c2..0bedcc9791f 100644 --- a/spec/models/work_item_spec.rb +++ b/spec/models/work_item_spec.rb @@ -21,6 +21,13 @@ RSpec.describe WorkItem, feature_category: :portfolio_management do .with_foreign_key('work_item_id') end + it 'has many `work_item_children_by_created_at`' do + is_expected.to have_many(:work_item_children_by_created_at) + .order(created_at: :asc) + .class_name('WorkItem') + .with_foreign_key('work_item_id') + end + it 'has many `child_links`' do is_expected.to have_many(:child_links) .class_name('::WorkItems::ParentLink') diff --git a/spec/models/work_items/widgets/hierarchy_spec.rb b/spec/models/work_items/widgets/hierarchy_spec.rb index c847f2694fe..43670b30645 100644 --- a/spec/models/work_items/widgets/hierarchy_spec.rb +++ b/spec/models/work_items/widgets/hierarchy_spec.rb @@ -2,11 +2,11 @@ require 'spec_helper' -RSpec.describe WorkItems::Widgets::Hierarchy do +RSpec.describe WorkItems::Widgets::Hierarchy, feature_category: :team_planning do 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) } + let_it_be_with_reload(:work_item_parent) { create(:work_item, project: project) } describe '.type' do subject { described_class.type } @@ -21,7 +21,7 @@ RSpec.describe WorkItems::Widgets::Hierarchy do end describe '#parent' do - let_it_be(:parent_link) { create(:parent_link, work_item: task, work_item_parent: work_item_parent).reload } + let_it_be_with_reload(:parent_link) { create(:parent_link, work_item: task, work_item_parent: work_item_parent) } subject { described_class.new(parent_link.work_item).parent } @@ -29,11 +29,21 @@ RSpec.describe WorkItems::Widgets::Hierarchy do end describe '#children' do - 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 } + let_it_be_with_reload(:parent_link1) { create(:parent_link, work_item_parent: work_item_parent, work_item: task) } + let_it_be_with_reload(:parent_link2) { create(:parent_link, work_item_parent: work_item_parent) } subject { described_class.new(work_item_parent).children } it { is_expected.to contain_exactly(parent_link1.work_item, parent_link2.work_item) } + + context 'with default order by created_at' do + let_it_be(:oldest_child) { create(:work_item, :task, project: project, created_at: 5.minutes.ago) } + + 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)) } + end end end |
