Commit 628c6edf authored by Lin Jen-Shin's avatar Lin Jen-Shin

Merge branch 'resrouce-parent-rename' into 'master'

Use resource_parent instead of parent

See merge request gitlab-org/gitlab!16315
parents 6faf9bab 6b4f1ab2
...@@ -13,7 +13,7 @@ module Boards ...@@ -13,7 +13,7 @@ module Boards
end end
def board_parent def board_parent
@board_parent ||= board.parent @board_parent ||= board.resource_parent
end end
def record_not_found(exception) def record_not_found(exception)
......
...@@ -9,7 +9,7 @@ module Boards ...@@ -9,7 +9,7 @@ module Boards
skip_before_action :authenticate_user!, only: [:index] skip_before_action :authenticate_user!, only: [:index]
def index def index
lists = Boards::Lists::ListService.new(board.parent, current_user).execute(board) lists = Boards::Lists::ListService.new(board.resource_parent, current_user).execute(board)
List.preload_preferences_for_user(lists, current_user) List.preload_preferences_for_user(lists, current_user)
...@@ -17,7 +17,7 @@ module Boards ...@@ -17,7 +17,7 @@ module Boards
end end
def create def create
list = Boards::Lists::CreateService.new(board.parent, current_user, create_list_params).execute(board) list = Boards::Lists::CreateService.new(board.resource_parent, current_user, create_list_params).execute(board)
if list.valid? if list.valid?
render json: serialize_as_json(list) render json: serialize_as_json(list)
......
...@@ -35,7 +35,7 @@ module MilestoneActions ...@@ -35,7 +35,7 @@ module MilestoneActions
render json: tabs_json("shared/milestones/_labels_tab", { render json: tabs_json("shared/milestones/_labels_tab", {
labels: milestone_labels.map do |label| labels: milestone_labels.map do |label|
label.present(issuable_subject: @milestone.parent) label.present(issuable_subject: @milestone.resource_parent)
end end
}) })
end end
......
...@@ -44,7 +44,7 @@ class Groups::MilestonesController < Groups::ApplicationController ...@@ -44,7 +44,7 @@ class Groups::MilestonesController < Groups::ApplicationController
# all projects milestones states at once. # all projects milestones states at once.
milestones, update_params = get_milestones_for_update milestones, update_params = get_milestones_for_update
milestones.each do |milestone| milestones.each do |milestone|
Milestones::UpdateService.new(milestone.parent, current_user, update_params).execute(milestone) Milestones::UpdateService.new(milestone.resource_parent, current_user, update_params).execute(milestone)
end end
redirect_to milestone_path redirect_to milestone_path
......
...@@ -76,10 +76,10 @@ module GitlabRoutingHelper ...@@ -76,10 +76,10 @@ module GitlabRoutingHelper
end end
def edit_milestone_path(entity, *args) def edit_milestone_path(entity, *args)
if entity.parent.is_a?(Group) if entity.resource_parent.is_a?(Group)
edit_group_milestone_path(entity.parent, entity, *args) edit_group_milestone_path(entity.resource_parent, entity, *args)
else else
edit_project_milestone_path(entity.parent, entity, *args) edit_project_milestone_path(entity.resource_parent, entity, *args)
end end
end end
......
...@@ -45,8 +45,8 @@ module TodosHelper ...@@ -45,8 +45,8 @@ module TodosHelper
end end
def todo_parent_path(todo) def todo_parent_path(todo)
if todo.parent.is_a?(Group) if todo.resource_parent.is_a?(Group)
link_to todo.parent.name, group_path(todo.parent) link_to todo.resource_parent.name, group_path(todo.resource_parent)
else else
link_to_project(todo.project) link_to_project(todo.project)
end end
...@@ -64,7 +64,7 @@ module TodosHelper ...@@ -64,7 +64,7 @@ module TodosHelper
if todo.for_commit? if todo.for_commit?
project_commit_path(todo.project, todo.target, path_options) project_commit_path(todo.project, todo.target, path_options)
else else
path = [todo.parent, todo.target] path = [todo.resource_parent, todo.target]
path.unshift(:pipelines) if todo.build_failed? path.unshift(:pipelines) if todo.build_failed?
......
...@@ -16,10 +16,9 @@ class Board < ApplicationRecord ...@@ -16,10 +16,9 @@ class Board < ApplicationRecord
!group !group
end end
def parent def resource_parent
@parent ||= group || project @resource_parent ||= group || project
end end
alias_method :resource_parent, :parent
def group_board? def group_board?
group_id.present? group_id.present?
......
...@@ -11,7 +11,7 @@ class GlobalMilestone ...@@ -11,7 +11,7 @@ class GlobalMilestone
delegate :title, :state, :due_date, :start_date, :participants, :project, delegate :title, :state, :due_date, :start_date, :participants, :project,
:group, :expires_at, :closed?, :iid, :group_milestone?, :safe_title, :group, :expires_at, :closed?, :iid, :group_milestone?, :safe_title,
:milestoneish_id, :parent, to: :milestone :milestoneish_id, :resource_parent, to: :milestone
def to_hash def to_hash
{ {
......
...@@ -257,10 +257,9 @@ class Milestone < ApplicationRecord ...@@ -257,10 +257,9 @@ class Milestone < ApplicationRecord
title.to_slug.normalize.to_s title.to_slug.normalize.to_s
end end
def parent def resource_parent
group || project group || project
end end
alias_method :resource_parent, :parent
def group_milestone? def group_milestone?
group_id.present? group_id.present?
......
...@@ -483,10 +483,9 @@ class Note < ApplicationRecord ...@@ -483,10 +483,9 @@ class Note < ApplicationRecord
Upload.find_by(model: self, path: paths) Upload.find_by(model: self, path: paths)
end end
def parent def resource_parent
project project
end end
alias_method :resource_parent, :parent
private private
......
...@@ -144,10 +144,9 @@ class Todo < ApplicationRecord ...@@ -144,10 +144,9 @@ class Todo < ApplicationRecord
end end
end end
def parent def resource_parent
project project
end end
alias_method :resource_parent, :parent
def unmergeable? def unmergeable?
action == UNMERGEABLE action == UNMERGEABLE
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
class BoardPolicy < BasePolicy class BoardPolicy < BasePolicy
include FindGroupProjects include FindGroupProjects
delegate { @subject.parent } delegate { @subject.resource_parent }
condition(:is_group_board) { @subject.group_board? } condition(:is_group_board) { @subject.group_board? }
condition(:is_project_board) { @subject.project_board? } condition(:is_project_board) { @subject.project_board? }
...@@ -19,7 +19,7 @@ class BoardPolicy < BasePolicy ...@@ -19,7 +19,7 @@ class BoardPolicy < BasePolicy
condition(:reporter_of_group_projects) do condition(:reporter_of_group_projects) do
next unless @user next unless @user
group_projects_for(user: @user, group: @subject.parent) group_projects_for(user: @user, group: @subject.resource_parent)
.visible_to_user_and_access_level(@user, ::Gitlab::Access::REPORTER) .visible_to_user_and_access_level(@user, ::Gitlab::Access::REPORTER)
.exists? .exists?
end end
......
# frozen_string_literal: true # frozen_string_literal: true
class MilestonePolicy < BasePolicy class MilestonePolicy < BasePolicy
delegate { @subject.parent } delegate { @subject.resource_parent }
end end
...@@ -50,7 +50,7 @@ module Notes ...@@ -50,7 +50,7 @@ module Notes
return if update_params.empty? return if update_params.empty?
return unless supported?(note) return unless supported?(note)
self.class.noteable_update_service(note).new(note.parent, current_user, update_params).execute(note.noteable) self.class.noteable_update_service(note).new(note.resource_parent, current_user, update_params).execute(note.noteable)
end end
end end
end end
......
- parent = board.parent - parent = board.resource_parent
- milestone_filter_opts = { format: :json } - milestone_filter_opts = { format: :json }
- milestone_filter_opts = milestone_filter_opts.merge(only_group_milestones: true) if board.group_board? - milestone_filter_opts = milestone_filter_opts.merge(only_group_milestones: true) if board.group_board?
- weights = Gitlab.ee? ? ([Issue::WEIGHT_ANY] + Issue.weight_options) : [] - weights = Gitlab.ee? ? ([Issue::WEIGHT_ANY] + Issue.weight_options) : []
......
...@@ -3,6 +3,6 @@ ...@@ -3,6 +3,6 @@
Add list Add list
.dropdown-menu.dropdown-extended-height.dropdown-menu-paging.dropdown-menu-right.dropdown-menu-issues-board-new.dropdown-menu-selectable.js-tab-container-labels .dropdown-menu.dropdown-extended-height.dropdown-menu-paging.dropdown-menu-right.dropdown-menu-issues-board-new.dropdown-menu-selectable.js-tab-container-labels
= render partial: "shared/issuable/label_page_default", locals: { show_footer: true, show_create: true, show_boards_content: true, title: "Add list" } = render partial: "shared/issuable/label_page_default", locals: { show_footer: true, show_create: true, show_boards_content: true, title: "Add list" }
- if can?(current_user, :admin_label, board.parent) - if can?(current_user, :admin_label, board.resource_parent)
= render partial: "shared/issuable/label_page_create", locals: { show_add_list: true, add_list: true, add_list_class: 'd-none' } = render partial: "shared/issuable/label_page_create", locals: { show_add_list: true, add_list: true, add_list_class: 'd-none' }
= dropdown_loading = dropdown_loading
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
- board = local_assigns.fetch(:board, nil) - board = local_assigns.fetch(:board, nil)
- is_not_boards_modal_or_productivity_analytics = type != :boards_modal && type != :productivity_analytics - is_not_boards_modal_or_productivity_analytics = type != :boards_modal && type != :productivity_analytics
- block_css_class = is_not_boards_modal_or_productivity_analytics ? 'row-content-block second-block' : '' - block_css_class = is_not_boards_modal_or_productivity_analytics ? 'row-content-block second-block' : ''
- user_can_admin_list = board && can?(current_user, :admin_list, board.parent) - user_can_admin_list = board && can?(current_user, :admin_list, board.resource_parent)
.issues-filters{ class: ("w-100" if type == :boards_modal) } .issues-filters{ class: ("w-100" if type == :boards_modal) }
.issues-details-filters.filtered-search-block.d-flex.flex-column.flex-md-row{ class: block_css_class, "v-pre" => type == :boards_modal } .issues-details-filters.filtered-search-block.d-flex.flex-column.flex-md-row{ class: block_css_class, "v-pre" => type == :boards_modal }
......
...@@ -15,7 +15,7 @@ module Boards ...@@ -15,7 +15,7 @@ module Boards
# rubocop: disable CodeReuse/Finder # rubocop: disable CodeReuse/Finder
def finder_service def finder_service
parent = @board.parent parent = @board.resource_parent
finder_params = finder_params =
if parent.is_a?(Group) if parent.is_a?(Group)
......
...@@ -16,10 +16,10 @@ module Boards ...@@ -16,10 +16,10 @@ module Boards
# rubocop: disable CodeReuse/Finder # rubocop: disable CodeReuse/Finder
def finder_service def finder_service
@finder_service ||= @finder_service ||=
if @board.parent.is_a?(Group) if @board.resource_parent.is_a?(Group)
GroupMembersFinder.new(@board.parent) GroupMembersFinder.new(@board.resource_parent)
else else
MembersFinder.new(@board.parent, @current_user) MembersFinder.new(@board.resource_parent, @current_user)
end end
end end
# rubocop: enable CodeReuse/Finder # rubocop: enable CodeReuse/Finder
......
...@@ -20,7 +20,7 @@ module EE ...@@ -20,7 +20,7 @@ module EE
return false if cookies['hide_burndown_message'].present? return false if cookies['hide_burndown_message'].present?
return false unless milestone.supports_burndown_charts? return false unless milestone.supports_burndown_charts?
warning.nil? && can?(current_user, :admin_milestone, milestone.parent) warning.nil? && can?(current_user, :admin_milestone, milestone.resource_parent)
end end
def data_warning_for(burndown) def data_warning_for(burndown)
......
...@@ -32,7 +32,7 @@ module EE ...@@ -32,7 +32,7 @@ module EE
) )
designs_project_issue_path( designs_project_issue_path(
todo.parent, todo.resource_parent,
design.issue, design.issue,
path_options path_options
) )
......
...@@ -16,7 +16,7 @@ module EE ...@@ -16,7 +16,7 @@ module EE
design = @note.noteable design = @note.noteable
@target_url = ::Gitlab::Routing.url_helpers.designs_project_issue_url( @target_url = ::Gitlab::Routing.url_helpers.designs_project_issue_url(
@note.parent, @note.resource_parent,
design.issue, design.issue,
note_target_url_query_params.merge(vueroute: design.filename) note_target_url_query_params.merge(vueroute: design.filename)
) )
......
...@@ -28,7 +28,7 @@ module EE ...@@ -28,7 +28,7 @@ module EE
override :scoped? override :scoped?
def scoped? def scoped?
return super unless parent.feature_available?(:scoped_issue_board) return super unless resource_parent.feature_available?(:scoped_issue_board)
EMPTY_SCOPE_STATE.exclude?(milestone_id) || EMPTY_SCOPE_STATE.exclude?(milestone_id) ||
EMPTY_SCOPE_STATE.exclude?(weight) || EMPTY_SCOPE_STATE.exclude?(weight) ||
...@@ -37,7 +37,7 @@ module EE ...@@ -37,7 +37,7 @@ module EE
end end
def milestone def milestone
return unless parent&.feature_available?(:scoped_issue_board) return unless resource_parent&.feature_available?(:scoped_issue_board)
case milestone_id case milestone_id
when ::Milestone::Upcoming.id when ::Milestone::Upcoming.id
......
...@@ -23,10 +23,10 @@ module EE ...@@ -23,10 +23,10 @@ module EE
base.validates :max_issue_count, numericality: { only_integer: true, greater_than_or_equal_to: 0 } base.validates :max_issue_count, numericality: { only_integer: true, greater_than_or_equal_to: 0 }
base.validates :list_type, base.validates :list_type,
exclusion: { in: %w[assignee], message: _('Assignee lists not available with your current license') }, exclusion: { in: %w[assignee], message: _('Assignee lists not available with your current license') },
unless: -> { board&.parent&.feature_available?(:board_assignee_lists) } unless: -> { board&.resource_parent&.feature_available?(:board_assignee_lists) }
base.validates :list_type, base.validates :list_type,
exclusion: { in: %w[milestone], message: _('Milestone lists not available with your current license') }, exclusion: { in: %w[milestone], message: _('Milestone lists not available with your current license') },
unless: -> { board&.parent&.feature_available?(:board_milestone_lists) } unless: -> { board&.resource_parent&.feature_available?(:board_milestone_lists) }
end end
def assignee=(user) def assignee=(user)
......
...@@ -11,13 +11,13 @@ module EE ...@@ -11,13 +11,13 @@ module EE
end end
def supports_weight? def supports_weight?
parent&.feature_available?(:issue_weights) resource_parent&.feature_available?(:issue_weights)
end end
def supports_burndown_charts? def supports_burndown_charts?
feature_name = group_milestone? ? :group_burndown_charts : :burndown_charts feature_name = group_milestone? ? :group_burndown_charts : :burndown_charts
parent&.feature_available?(feature_name) && supports_weight? resource_parent&.feature_available?(feature_name) && supports_weight?
end end
end end
end end
...@@ -57,11 +57,10 @@ module EE ...@@ -57,11 +57,10 @@ module EE
noteable_type == DesignManagement::Design.name noteable_type == DesignManagement::Design.name
end end
override :parent override :resource_parent
def parent def resource_parent
for_epic? ? noteable.group : super for_epic? ? noteable.group : super
end end
alias_method :resource_parent, :parent
def notify_after_create def notify_after_create
noteable&.after_note_created(self) noteable&.after_note_created(self)
......
...@@ -9,11 +9,10 @@ module EE ...@@ -9,11 +9,10 @@ module EE
include UsageStatistics include UsageStatistics
end end
override :parent override :resource_parent
def parent def resource_parent
project || group project || group
end end
alias_method :resource_parent, :parent
def for_design? def for_design?
target_type == DesignManagement::Design.name target_type == DesignManagement::Design.name
......
...@@ -25,7 +25,7 @@ module EE ...@@ -25,7 +25,7 @@ module EE
private private
def list_type_features_availability(board) def list_type_features_availability(board)
parent = board.parent parent = board.resource_parent
LICENSED_LIST_TYPES.each_with_object({}) do |list_type, hash| LICENSED_LIST_TYPES.each_with_object({}) do |list_type, hash|
list_type_key = ::List.list_types[list_type] list_type_key = ::List.list_types[list_type]
......
...@@ -16,7 +16,7 @@ module EE ...@@ -16,7 +16,7 @@ module EE
end end
def max_issue_count?(list) def max_issue_count?(list)
params.has_key?(:max_issue_count) && list.board.parent.feature_available?(:wip_limits) params.has_key?(:max_issue_count) && list.board.resource_parent.feature_available?(:wip_limits)
end end
def update_max_issue_count(list) def update_max_issue_count(list)
......
- assignee_lists_available = board.parent.feature_available?(:board_assignee_lists) - assignee_lists_available = board.resource_parent.feature_available?(:board_assignee_lists)
- milestone_lists_available = board.parent.feature_available?(:board_milestone_lists) - milestone_lists_available = board.resource_parent.feature_available?(:board_milestone_lists)
- if assignee_lists_available || milestone_lists_available - if assignee_lists_available || milestone_lists_available
.dropdown.boards-add-list.prepend-left-10#js-add-list .dropdown.boards-add-list.prepend-left-10#js-add-list
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
.tab-content .tab-content
#tab-labels.tab-pane.tab-pane-labels.active.js-tab-container-labels{ role: 'tabpanel' } #tab-labels.tab-pane.tab-pane-labels.active.js-tab-container-labels{ role: 'tabpanel' }
= render partial: "shared/issuable/label_page_default", locals: { show_title: false, show_footer: true, show_create: true, show_boards_content: true, content_title: _('Label lists show all issues with the selected label.') } = render partial: "shared/issuable/label_page_default", locals: { show_title: false, show_footer: true, show_create: true, show_boards_content: true, content_title: _('Label lists show all issues with the selected label.') }
- if can?(current_user, :admin_label, board.parent) - if can?(current_user, :admin_label, board.resource_parent)
= render partial: "shared/issuable/label_page_create", locals: { show_close: false } = render partial: "shared/issuable/label_page_create", locals: { show_close: false }
- if assignee_lists_available - if assignee_lists_available
......
...@@ -147,7 +147,7 @@ module EE ...@@ -147,7 +147,7 @@ module EE
expose :name expose :name
expose :group, using: ::API::Entities::BasicGroupDetails expose :group, using: ::API::Entities::BasicGroupDetails
with_options if: ->(board, _) { board.parent.feature_available?(:scoped_issue_board) } do with_options if: ->(board, _) { board.resource_parent.feature_available?(:scoped_issue_board) } do
expose :milestone do |board| expose :milestone do |board|
if board.milestone.is_a?(Milestone) if board.milestone.is_a?(Milestone)
::API::Entities::Milestone.represent(board.milestone) ::API::Entities::Milestone.represent(board.milestone)
...@@ -168,7 +168,7 @@ module EE ...@@ -168,7 +168,7 @@ module EE
prepended do prepended do
expose :milestone, using: ::API::Entities::Milestone, if: -> (entity, _) { entity.milestone? } expose :milestone, using: ::API::Entities::Milestone, if: -> (entity, _) { entity.milestone? }
expose :user, as: :assignee, using: ::API::Entities::UserSafe, if: -> (entity, _) { entity.assignee? } expose :user, as: :assignee, using: ::API::Entities::UserSafe, if: -> (entity, _) { entity.assignee? }
expose :max_issue_count, if: -> (list, _) { list.board.parent.feature_available?(:wip_limits) } expose :max_issue_count, if: -> (list, _) { list.board.resource_parent.feature_available?(:wip_limits) }
end end
end end
......
...@@ -41,7 +41,7 @@ describe 'Multiple Issue Boards', :js do ...@@ -41,7 +41,7 @@ describe 'Multiple Issue Boards', :js do
end end
it 'shows a license warning when group has more than one board' do it 'shows a license warning when group has more than one board' do
create(:board, parent: parent) create(:board, resource_parent: parent)
visit boards_path visit boards_path
wait_for_requests wait_for_requests
......
...@@ -76,12 +76,12 @@ describe Note do ...@@ -76,12 +76,12 @@ describe Note do
end end
end end
describe '#parent' do describe '#resource_parent' do
it 'returns group for epic notes' do it 'returns group for epic notes' do
group = create(:group) group = create(:group)
note = create(:note_on_epic, noteable: create(:epic, group: group)) note = create(:note_on_epic, noteable: create(:epic, group: group))
expect(note.parent).to eq(group) expect(note.resource_parent).to eq(group)
end end
end end
......
...@@ -4,8 +4,8 @@ require 'spec_helper' ...@@ -4,8 +4,8 @@ require 'spec_helper'
describe Boards::ListService do describe Boards::ListService do
shared_examples 'boards list service' do shared_examples 'boards list service' do
let(:service) { described_class.new(parent, double) } let(:service) { described_class.new(resource_parent, double) }
let!(:boards) { create_list(:board, 3, parent: parent) } let!(:boards) { create_list(:board, 3, resource_parent: resource_parent) }
describe '#execute' do describe '#execute' do
it 'returns all issue boards when multiple issue boards is enabled' do it 'returns all issue boards when multiple issue boards is enabled' do
...@@ -25,11 +25,11 @@ describe Boards::ListService do ...@@ -25,11 +25,11 @@ describe Boards::ListService do
end end
it_behaves_like 'boards list service' do it_behaves_like 'boards list service' do
let(:parent) { create(:project, :empty_repo) } let(:resource_parent) { create(:project, :empty_repo) }
end end
it_behaves_like 'boards list service' do it_behaves_like 'boards list service' do
let(:parent) { create(:group) } let(:resource_parent) { create(:group) }
it 'returns the first issue board when multiple issue boards is disabled' do it 'returns the first issue board when multiple issue boards is disabled' do
stub_licensed_features(multiple_group_issue_boards: false) stub_licensed_features(multiple_group_issue_boards: false)
......
...@@ -68,7 +68,7 @@ describe Boards::UpdateService, services: true do ...@@ -68,7 +68,7 @@ describe Boards::UpdateService, services: true do
context '#set_labels' do context '#set_labels' do
def expect_label_assigned(user, board, input_labels, expected_labels) def expect_label_assigned(user, board, input_labels, expected_labels)
service = described_class.new(board.parent, user, labels: input_labels.join(',')) service = described_class.new(board.resource_parent, user, labels: input_labels.join(','))
service.execute(board) service.execute(board)
expect(board.reload.labels.map(&:title)).to contain_exactly(*expected_labels) expect(board.reload.labels.map(&:title)).to contain_exactly(*expected_labels)
...@@ -146,7 +146,7 @@ describe Boards::UpdateService, services: true do ...@@ -146,7 +146,7 @@ describe Boards::UpdateService, services: true do
other_group_label = create(:group_label, title: 'other_group_label') other_group_label = create(:group_label, title: 'other_group_label')
label_ids = [group_label.id, label.id, other_project_label.id, other_group_label.id] label_ids = [group_label.id, label.id, other_project_label.id, other_group_label.id]
described_class.new(board.parent, user, label_ids: label_ids).execute(board) described_class.new(board.resource_parent, user, label_ids: label_ids).execute(board)
expect(board.reload.labels).to contain_exactly(group_label, label) expect(board.reload.labels).to contain_exactly(group_label, label)
end end
......
...@@ -10,7 +10,7 @@ describe Boards::Issues::CreateService do ...@@ -10,7 +10,7 @@ describe Boards::Issues::CreateService do
let(:label) { create(:label, project: project, name: 'in-progress') } let(:label) { create(:label, project: project, name: 'in-progress') }
subject(:service) do subject(:service) do
described_class.new(board.parent, project, user, board_id: board.id, list_id: list.id, title: 'New issue') described_class.new(board.resource_parent, project, user, board_id: board.id, list_id: list.id, title: 'New issue')
end end
before do before do
......
...@@ -11,8 +11,8 @@ describe Boards::Lists::ListService do ...@@ -11,8 +11,8 @@ describe Boards::Lists::ListService do
context 'when the feature is enabled' do context 'when the feature is enabled' do
before do before do
allow(board.parent).to receive(:feature_available?).with(:board_assignee_lists).and_return(true) allow(board.resource_parent).to receive(:feature_available?).with(:board_assignee_lists).and_return(true)
allow(board.parent).to receive(:feature_available?).with(:board_milestone_lists).and_return(false) allow(board.resource_parent).to receive(:feature_available?).with(:board_milestone_lists).and_return(false)
end end
it 'returns all lists' do it 'returns all lists' do
...@@ -34,8 +34,8 @@ describe Boards::Lists::ListService do ...@@ -34,8 +34,8 @@ describe Boards::Lists::ListService do
context 'when the feature is enabled' do context 'when the feature is enabled' do
before do before do
allow(board.parent).to receive(:feature_available?).with(:board_assignee_lists).and_return(false) allow(board.resource_parent).to receive(:feature_available?).with(:board_assignee_lists).and_return(false)
allow(board.parent).to receive(:feature_available?).with(:board_milestone_lists).and_return(true) allow(board.resource_parent).to receive(:feature_available?).with(:board_milestone_lists).and_return(true)
end end
it 'returns all lists' do it 'returns all lists' do
......
...@@ -3,8 +3,8 @@ ...@@ -3,8 +3,8 @@
require 'spec_helper' require 'spec_helper'
shared_examples 'multiple issue boards show' do shared_examples 'multiple issue boards show' do
let!(:board1) { create(:board, parent: parent, name: 'b') } let!(:board1) { create(:board, resource_parent: parent, name: 'b') }
let!(:board2) { create(:board, parent: parent, name: 'a') } let!(:board2) { create(:board, resource_parent: parent, name: 'a') }
context 'when multiple issue boards is enabled' do context 'when multiple issue boards is enabled' do
it 'lets user view board1' do it 'lets user view board1' do
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
require 'spec_helper' require 'spec_helper'
shared_examples 'returns recently visited boards' do shared_examples 'returns recently visited boards' do
let(:boards) { create_list(:board, 8, parent: parent) } let(:boards) { create_list(:board, 8, resource_parent: parent) }
context 'unauthenticated' do context 'unauthenticated' do
it 'returns a 401' do it 'returns a 401' do
...@@ -28,7 +28,7 @@ shared_examples 'returns recently visited boards' do ...@@ -28,7 +28,7 @@ shared_examples 'returns recently visited boards' do
end end
shared_examples 'redirects to last visited board' do shared_examples 'redirects to last visited board' do
let(:boards) { create_list(:board, 3, parent: parent) } let(:boards) { create_list(:board, 3, resource_parent: parent) }
before do before do
visit_board(boards[2], Time.now + 1.minute) visit_board(boards[2], Time.now + 1.minute)
......
...@@ -988,11 +988,11 @@ module API ...@@ -988,11 +988,11 @@ module API
def todo_target_url(todo) def todo_target_url(todo)
target_type = todo.target_type.underscore target_type = todo.target_type.underscore
target_url = "#{todo.parent.class.to_s.underscore}_#{target_type}_url" target_url = "#{todo.resource_parent.class.to_s.underscore}_#{target_type}_url"
Gitlab::Routing Gitlab::Routing
.url_helpers .url_helpers
.public_send(target_url, todo.parent, todo.target, anchor: todo_target_anchor(todo)) # rubocop:disable GitlabSecurity/PublicSend .public_send(target_url, todo.resource_parent, todo.target, anchor: todo_target_anchor(todo)) # rubocop:disable GitlabSecurity/PublicSend
end end
def todo_target_anchor(todo) def todo_target_anchor(todo)
......
...@@ -7,7 +7,7 @@ FactoryBot.define do ...@@ -7,7 +7,7 @@ FactoryBot.define do
group { nil } group { nil }
project_id { nil } project_id { nil }
group_id { nil } group_id { nil }
parent { nil } resource_parent { nil }
end end
after(:build, :stub) do |board, evaluator| after(:build, :stub) do |board, evaluator|
...@@ -19,9 +19,9 @@ FactoryBot.define do ...@@ -19,9 +19,9 @@ FactoryBot.define do
board.project = evaluator.project board.project = evaluator.project
elsif evaluator.project_id elsif evaluator.project_id
board.project_id = evaluator.project_id board.project_id = evaluator.project_id
elsif evaluator.parent elsif evaluator.resource_parent
id = evaluator.parent.id id = evaluator.resource_parent.id
evaluator.parent.is_a?(Group) ? board.group_id = id : evaluator.project_id = id evaluator.resource_parent.is_a?(Group) ? board.group_id = id : evaluator.project_id = id
else else
board.project = create(:project, :empty_repo) board.project = create(:project, :empty_repo)
end end
......
...@@ -9,7 +9,7 @@ FactoryBot.define do ...@@ -9,7 +9,7 @@ FactoryBot.define do
group { nil } group { nil }
project_id { nil } project_id { nil }
group_id { nil } group_id { nil }
parent { nil } resource_parent { nil }
end end
trait :active do trait :active do
...@@ -34,9 +34,9 @@ FactoryBot.define do ...@@ -34,9 +34,9 @@ FactoryBot.define do
milestone.project = evaluator.project milestone.project = evaluator.project
elsif evaluator.project_id elsif evaluator.project_id
milestone.project_id = evaluator.project_id milestone.project_id = evaluator.project_id
elsif evaluator.parent elsif evaluator.resource_parent
id = evaluator.parent.id id = evaluator.resource_parent.id
evaluator.parent.is_a?(Group) ? evaluator.group_id = id : evaluator.project_id = id evaluator.resource_parent.is_a?(Group) ? evaluator.group_id = id : evaluator.project_id = id
else else
milestone.project = create(:project) milestone.project = create(:project)
end end
......
...@@ -12,7 +12,7 @@ describe "User deletes milestone", :js do ...@@ -12,7 +12,7 @@ describe "User deletes milestone", :js do
end end
context "when milestone belongs to project" do context "when milestone belongs to project" do
let!(:milestone) { create(:milestone, parent: project, title: "project milestone") } let!(:milestone) { create(:milestone, resource_parent: project, title: "project milestone") }
it "deletes milestone" do it "deletes milestone" do
project.add_developer(user) project.add_developer(user)
...@@ -30,8 +30,8 @@ describe "User deletes milestone", :js do ...@@ -30,8 +30,8 @@ describe "User deletes milestone", :js do
end end
context "when milestone belongs to group" do context "when milestone belongs to group" do
let!(:milestone_to_be_deleted) { create(:milestone, parent: group, title: "group milestone 1") } let!(:milestone_to_be_deleted) { create(:milestone, resource_parent: group, title: "group milestone 1") }
let!(:milestone) { create(:milestone, parent: group, title: "group milestone 2") } let!(:milestone) { create(:milestone, resource_parent: group, title: "group milestone 2") }
it "deletes milestone" do it "deletes milestone" do
group.add_developer(user) group.add_developer(user)
......
...@@ -10,7 +10,7 @@ describe Boards::VisitsFinder do ...@@ -10,7 +10,7 @@ describe Boards::VisitsFinder do
let(:project) { create(:project) } let(:project) { create(:project) }
let(:project_board) { create(:board, project: project) } let(:project_board) { create(:board, project: project) }
subject(:finder) { described_class.new(project_board.parent, user) } subject(:finder) { described_class.new(project_board.resource_parent, user) }
it 'returns nil when there is no user' do it 'returns nil when there is no user' do
finder.current_user = nil finder.current_user = nil
...@@ -27,7 +27,7 @@ describe Boards::VisitsFinder do ...@@ -27,7 +27,7 @@ describe Boards::VisitsFinder do
it 'queries for last N visits' do it 'queries for last N visits' do
expect(BoardProjectRecentVisit).to receive(:latest).with(user, project, count: 5).once expect(BoardProjectRecentVisit).to receive(:latest).with(user, project, count: 5).once
described_class.new(project_board.parent, user).latest(5) described_class.new(project_board.resource_parent, user).latest(5)
end end
end end
...@@ -35,7 +35,7 @@ describe Boards::VisitsFinder do ...@@ -35,7 +35,7 @@ describe Boards::VisitsFinder do
let(:group) { create(:group) } let(:group) { create(:group) }
let(:group_board) { create(:board, group: group) } let(:group_board) { create(:board, group: group) }
subject(:finder) { described_class.new(group_board.parent, user) } subject(:finder) { described_class.new(group_board.resource_parent, user) }
it 'returns nil when there is no user' do it 'returns nil when there is no user' do
finder.current_user = nil finder.current_user = nil
...@@ -52,7 +52,7 @@ describe Boards::VisitsFinder do ...@@ -52,7 +52,7 @@ describe Boards::VisitsFinder do
it 'queries for last N visits' do it 'queries for last N visits' do
expect(BoardGroupRecentVisit).to receive(:latest).with(user, group, count: 5).once expect(BoardGroupRecentVisit).to receive(:latest).with(user, group, count: 5).once
described_class.new(group_board.parent, user).latest(5) described_class.new(group_board.resource_parent, user).latest(5)
end end
end end
end end
......
...@@ -972,13 +972,13 @@ describe Note do ...@@ -972,13 +972,13 @@ describe Note do
project = create(:project) project = create(:project)
note = create(:note_on_issue, project: project) note = create(:note_on_issue, project: project)
expect(note.parent).to eq(project) expect(note.resource_parent).to eq(project)
end end
it 'returns nil for personal snippet note' do it 'returns nil for personal snippet note' do
note = create(:note_on_personal_snippet) note = create(:note_on_personal_snippet)
expect(note.parent).to be_nil expect(note.resource_parent).to be_nil
end end
end end
......
...@@ -10,7 +10,7 @@ describe Boards::Issues::CreateService do ...@@ -10,7 +10,7 @@ describe Boards::Issues::CreateService do
let(:label) { create(:label, project: project, name: 'in-progress') } let(:label) { create(:label, project: project, name: 'in-progress') }
let!(:list) { create(:list, board: board, label: label, position: 0) } let!(:list) { create(:list, board: board, label: label, position: 0) }
subject(:service) { described_class.new(board.parent, project, user, board_id: board.id, list_id: list.id, title: 'New issue') } subject(:service) { described_class.new(board.resource_parent, project, user, board_id: board.id, list_id: list.id, title: 'New issue') }
before do before do
project.add_developer(user) project.add_developer(user)
......
...@@ -9,9 +9,9 @@ describe Boards::Lists::UpdateService do ...@@ -9,9 +9,9 @@ describe Boards::Lists::UpdateService do
shared_examples 'moving list' do shared_examples 'moving list' do
context 'when user can admin list' do context 'when user can admin list' do
it 'calls Lists::MoveService to update list position' do it 'calls Lists::MoveService to update list position' do
board.parent.add_developer(user) board.resource_parent.add_developer(user)
expect(Boards::Lists::MoveService).to receive(:new).with(board.parent, user, params).and_call_original expect(Boards::Lists::MoveService).to receive(:new).with(board.resource_parent, user, params).and_call_original
expect_any_instance_of(Boards::Lists::MoveService).to receive(:execute).with(list) expect_any_instance_of(Boards::Lists::MoveService).to receive(:execute).with(list)
service.execute(list) service.execute(list)
...@@ -30,7 +30,7 @@ describe Boards::Lists::UpdateService do ...@@ -30,7 +30,7 @@ describe Boards::Lists::UpdateService do
shared_examples 'updating list preferences' do shared_examples 'updating list preferences' do
context 'when user can read list' do context 'when user can read list' do
it 'updates list preference for user' do it 'updates list preference for user' do
board.parent.add_guest(user) board.resource_parent.add_guest(user)
service.execute(list) service.execute(list)
...@@ -48,7 +48,7 @@ describe Boards::Lists::UpdateService do ...@@ -48,7 +48,7 @@ describe Boards::Lists::UpdateService do
end end
describe '#execute' do describe '#execute' do
let(:service) { described_class.new(board.parent, user, params) } let(:service) { described_class.new(board.resource_parent, user, params) }
context 'when position parameter is present' do context 'when position parameter is present' do
let(:params) { { position: 1 } } let(:params) { { position: 1 } }
......
...@@ -10,7 +10,7 @@ describe Boards::Visits::CreateService do ...@@ -10,7 +10,7 @@ describe Boards::Visits::CreateService do
let(:project) { create(:project) } let(:project) { create(:project) }
let(:project_board) { create(:board, project: project) } let(:project_board) { create(:board, project: project) }
subject(:service) { described_class.new(project_board.parent, user) } subject(:service) { described_class.new(project_board.resource_parent, user) }
it 'returns nil when there is no user' do it 'returns nil when there is no user' do
service.current_user = nil service.current_user = nil
...@@ -35,7 +35,7 @@ describe Boards::Visits::CreateService do ...@@ -35,7 +35,7 @@ describe Boards::Visits::CreateService do
let(:group) { create(:group) } let(:group) { create(:group) }
let(:group_board) { create(:board, group: group) } let(:group_board) { create(:board, group: group) }
subject(:service) { described_class.new(group_board.parent, user) } subject(:service) { described_class.new(group_board.resource_parent, user) }
it 'returns nil when there is no user' do it 'returns nil when there is no user' do
service.current_user = nil service.current_user = nil
......
...@@ -171,7 +171,7 @@ shared_examples_for 'group and project boards' do |route_definition, ee = false| ...@@ -171,7 +171,7 @@ shared_examples_for 'group and project boards' do |route_definition, ee = false|
if board_parent.try(:namespace) if board_parent.try(:namespace)
board_parent.update(namespace: owner.namespace) board_parent.update(namespace: owner.namespace)
else else
board.parent.add_owner(owner) board.resource_parent.add_owner(owner)
end end
end end
......
...@@ -205,7 +205,7 @@ shared_examples_for 'group and project milestones' do |route_definition| ...@@ -205,7 +205,7 @@ shared_examples_for 'group and project milestones' do |route_definition|
describe "DELETE #{route_definition}/:milestone_id" do describe "DELETE #{route_definition}/:milestone_id" do
it "rejects a member with reporter access from deleting a milestone" do it "rejects a member with reporter access from deleting a milestone" do
reporter = create(:user) reporter = create(:user)
milestone.parent.add_reporter(reporter) milestone.resource_parent.add_reporter(reporter)
delete api(resource_route, reporter) delete api(resource_route, reporter)
......
...@@ -17,7 +17,7 @@ shared_examples 'boards create service' do ...@@ -17,7 +17,7 @@ shared_examples 'boards create service' do
context 'when parent has a board' do context 'when parent has a board' do
before do before do
create(:board, parent: parent) create(:board, resource_parent: parent)
end end
it 'does not create a new board' do it 'does not create a new board' do
......
...@@ -15,7 +15,7 @@ shared_examples 'boards list service' do ...@@ -15,7 +15,7 @@ shared_examples 'boards list service' do
context 'when parent has a board' do context 'when parent has a board' do
before do before do
create(:board, parent: parent) create(:board, resource_parent: parent)
end end
it 'does not create a new board' do it 'does not create a new board' do
...@@ -24,7 +24,7 @@ shared_examples 'boards list service' do ...@@ -24,7 +24,7 @@ shared_examples 'boards list service' do
end end
it 'returns parent boards' do it 'returns parent boards' do
board = create(:board, parent: parent) board = create(:board, resource_parent: parent)
expect(service.execute).to eq [board] expect(service.execute).to eq [board]
end end
......
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