Commit 29dc05b0 authored by Alexandru Croitor's avatar Alexandru Croitor

Consider all projects in hierarchy for issue rebalance

When rebalancing issues based on a issue from a project, we need
to consider all issues in the hierarchy vs just issues in the
project's parent group and descendants, as it may happen that the
project's group is not the root group, thus not rebalancing issues
throughout the hierarchy.
parent 7cf7f452
...@@ -88,7 +88,6 @@ class Issue < ApplicationRecord ...@@ -88,7 +88,6 @@ class Issue < ApplicationRecord
test_case: 2 ## EE-only test_case: 2 ## EE-only
} }
alias_attribute :parent_ids, :project_id
alias_method :issuing_parent, :project alias_method :issuing_parent, :project
alias_attribute :external_author, :service_desk_reply_to alias_attribute :external_author, :service_desk_reply_to
...@@ -191,7 +190,8 @@ class Issue < ApplicationRecord ...@@ -191,7 +190,8 @@ class Issue < ApplicationRecord
end end
def self.relative_positioning_query_base(issue) def self.relative_positioning_query_base(issue)
in_projects(issue.parent_ids) projects = issue.project.group&.root_ancestor&.all_projects || issue.project
in_projects(projects)
end end
def self.relative_positioning_parent_column def self.relative_positioning_parent_column
......
...@@ -175,21 +175,6 @@ module EE ...@@ -175,21 +175,6 @@ module EE
user.can?(:admin_issue, project) && user.can?(:create_epic, group) user.can?(:admin_issue, project) && user.can?(:create_epic, group)
end end
# Issue position on boards list should be relative to all group projects
def parent_ids
return super unless has_group_boards?
board_group.all_projects.select(:id)
end
def has_group_boards?
board_group && board_group.boards.any?
end
def board_group
@group ||= project.group
end
def promoted? def promoted?
!!promoted_to_epic_id !!promoted_to_epic_id
end end
......
...@@ -529,9 +529,10 @@ RSpec.describe Issue do ...@@ -529,9 +529,10 @@ RSpec.describe Issue do
describe 'relative positioning with group boards' do describe 'relative positioning with group boards' do
let_it_be(:group) { create(:group) } let_it_be(:group) { create(:group) }
let_it_be(:subgroup) { create(:group, parent: group) }
let_it_be(:board) { create(:board, group: group) } let_it_be(:board) { create(:board, group: group) }
let_it_be(:project) { create(:project, namespace: group) } let_it_be(:project) { create(:project, group: subgroup) }
let_it_be(:project1) { create(:project, namespace: group) } let_it_be(:project1) { create(:project, group: group) }
let_it_be_with_reload(:issue) { create(:issue, project: project) } let_it_be_with_reload(:issue) { create(:issue, project: project) }
let_it_be_with_reload(:issue1) { create(:issue, project: project1, relative_position: issue.relative_position + RelativePositioning::IDEAL_DISTANCE) } let_it_be_with_reload(:issue1) { create(:issue, project: project1, relative_position: issue.relative_position + RelativePositioning::IDEAL_DISTANCE) }
let(:new_issue) { build(:issue, project: project1, relative_position: nil) } let(:new_issue) { build(:issue, project: project1, relative_position: nil) }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment