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
0
Merge Requests
0
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
Boxiang Sun
gitlab-ce
Commits
6987ec29
Commit
6987ec29
authored
Sep 22, 2016
by
Lin Jen-Shin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
For empty merge_request_diff st_commits would be nil
Closes #22438
parent
73b4eecd
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
7 deletions
+24
-7
app/models/merge_request_diff.rb
app/models/merge_request_diff.rb
+3
-1
spec/models/merge_request_spec.rb
spec/models/merge_request_spec.rb
+21
-6
No files found.
app/models/merge_request_diff.rb
View file @
6987ec29
...
@@ -120,8 +120,10 @@ class MergeRequestDiff < ActiveRecord::Base
...
@@ -120,8 +120,10 @@ class MergeRequestDiff < ActiveRecord::Base
def
commits_sha
def
commits_sha
if
@commits
if
@commits
commits
.
map
(
&
:sha
)
commits
.
map
(
&
:sha
)
els
e
els
if
st_commits
st_commits
.
map
{
|
commit
|
commit
[
:id
]
}
st_commits
.
map
{
|
commit
|
commit
[
:id
]
}
else
[]
end
end
end
end
...
...
spec/models/merge_request_spec.rb
View file @
6987ec29
...
@@ -517,7 +517,7 @@ describe MergeRequest, models: true do
...
@@ -517,7 +517,7 @@ describe MergeRequest, models: true do
context
'with multiple irrelevant merge_request_diffs'
do
context
'with multiple irrelevant merge_request_diffs'
do
before
do
before
do
subject
.
update
(
target_branch:
'
markdown
'
)
subject
.
update
(
target_branch:
'
v1.0.0
'
)
end
end
it_behaves_like
'returning pipelines with proper ordering'
it_behaves_like
'returning pipelines with proper ordering'
...
@@ -544,16 +544,31 @@ describe MergeRequest, models: true do
...
@@ -544,16 +544,31 @@ describe MergeRequest, models: true do
subject
.
merge_request_diffs
.
flat_map
(
&
:commits
).
map
(
&
:sha
).
uniq
subject
.
merge_request_diffs
.
flat_map
(
&
:commits
).
map
(
&
:sha
).
uniq
end
end
before
do
shared_examples
'returning all SHA'
do
subject
.
update
(
target_branch:
'markdown'
)
end
it
'returns all SHA from all merge_request_diffs'
do
it
'returns all SHA from all merge_request_diffs'
do
expect
(
subject
.
merge_request_diffs
.
size
).
to
eq
(
2
)
expect
(
subject
.
merge_request_diffs
.
size
).
to
eq
(
2
)
expect
(
subject
.
all_commits_sha
).
to
eq
(
all_commits_sha
)
expect
(
subject
.
all_commits_sha
).
to
eq
(
all_commits_sha
)
end
end
end
end
context
'with a completely different branch'
do
before
do
subject
.
update
(
target_branch:
'v1.0.0'
)
end
it_behaves_like
'returning all SHA'
end
context
'with a branch having no difference'
do
before
do
subject
.
update
(
target_branch:
'v1.1.0'
)
subject
.
reload
# make sure commits were not cached
end
it_behaves_like
'returning all SHA'
end
end
describe
'#participants'
do
describe
'#participants'
do
let
(
:project
)
{
create
(
:project
,
:public
)
}
let
(
:project
)
{
create
(
:project
,
:public
)
}
...
...
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