summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCan Eldem <celdem@gitlab.com>2019-09-11 15:33:50 +0000
committerRémy Coutable <remy@rymai.me>2019-09-11 15:33:50 +0000
commit0a5bce6e4f7e5a0f7bcbb1acd203416bcd234589 (patch)
tree8613f318b1978d0a62f2a27d01becb522a01b976
parentf95857c8c5155b4fb1d4ff5b521f28c8d72d9d90 (diff)
downloadgitlab-ce-0a5bce6e4f7e5a0f7bcbb1acd203416bcd234589.tar.gz
Backport changes for 16252 in EE add current_user to report comparison services
-rw-r--r--app/models/merge_request.rb7
-rw-r--r--app/services/ci/compare_reports_base_service.rb2
2 files changed, 5 insertions, 4 deletions
diff --git a/app/models/merge_request.rb b/app/models/merge_request.rb
index 901ebcf249f..74f8067db0a 100644
--- a/app/models/merge_request.rb
+++ b/app/models/merge_request.rb
@@ -1239,7 +1239,7 @@ class MergeRequest < ApplicationRecord
end
def compare_reports(service_class, current_user = nil)
- with_reactive_cache(service_class.name) do |data|
+ with_reactive_cache(service_class.name, current_user&.id) do |data|
unless service_class.new(project, current_user)
.latest?(base_pipeline, actual_head_pipeline, data)
raise InvalidateReactiveCache
@@ -1249,12 +1249,13 @@ class MergeRequest < ApplicationRecord
end || { status: :parsing }
end
- def calculate_reactive_cache(identifier, *args)
+ def calculate_reactive_cache(identifier, current_user_id = nil, *args)
service_class = identifier.constantize
raise NameError, service_class unless service_class < Ci::CompareReportsBaseService
- service_class.new(project).execute(base_pipeline, actual_head_pipeline)
+ current_user = User.find_by(id: current_user_id)
+ service_class.new(project, current_user).execute(base_pipeline, actual_head_pipeline)
end
def all_commits
diff --git a/app/services/ci/compare_reports_base_service.rb b/app/services/ci/compare_reports_base_service.rb
index 6c2d80d8f45..5b76e1824e4 100644
--- a/app/services/ci/compare_reports_base_service.rb
+++ b/app/services/ci/compare_reports_base_service.rb
@@ -41,7 +41,7 @@ module Ci
end
def serializer_params
- { project: project }
+ { project: project, current_user: current_user }
end
def get_report(pipeline)