diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-03-31 21:09:19 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-03-31 21:09:19 +0300 |
commit | 676109e1b32682bdbdd94a9ffbd8743784f35521 (patch) | |
tree | 71f0394c68455c1736a14c215992de6aa5fe358c /app/models | |
parent | 5facc34f44ce8736078127a5df174a7b52d922b4 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/commit_status.rb | 1 | ||||
-rw-r--r-- | app/models/concerns/issuable.rb | 2 | ||||
-rw-r--r-- | app/models/members/group_member.rb | 2 | ||||
-rw-r--r-- | app/models/members/project_member.rb | 2 | ||||
-rw-r--r-- | app/models/merge_request.rb | 4 | ||||
-rw-r--r-- | app/models/project.rb | 2 |
6 files changed, 8 insertions, 5 deletions
diff --git a/app/models/commit_status.rb b/app/models/commit_status.rb index 9b08ca3718e..e64380f5d91 100644 --- a/app/models/commit_status.rb +++ b/app/models/commit_status.rb @@ -55,6 +55,7 @@ class CommitStatus < ApplicationRecord scope :for_ref, -> (ref) { where(ref: ref) } scope :by_name, -> (name) { where(name: name) } scope :in_pipelines, ->(pipelines) { where(pipeline: pipelines) } + scope :eager_load_pipeline, -> { eager_load(:pipeline, project: { namespace: :route }) } scope :for_project_paths, -> (paths) do where(project: Project.where_full_path_in(Array(paths))) diff --git a/app/models/concerns/issuable.rb b/app/models/concerns/issuable.rb index e1be0665452..09859fda877 100644 --- a/app/models/concerns/issuable.rb +++ b/app/models/concerns/issuable.rb @@ -324,7 +324,7 @@ module Issuable # This prevents errors when ignored columns are present in the database. issuable_columns = with_cte ? issue_grouping_columns(use_cte: with_cte) : "#{table_name}.*" - extra_select_columns = extra_select_columns.unshift("(#{highest_priority}) AS highest_priority") + extra_select_columns.unshift("(#{highest_priority}) AS highest_priority") select(issuable_columns) .select(extra_select_columns) diff --git a/app/models/members/group_member.rb b/app/models/members/group_member.rb index c30f6dc81ee..b63c2b84882 100644 --- a/app/models/members/group_member.rb +++ b/app/models/members/group_member.rb @@ -7,7 +7,7 @@ class GroupMember < Member SOURCE_TYPE = 'Namespace' belongs_to :group, foreign_key: 'source_id' - + alias_attribute :namespace_id, :source_id delegate :update_two_factor_requirement, to: :user # Make sure group member points only to group as it source diff --git a/app/models/members/project_member.rb b/app/models/members/project_member.rb index 833b27756ab..9a86b3a3fd9 100644 --- a/app/models/members/project_member.rb +++ b/app/models/members/project_member.rb @@ -5,6 +5,8 @@ class ProjectMember < Member belongs_to :project, foreign_key: 'source_id' + delegate :namespace_id, to: :project + # Make sure project member points only to project as it source default_value_for :source_type, SOURCE_TYPE validates :source_type, format: { with: /\AProject\z/ } diff --git a/app/models/merge_request.rb b/app/models/merge_request.rb index 4a3162c5aa6..7a63fba2835 100644 --- a/app/models/merge_request.rb +++ b/app/models/merge_request.rb @@ -1350,8 +1350,8 @@ class MergeRequest < ApplicationRecord has_no_commits? || branch_missing? || cannot_be_merged? end - def can_be_merged_by?(user) - access = ::Gitlab::UserAccess.new(user, container: project) + def can_be_merged_by?(user, skip_collaboration_check: false) + access = ::Gitlab::UserAccess.new(user, container: project, skip_collaboration_check: skip_collaboration_check) access.can_update_branch?(target_branch) end diff --git a/app/models/project.rb b/app/models/project.rb index 30741e117bf..eb0382414de 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -2711,7 +2711,7 @@ class Project < ApplicationRecord # Issue for N+1: https://gitlab.com/gitlab-org/gitlab-foss/issues/49322 Gitlab::GitalyClient.allow_n_plus_1_calls do merge_requests_allowing_collaboration(branch_name).any? do |merge_request| - merge_request.can_be_merged_by?(user) + merge_request.can_be_merged_by?(user, skip_collaboration_check: true) end end end |