Skip to content
Snippets Groups Projects
Commit 52778632 authored by Nick Thomas's avatar Nick Thomas Committed by GitLab Release Tools Bot
Browse files

Merge branch 'fj-59547-fix-has-commits' into 'master'

Fix MergeRequest#has_commits? nil comparison

Closes #59547

See merge request gitlab-org/gitlab-ce!26828

(cherry picked from commit b224efe7)

6645b825 Fix MergeRequest#commits_count nil comparison
parent c044bfe8
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -1301,7 +1301,7 @@ class MergeRequest < ActiveRecord::Base
end
 
def has_commits?
merge_request_diff && commits_count > 0
merge_request_diff && commits_count.to_i > 0
end
 
def has_no_commits?
Loading
Loading
Loading
Loading
@@ -2613,14 +2613,21 @@ describe MergeRequest do
end
 
describe '#has_commits?' do
before do
it 'returns true when merge request diff has commits' do
allow(subject.merge_request_diff).to receive(:commits_count)
.and_return(2)
end
 
it 'returns true when merge request diff has commits' do
expect(subject.has_commits?).to be_truthy
end
context 'when commits_count is nil' do
it 'returns false' do
allow(subject.merge_request_diff).to receive(:commits_count)
.and_return(nil)
expect(subject.has_commits?).to be_falsey
end
end
end
 
describe '#has_no_commits?' do
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment