Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
45293f66
Commit
45293f66
authored
Apr 01, 2019
by
Francisco Javier López
Committed by
Nick Thomas
Apr 01, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix MergeRequest#has_commits? nil comparison
parent
0a480e3c
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
4 deletions
+11
-4
app/models/merge_request.rb
app/models/merge_request.rb
+1
-1
spec/models/merge_request_spec.rb
spec/models/merge_request_spec.rb
+10
-3
No files found.
app/models/merge_request.rb
View file @
45293f66
...
...
@@ -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?
...
...
spec/models/merge_request_spec.rb
View file @
45293f66
...
...
@@ -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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment