Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-02-24 06:09:05 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-02-24 06:09:05 +0300
commit07d0374b204881f2bd64ed897e4bbab19f180cc9 (patch)
treeed7837a31c0edae5e8ec876626b0bf3ecb3db68c /app/models
parent2ed3b0abccc8de391f1a9de2bc5785d3e0f5b018 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/models')
-rw-r--r--app/models/ci/job_artifact.rb2
-rw-r--r--app/models/discussion.rb3
-rw-r--r--app/models/note.rb16
-rw-r--r--app/models/project.rb2
4 files changed, 13 insertions, 10 deletions
diff --git a/app/models/ci/job_artifact.rb b/app/models/ci/job_artifact.rb
index b66bc78094f..8defe742ec4 100644
--- a/app/models/ci/job_artifact.rb
+++ b/app/models/ci/job_artifact.rb
@@ -74,7 +74,7 @@ module Ci
scope :with_files_stored_locally, -> { where(file_store: [nil, ::JobArtifactUploader::Store::LOCAL]) }
scope :with_files_stored_remotely, -> { where(file_store: ::JobArtifactUploader::Store::REMOTE) }
- scope :for_sha, ->(sha) { joins(job: :pipeline).where(ci_pipelines: { sha: sha }) }
+ scope :for_sha, ->(sha, project_id) { joins(job: :pipeline).where(ci_pipelines: { sha: sha, project_id: project_id }) }
scope :with_file_types, -> (file_types) do
types = self.file_types.select { |file_type| file_types.include?(file_type) }.values
diff --git a/app/models/discussion.rb b/app/models/discussion.rb
index d0a7db39a30..5c45c5fb7fb 100644
--- a/app/models/discussion.rb
+++ b/app/models/discussion.rb
@@ -19,7 +19,8 @@ class Discussion
:noteable_ability_name,
:to_ability_name,
:editable?,
- :visible_for?,
+ :system_note_with_references_visible_for?,
+ :resource_parent,
to: :first_note
diff --git a/app/models/note.rb b/app/models/note.rb
index 97e84bb79f6..561391a55b6 100644
--- a/app/models/note.rb
+++ b/app/models/note.rb
@@ -223,7 +223,7 @@ class Note < ApplicationRecord
end
# rubocop: disable CodeReuse/ServiceClass
- def cross_reference?
+ def system_note_with_references?
return unless system?
if force_cross_reference_regex_check?
@@ -339,12 +339,10 @@ class Note < ApplicationRecord
super
end
- def cross_reference_not_visible_for?(user)
- cross_reference? && !all_referenced_mentionables_allowed?(user)
- end
-
- def visible_for?(user)
- !cross_reference_not_visible_for?(user) && system_note_viewable_by?(user)
+ # This method is to be used for checking read permissions on a note instead of `system_note_with_references_visible_for?`
+ def readable_by?(user)
+ # note_policy accounts for #system_note_with_references_visible_for?(user) check when granting read access
+ Ability.allowed?(user, :read_note, self)
end
def award_emoji?
@@ -504,6 +502,10 @@ class Note < ApplicationRecord
noteable.user_mentions.where(note: self)
end
+ def system_note_with_references_visible_for?(user)
+ (!system_note_with_references? || all_referenced_mentionables_allowed?(user)) && system_note_viewable_by?(user)
+ end
+
private
# Using this method followed by a call to `save` may result in ActiveRecord::RecordNotUnique exception
diff --git a/app/models/project.rb b/app/models/project.rb
index e16bd568153..6ff5016be03 100644
--- a/app/models/project.rb
+++ b/app/models/project.rb
@@ -1374,7 +1374,7 @@ class Project < ApplicationRecord
@lfs_storage_project ||= begin
result = self
- # TODO: Make this go to the fork_network root immeadiatly
+ # TODO: Make this go to the fork_network root immediately
# dependant on the discussion in: https://gitlab.com/gitlab-org/gitlab-foss/issues/39769
result = result.fork_source while result&.forked?