gitlab-org--gitlab-foss/app/finders/merge_request_target_project_finder.rb
Bob Van Landuyt ec43e36444 Prevent new merge requests for archived projects
This prevents creating merge requests targeting archived projects.

This could happen when a project was already forked, but then the
source was archived.
2018-04-11 10:51:14 +02:00

21 lines
543 B
Ruby

class MergeRequestTargetProjectFinder
include FinderMethods
attr_reader :current_user, :source_project
def initialize(current_user: nil, source_project:)
@current_user = current_user
@source_project = source_project
end
def execute
if @source_project.fork_network
@source_project.fork_network.projects
.public_or_visible_to_user(current_user)
.non_archived
.with_feature_available_for_user(:merge_requests, current_user)
else
Project.where(id: source_project)
end
end
end