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
b497b0ce
Commit
b497b0ce
authored
Aug 03, 2016
by
Z.J. van de Weg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Incorporate feedback
parent
826862d4
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
56 additions
and
9 deletions
+56
-9
CHANGELOG
CHANGELOG
+1
-1
app/models/deployment.rb
app/models/deployment.rb
+2
-2
app/models/environment.rb
app/models/environment.rb
+3
-3
app/models/merge_request.rb
app/models/merge_request.rb
+1
-1
spec/models/deployment_spec.rb
spec/models/deployment_spec.rb
+20
-0
spec/models/environment_spec.rb
spec/models/environment_spec.rb
+10
-0
spec/models/merge_request_spec.rb
spec/models/merge_request_spec.rb
+15
-0
spec/views/projects/merge_requests/_heading.html.haml_spec.rb
.../views/projects/merge_requests/_heading.html.haml_spec.rb
+4
-2
No files found.
CHANGELOG
View file @
b497b0ce
...
@@ -37,7 +37,7 @@ v 8.11.0 (unreleased)
...
@@ -37,7 +37,7 @@ v 8.11.0 (unreleased)
- Update `timeago` plugin to use multiple string/locale settings
- Update `timeago` plugin to use multiple string/locale settings
- Remove unused images (ClemMakesApps)
- Remove unused images (ClemMakesApps)
- Limit git rev-list output count to one in forced push check
- Limit git rev-list output count to one in forced push check
- Show deployment status on merge requests
- Show deployment status on merge requests
with external URLs
- Clean up unused routes (Josef Strzibny)
- Clean up unused routes (Josef Strzibny)
- Fix issue on empty project to allow developers to only push to protected branches if given permission
- Fix issue on empty project to allow developers to only push to protected branches if given permission
- Add green outline to New Branch button. !5447 (winniehell)
- Add green outline to New Branch button. !5447 (winniehell)
...
...
app/models/deployment.rb
View file @
b497b0ce
...
@@ -37,10 +37,10 @@ class Deployment < ActiveRecord::Base
...
@@ -37,10 +37,10 @@ class Deployment < ActiveRecord::Base
deployable
.
try
(
:other_actions
)
deployable
.
try
(
:other_actions
)
end
end
def
deployed_to
(
ref
)
def
deployed_to
?
(
ref
)
commit
=
project
.
commit
(
ref
)
commit
=
project
.
commit
(
ref
)
return
false
unless
commit
return
false
unless
commit
project
.
repository
.
merge_base
(
commit
.
id
,
sha
)
==
commit
.
id
project
.
repository
.
is_ancestor?
(
commit
.
id
,
sha
)
end
end
end
end
app/models/environment.rb
View file @
b497b0ce
...
@@ -26,9 +26,9 @@ class Environment < ActiveRecord::Base
...
@@ -26,9 +26,9 @@ class Environment < ActiveRecord::Base
self
.
external_url
=
nil
if
self
.
external_url
.
blank?
self
.
external_url
=
nil
if
self
.
external_url
.
blank?
end
end
def
deployed_
to
?
(
ref
)
def
deployed_
from
?
(
ref
)
return
unless
last_deployment
return
false
unless
last_deployment
last_deployment
.
deployed_to
(
ref
)
last_deployment
.
deployed_to
?
(
ref
)
end
end
end
end
app/models/merge_request.rb
View file @
b497b0ce
...
@@ -592,7 +592,7 @@ class MergeRequest < ActiveRecord::Base
...
@@ -592,7 +592,7 @@ class MergeRequest < ActiveRecord::Base
def
environments
def
environments
target_project
.
environments
.
select
do
|
environment
|
target_project
.
environments
.
select
do
|
environment
|
environment
.
deployed_
to
?
(
ref_path
)
environment
.
deployed_
from
?
(
ref_path
)
end
end
end
end
...
...
spec/models/deployment_spec.rb
View file @
b497b0ce
...
@@ -15,4 +15,24 @@ describe Deployment, models: true do
...
@@ -15,4 +15,24 @@ describe Deployment, models: true do
it
{
is_expected
.
to
validate_presence_of
(
:ref
)
}
it
{
is_expected
.
to
validate_presence_of
(
:ref
)
}
it
{
is_expected
.
to
validate_presence_of
(
:sha
)
}
it
{
is_expected
.
to
validate_presence_of
(
:sha
)
}
describe
'#deployed_to?'
do
let
(
:project
)
{
create
(
:project
)
}
let
(
:environment
)
{
create
(
:environment
,
project:
project
)
}
let
(
:deployment
)
do
create
(
:deployment
,
environment:
environment
,
sha:
'5f923865dde3436854e9ceb9cdb7815618d4e849'
)
end
context
'when there is no project commit'
do
it
'returns false'
do
expect
(
deployment
.
deployed_to?
(
'random-branch'
)).
to
be
false
end
end
context
'when they share the same tree branch'
do
it
'returns true'
do
expect
(
deployment
.
deployed_to?
(
'HEAD'
)).
to
be
true
end
end
end
end
end
spec/models/environment_spec.rb
View file @
b497b0ce
...
@@ -30,4 +30,14 @@ describe Environment, models: true do
...
@@ -30,4 +30,14 @@ describe Environment, models: true do
expect
(
env
.
external_url
).
to
be_nil
expect
(
env
.
external_url
).
to
be_nil
end
end
end
end
describe
'#deployed_from?'
do
let
(
:environment
)
{
create
(
:environment
)
}
context
'without a last deployment'
do
it
"returns false"
do
expect
(
environment
.
deployed_from?
(
'HEAD'
)).
to
be
false
end
end
end
end
end
spec/models/merge_request_spec.rb
View file @
b497b0ce
...
@@ -674,6 +674,21 @@ describe MergeRequest, models: true do
...
@@ -674,6 +674,21 @@ describe MergeRequest, models: true do
end
end
end
end
describe
"#environments"
do
let
(
:project
)
{
create
(
:project
)
}
let!
(
:deployment
)
{
create
(
:deployment
,
environment:
environment
,
sha:
'5f923865dde3436854e9ceb9cdb7815618d4e849'
)
}
let!
(
:environment
)
{
create
(
:environment
,
project:
project
)
}
let!
(
:environment1
)
{
create
(
:environment
,
project:
project
)
}
let
(
:merge_request
)
{
create
(
:merge_request
,
source_project:
project
)
}
it
'selects deployed environments'
do
expect
(
merge_request
.
environments
).
to
eq
[
environment
]
end
end
describe
"#reload_diff"
do
describe
"#reload_diff"
do
let
(
:note
)
{
create
(
:diff_note_on_merge_request
,
project:
subject
.
project
,
noteable:
subject
)
}
let
(
:note
)
{
create
(
:diff_note_on_merge_request
,
project:
subject
.
project
,
noteable:
subject
)
}
...
...
spec/views/projects/merge_requests/_heading.html.haml_spec.rb
View file @
b497b0ce
...
@@ -7,8 +7,10 @@ describe 'projects/merge_requests/widget/_heading' do
...
@@ -7,8 +7,10 @@ describe 'projects/merge_requests/widget/_heading' do
let
(
:project
)
{
merge_request
.
target_project
}
let
(
:project
)
{
merge_request
.
target_project
}
let
(
:merge_request
)
{
create
(
:merge_request
,
:merged
)
}
let
(
:merge_request
)
{
create
(
:merge_request
,
:merged
)
}
let
(
:environment
)
{
create
(
:environment
,
project:
project
)
}
let
(
:environment
)
{
create
(
:environment
,
project:
project
)
}
let!
(
:deployment
)
{
create
(
:deployment
,
environment:
environment
,
let!
(
:deployment
)
do
sha:
'a5391128b0ef5d21df5dd23d98557f4ef12fae20'
)
}
create
(
:deployment
,
environment:
environment
,
sha:
'a5391128b0ef5d21df5dd23d98557f4ef12fae20'
)
end
before
do
before
do
assign
(
:merge_request
,
merge_request
)
assign
(
:merge_request
,
merge_request
)
...
...
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