Commit 520065bd authored by Micael Bergeron's avatar Micael Bergeron

Fix some failing tests

parent 8b393c9f
......@@ -1021,7 +1021,7 @@ class MergeRequest < ApplicationRecord
end
def for_fork?
target_project != source_project
target_project_id != source_project_id
end
# If the merge request closes any issues, save this information in the
......
......@@ -14,7 +14,11 @@ module API
super
end
def issuable_metadata
def issuable_metadata(user: nil)
# Because of the presence of the `user` parameter, we can't
# use the same lazy association.
return Gitlab::IssuableMetadata.new(user, [object]).data[object.id] if user
lazy_issuable_metadata
end
......
......@@ -32,7 +32,7 @@ module API
end
def total_time_spent
lazy_timelogs.sum(&:time_spend) # rubocop:disable CodeReuse/ActiveRecord
lazy_timelogs.sum(&:time_spent) # rubocop:disable CodeReuse/ActiveRecord
end
end
end
......
......@@ -21,10 +21,10 @@ module API
issue.assignees.first
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, options[:current_user]) }
expose(:upvotes) { |issue, options| issuable_metadata(issue, options, :upvotes) }
expose(:downvotes) { |issue, options| issuable_metadata(issue, options, :downvotes) }
expose(:user_notes_count) { |issue, options| issuable_metadata.user_notes_count }
expose(:merge_requests_count) { |issue, options| issuable_metadata(user: options[:current_user]).merge_requests_count }
expose(:upvotes) { |issue, options| issuable_metadata.upvotes }
expose(:downvotes) { |issue, options| issuable_metadata.downvotes }
expose :due_date
expose :confidential
expose :discussion_locked
......
......@@ -27,6 +27,7 @@ module Gitlab
end
def objects(scope, page: nil, per_page: DEFAULT_PER_PAGE, without_count: true, preload_method: nil)
should_preload = preload_method.present?
collection = case scope
when 'projects'
projects
......@@ -39,9 +40,11 @@ module Gitlab
when 'users'
users
else
should_preload = false
Kaminari.paginate_array([])
end
collection = collection.public_send(preload_method) if should_preload # rubocop:disable GitlabSecurity/PublicSend
collection = collection.page(page).per(per_page)
without_count ? collection.without_count : collection
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment