Commit 45293f66 authored by Francisco Javier López's avatar Francisco Javier López Committed by Nick Thomas

Fix MergeRequest#has_commits? nil comparison

parent 0a480e3c
......@@ -1343,7 +1343,7 @@ class MergeRequest < ApplicationRecord
end
def has_commits?
merge_request_diff && commits_count > 0
merge_request_diff && commits_count.to_i > 0
end
def has_no_commits?
......
......@@ -2714,14 +2714,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
......
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