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

Fix some failing tests

parent 8b393c9f
...@@ -1021,7 +1021,7 @@ class MergeRequest < ApplicationRecord ...@@ -1021,7 +1021,7 @@ class MergeRequest < ApplicationRecord
end end
def for_fork? def for_fork?
target_project != source_project target_project_id != source_project_id
end end
# If the merge request closes any issues, save this information in the # If the merge request closes any issues, save this information in the
......
...@@ -14,7 +14,11 @@ module API ...@@ -14,7 +14,11 @@ module API
super super
end 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 lazy_issuable_metadata
end end
......
...@@ -32,7 +32,7 @@ module API ...@@ -32,7 +32,7 @@ module API
end end
def total_time_spent 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 end
end end
......
...@@ -21,10 +21,10 @@ module API ...@@ -21,10 +21,10 @@ module API
issue.assignees.first issue.assignees.first
end end
expose(:user_notes_count) { |issue, options| issuable_metadata(issue, options, :user_notes_count) } expose(:user_notes_count) { |issue, options| issuable_metadata.user_notes_count }
expose(:merge_requests_count) { |issue, options| issuable_metadata(issue, options, :merge_requests_count, options[:current_user]) } expose(:merge_requests_count) { |issue, options| issuable_metadata(user: options[:current_user]).merge_requests_count }
expose(:upvotes) { |issue, options| issuable_metadata(issue, options, :upvotes) } expose(:upvotes) { |issue, options| issuable_metadata.upvotes }
expose(:downvotes) { |issue, options| issuable_metadata(issue, options, :downvotes) } expose(:downvotes) { |issue, options| issuable_metadata.downvotes }
expose :due_date expose :due_date
expose :confidential expose :confidential
expose :discussion_locked expose :discussion_locked
......
...@@ -27,6 +27,7 @@ module Gitlab ...@@ -27,6 +27,7 @@ module Gitlab
end end
def objects(scope, page: nil, per_page: DEFAULT_PER_PAGE, without_count: true, preload_method: nil) def objects(scope, page: nil, per_page: DEFAULT_PER_PAGE, without_count: true, preload_method: nil)
should_preload = preload_method.present?
collection = case scope collection = case scope
when 'projects' when 'projects'
projects projects
...@@ -39,9 +40,11 @@ module Gitlab ...@@ -39,9 +40,11 @@ module Gitlab
when 'users' when 'users'
users users
else else
should_preload = false
Kaminari.paginate_array([]) Kaminari.paginate_array([])
end end
collection = collection.public_send(preload_method) if should_preload # rubocop:disable GitlabSecurity/PublicSend
collection = collection.page(page).per(per_page) collection = collection.page(page).per(per_page)
without_count ? collection.without_count : collection 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