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
07fc2f85
Commit
07fc2f85
authored
Aug 09, 2016
by
Z.J. van de Weg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Method names changed to #includes_commit?
parent
03ea0194
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
60 additions
and
29 deletions
+60
-29
app/assets/stylesheets/pages/merge_requests.scss
app/assets/stylesheets/pages/merge_requests.scss
+4
-1
app/models/deployment.rb
app/models/deployment.rb
+1
-2
app/models/environment.rb
app/models/environment.rb
+2
-2
app/models/merge_request.rb
app/models/merge_request.rb
+3
-1
app/views/projects/merge_requests/widget/_heading.html.haml
app/views/projects/merge_requests/widget/_heading.html.haml
+6
-3
db/schema.rb
db/schema.rb
+1
-1
spec/models/deployment_spec.rb
spec/models/deployment_spec.rb
+8
-5
spec/models/environment_spec.rb
spec/models/environment_spec.rb
+27
-4
spec/models/merge_request_spec.rb
spec/models/merge_request_spec.rb
+4
-7
spec/views/projects/merge_requests/_heading.html.haml_spec.rb
.../views/projects/merge_requests/_heading.html.haml_spec.rb
+4
-3
No files found.
app/assets/stylesheets/pages/merge_requests.scss
View file @
07fc2f85
...
...
@@ -69,6 +69,10 @@
&
.ci-success
{
color
:
$gl-success
;
a
.environment
{
color
:
inherit
;
}
}
&
.ci-success_with_warnings
{
...
...
@@ -126,7 +130,6 @@
&
.has-conflicts
.fa-exclamation-triangle
{
color
:
$gl-warning
;
}
}
p
:last-child
{
...
...
app/models/deployment.rb
View file @
07fc2f85
...
...
@@ -37,8 +37,7 @@ class Deployment < ActiveRecord::Base
deployable
.
try
(
:other_actions
)
end
def
deployed_to?
(
ref
)
commit
=
project
.
commit
(
ref
)
def
includes_commit?
(
commit
)
return
false
unless
commit
project
.
repository
.
is_ancestor?
(
commit
.
id
,
sha
)
...
...
app/models/environment.rb
View file @
07fc2f85
...
...
@@ -26,9 +26,9 @@ class Environment < ActiveRecord::Base
self
.
external_url
=
nil
if
self
.
external_url
.
blank?
end
def
deployed_from?
(
ref
)
def
includes_commit?
(
commit
)
return
false
unless
last_deployment
last_deployment
.
deployed_to?
(
ref
)
last_deployment
.
includes_commit?
(
commit
)
end
end
app/models/merge_request.rb
View file @
07fc2f85
...
...
@@ -591,8 +591,10 @@ class MergeRequest < ActiveRecord::Base
end
def
environments
return
unless
diff_head_commit
target_project
.
environments
.
select
do
|
environment
|
environment
.
deployed_from?
(
ref_path
)
environment
.
includes_commit?
(
diff_head_commit
)
end
end
...
...
app/views/projects/merge_requests/widget/_heading.html.haml
View file @
07fc2f85
...
...
@@ -45,10 +45,13 @@
-
@merge_request
.
environments
.
each
do
|
environment
|
.mr-widget-heading
.ci_widget
{
class:
"ci-success"
}
.ci_widget
.ci-success
=
ci_icon_for_status
(
"success"
)
%span
.hidden-sm
Released to
#{
environment
.
name
}
.
Deployed to
=
succeed
'.'
do
=
link_to
environment
.
name
,
namespace_project_environment_path
(
@project
.
namespace
,
@project
,
environment
),
class:
'environment'
-
external_url
=
environment
.
external_url
-
if
external_url
=
link_to
icon
(
'external-link'
,
text:
"View on
#{
external_url
.
gsub
(
/\A.*?:\/\//
,
''
)
}
"
),
external_url
=
link_to
external_url
,
target:
'_blank'
do
=
icon
(
'external-link'
,
text:
"View on
#{
external_url
.
gsub
(
/\A.*?:\/\//
,
''
)
}
"
,
right:
true
)
db/schema.rb
View file @
07fc2f85
...
...
@@ -589,12 +589,12 @@ ActiveRecord::Schema.define(version: 20160810142633) do
t
.
datetime
"locked_at"
t
.
integer
"updated_by_id"
t
.
string
"merge_error"
t
.
text
"merge_params"
t
.
boolean
"merge_when_build_succeeds"
,
default:
false
,
null:
false
t
.
integer
"merge_user_id"
t
.
string
"merge_commit_sha"
t
.
datetime
"deleted_at"
t
.
string
"in_progress_merge_commit_sha"
t
.
text
"merge_params"
end
add_index
"merge_requests"
,
[
"assignee_id"
],
name:
"index_merge_requests_on_assignee_id"
,
using: :btree
...
...
spec/models/deployment_spec.rb
View file @
07fc2f85
...
...
@@ -16,23 +16,26 @@ describe Deployment, models: true do
it
{
is_expected
.
to
validate_presence_of
(
:ref
)
}
it
{
is_expected
.
to
validate_presence_of
(
:sha
)
}
describe
'#
deployed_to
?'
do
describe
'#
includes_commit
?'
do
let
(
:project
)
{
create
(
:project
)
}
let
(
:environment
)
{
create
(
:environment
,
project:
project
)
}
let
(
:deployment
)
do
create
(
:deployment
,
environment:
environment
,
sha:
'5f923865dde3436854e9ceb9cdb7815618d4e849'
)
create
(
:deployment
,
environment:
environment
,
sha:
project
.
commit
.
id
)
end
context
'when there is no project commit'
do
it
'returns false'
do
expect
(
deployment
.
deployed_to?
(
'random-branch'
)).
to
be
false
commit
=
project
.
commit
(
'feature'
)
expect
(
deployment
.
includes_commit?
(
commit
)).
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
commit
=
project
.
commit
expect
(
deployment
.
includes_commit?
(
commit
)).
to
be
true
end
end
end
...
...
spec/models/environment_spec.rb
View file @
07fc2f85
...
...
@@ -31,12 +31,35 @@ describe Environment, models: true do
end
end
describe
'#deployed_from?'
do
let
(
:environment
)
{
create
(
:environment
)
}
describe
'#includes_commit?'
do
context
'without a last deployment'
do
it
"returns false"
do
expect
(
environment
.
deployed_from?
(
'HEAD'
)).
to
be
false
expect
(
environment
.
includes_commit?
(
'HEAD'
)).
to
be
false
end
end
context
'with a last deployment'
do
let
(
:project
)
{
create
(
:project
)
}
let
(
:environment
)
{
create
(
:environment
,
project:
project
)
}
let!
(
:deployment
)
do
create
(
:deployment
,
environment:
environment
,
sha:
project
.
commit
(
'master'
).
id
)
end
context
'in the same branch'
do
it
'returns true'
do
expect
(
environment
.
includes_commit?
(
RepoHelpers
.
sample_commit
)).
to
be
true
end
end
context
'not in the same branch'
do
before
do
deployment
.
update
(
sha:
project
.
commit
(
'feature'
).
id
)
end
it
'returns false'
do
expect
(
environment
.
includes_commit?
(
RepoHelpers
.
sample_commit
)).
to
be
false
end
end
end
end
...
...
spec/models/merge_request_spec.rb
View file @
07fc2f85
...
...
@@ -676,18 +676,15 @@ describe MergeRequest, models: true do
describe
"#environments"
do
let
(
:project
)
{
create
(
:project
)
}
let!
(
:deployment
)
do
create
(
:deployment
,
environment:
environment
,
sha:
'5f923865dde3436854e9ceb9cdb7815618d4e849'
)
end
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
)
expect
(
merge_request
.
environments
).
to
eq
[
environment
]
end
end
...
...
spec/views/projects/merge_requests/_heading.html.haml_spec.rb
View file @
07fc2f85
...
...
@@ -8,18 +8,19 @@ describe 'projects/merge_requests/widget/_heading' do
let
(
:merge_request
)
{
create
(
:merge_request
,
:merged
)
}
let
(
:environment
)
{
create
(
:environment
,
project:
project
)
}
let!
(
:deployment
)
do
create
(
:deployment
,
environment:
environment
,
sha:
'a5391128b0ef5d21df5dd23d98557f4ef12fae20'
)
create
(
:deployment
,
environment:
environment
,
sha:
project
.
commit
(
'master'
).
id
)
end
before
do
assign
(
:merge_request
,
merge_request
)
assign
(
:project
,
project
)
render
end
it
'displays that the environment is deployed'
do
expect
(
rendered
).
to
match
(
"Released to
#{
environment
.
name
}
"
)
expect
(
rendered
).
to
match
(
"Deployed to"
)
expect
(
rendered
).
to
match
(
"
#{
environment
.
name
}
"
)
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