Module: ChecksCollaboration

Included in:
BlobPresenter, Ci::PipelineEditorHelper, DiffFileBaseEntity, MergeRequestPresenter, ProjectPresenter, Projects::ApplicationController
Defined in:
app/controllers/concerns/checks_collaboration.rb

Instance Method Summary collapse

Instance Method Details

#can_collaborate_with_project?(project, ref: nil) ⇒ Boolean

Returns:

  • (Boolean)


4
5
6
7
8
9
10
11
12
13
# File 'app/controllers/concerns/checks_collaboration.rb', line 4

def can_collaborate_with_project?(project, ref: nil)
  return true if can?(current_user, :push_code, project)

  can_create_merge_request =
    can?(current_user, :create_merge_request_in, project) &&
    current_user.already_forked?(project)

  can_create_merge_request ||
    user_access(project).can_push_to_branch?(ref)
end

#user_access(project) ⇒ Object

rubocop:disable Gitlab/ModuleWithInstanceVariables enabling this so we can easily cache the user access value as it might be used across multiple calls in the view



18
19
20
21
# File 'app/controllers/concerns/checks_collaboration.rb', line 18

def user_access(project)
  @user_access ||= {}
  @user_access[project] ||= Gitlab::UserAccess.new(current_user, container: project)
end