Commit 2514cd9c authored by Alishan Ladhani's avatar Alishan Ladhani

Format the number of commit results according to convention

parent 6668e7eb
......@@ -37,7 +37,7 @@ module Gitlab
when 'wiki_blobs'
wiki_blobs_count.to_s
when 'commits'
commits_count.to_s
formatted_limited_count(commits_count)
else
super
end
......@@ -72,7 +72,7 @@ module Gitlab
end
def commits_count
@commits_count ||= commits.count
@commits_count ||= commits(limit: count_limit).count
end
def single_commit_result?
......@@ -145,7 +145,7 @@ module Gitlab
end
# rubocop: enable CodeReuse/ActiveRecord
def commits(limit: count_limit)
def commits(limit:)
@commits ||= find_commits(query, limit: limit)
end
......
......@@ -34,7 +34,7 @@ describe Gitlab::ProjectSearchResults do
'blobs' | :limited_blobs_count | max_limited_count
'notes' | :limited_notes_count | max_limited_count
'wiki_blobs' | :wiki_blobs_count | '1234'
'commits' | :commits_count | '1234'
'commits' | :commits_count | max_limited_count
'projects' | :limited_projects_count | max_limited_count
'unknown' | nil | nil
end
......@@ -386,6 +386,19 @@ describe Gitlab::ProjectSearchResults do
end
end
describe '#commits_count' do
let(:project) { create(:project, :public, :repository) }
it 'limits the number of commits requested' do
expect(project.repository)
.to receive(:find_commits_by_message)
.with(anything, anything, anything, described_class::COUNT_LIMIT)
.and_call_original
described_class.new(user, project, '.').commits_count
end
end
# Examples for commit access level test
#
# params:
......
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