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
Léo-Paul Géneau
gitlab-ce
Commits
73269b58
Commit
73269b58
authored
Sep 16, 2016
by
Rémy Coutable
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
MergeRequest#environments now returns an empty array when diff_head_commit is nil
Signed-off-by:
Rémy Coutable
<
remy@rymai.me
>
parent
1038ef54
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
7 deletions
+15
-7
app/models/merge_request.rb
app/models/merge_request.rb
+1
-1
spec/models/merge_request_spec.rb
spec/models/merge_request_spec.rb
+14
-6
No files found.
app/models/merge_request.rb
View file @
73269b58
...
...
@@ -652,7 +652,7 @@ class MergeRequest < ActiveRecord::Base
end
def
environments
return
unless
diff_head_commit
return
[]
unless
diff_head_commit
target_project
.
environments
.
select
do
|
environment
|
environment
.
includes_commit?
(
diff_head_commit
)
...
...
spec/models/merge_request_spec.rb
View file @
73269b58
...
...
@@ -703,16 +703,24 @@ describe MergeRequest, models: true do
describe
"#environments"
do
let
(
:project
)
{
create
(
:project
)
}
let!
(
:environment
)
{
create
(
:environment
,
project:
project
)
}
let!
(
:environment1
)
{
create
(
:environment
,
project:
project
)
}
let!
(
:environment2
)
{
create
(
:environment
,
project:
project
)
}
let
(
:merge_request
)
{
create
(
:merge_request
,
source_project:
project
)
}
it
'selects deployed environments'
do
create
(
:deployment
,
environment:
environment
,
sha:
project
.
commit
(
'master'
).
id
)
create
(
:deployment
,
environment:
environment1
,
sha:
project
.
commit
(
'feature'
).
id
)
environments
=
create_list
(
:environment
,
3
,
project:
project
)
create
(
:deployment
,
environment:
environments
.
first
,
sha:
project
.
commit
(
'master'
).
id
)
create
(
:deployment
,
environment:
environments
.
second
,
sha:
project
.
commit
(
'feature'
).
id
)
expect
(
merge_request
.
environments
).
to
eq
[
environment
]
expect
(
merge_request
.
environments
).
to
eq
[
environments
.
first
]
end
context
'without a diff_head_commit'
do
before
do
expect
(
merge_request
).
to
receive
(
:diff_head_commit
).
and_return
(
nil
)
end
it
'returns an empty array'
do
expect
(
merge_request
.
environments
).
to
be_empty
end
end
end
...
...
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