diff options
author | Marin Jankovski <marin@gitlab.com> | 2019-07-02 06:19:58 +0000 |
---|---|---|
committer | Marin Jankovski <marin@gitlab.com> | 2019-07-02 06:19:58 +0000 |
commit | f66169b35c29294ecc9f63eeeedc52085d2a3fd7 (patch) | |
tree | 272bcdb2ffd338d82b615e075e721a9043bc323a /lib/api/entities.rb | |
parent | f4cc3db38be9583876e0dffdbeb0f759e4945f5f (diff) | |
parent | 09163e423ac50c8eda82f67e5419142893faf18a (diff) | |
download | gitlab-ce-f66169b35c29294ecc9f63eeeedc52085d2a3fd7.tar.gz |
Merge branch 'security-59581-related-merge-requests-count' into 'master'
Expose merge requests count based on user access
See merge request gitlab/gitlabhq!3157
Diffstat (limited to 'lib/api/entities.rb')
-rw-r--r-- | lib/api/entities.rb | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/api/entities.rb b/lib/api/entities.rb index ead01dc53f7..0f4332506a7 100644 --- a/lib/api/entities.rb +++ b/lib/api/entities.rb @@ -498,9 +498,9 @@ module API expose :state, :created_at, :updated_at # Avoids an N+1 query when metadata is included - def issuable_metadata(subject, options, method) + def issuable_metadata(subject, options, method, args = nil) cached_subject = options.dig(:issuable_metadata, subject.id) - (cached_subject || subject).public_send(method) # rubocop: disable GitlabSecurity/PublicSend + (cached_subject || subject).public_send(method, *args) # rubocop: disable GitlabSecurity/PublicSend end end @@ -564,7 +564,7 @@ module API end expose(:user_notes_count) { |issue, options| issuable_metadata(issue, options, :user_notes_count) } - expose(:merge_requests_count) { |issue, options| issuable_metadata(issue, options, :merge_requests_count) } + expose(:merge_requests_count) { |issue, options| issuable_metadata(issue, options, :merge_requests_count, options[:current_user]) } expose(:upvotes) { |issue, options| issuable_metadata(issue, options, :upvotes) } expose(:downvotes) { |issue, options| issuable_metadata(issue, options, :downvotes) } expose :due_date |