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
Jérome Perrin
gitlab-ce
Commits
6d19e13d
Commit
6d19e13d
authored
May 13, 2016
by
Kamil Trzcinski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix specs
parent
c1bc5c58
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
17 additions
and
32 deletions
+17
-32
app/models/commit_status.rb
app/models/commit_status.rb
+3
-8
app/models/project.rb
app/models/project.rb
+1
-1
app/views/projects/ci/commits/_commit.html.haml
app/views/projects/ci/commits/_commit.html.haml
+1
-2
spec/features/pipelines_spec.rb
spec/features/pipelines_spec.rb
+12
-9
spec/models/commit_status_spec.rb
spec/models/commit_status_spec.rb
+0
-12
No files found.
app/models/commit_status.rb
View file @
6d19e13d
...
...
@@ -92,16 +92,11 @@ class CommitStatus < ActiveRecord::Base
def
self
.
stages
# We group by stage name, but order stages by theirs' index
unscoped
.
from
(
all
,
:sg
).
group
(
'stage'
).
order
(
'max(stage_idx)'
,
'stage'
).
pluck
(
'sg.
stage'
)
unscoped
.
where
(
id:
all
).
group
(
'stage'
).
order
(
'max(stage_idx)'
,
'stage'
).
pluck
(
'
stage'
)
end
def
self
.
stages_status
# We execute subquery for each stage to calculate a stage status
statuses
=
unscoped
.
from
(
all
,
:sg
).
group
(
'stage'
).
pluck
(
'sg.stage'
,
all
.
where
(
'stage=sg.stage'
).
status_sql
)
statuses
.
inject
({})
do
|
h
,
k
|
h
[
k
.
first
]
=
k
.
last
h
end
def
self
.
status_for_stage
(
stage
)
where
(
stage:
stage
).
status
end
def
ignored?
...
...
app/models/project.rb
View file @
6d19e13d
...
...
@@ -354,7 +354,7 @@ class Project < ActiveRecord::Base
join_body
=
"INNER JOIN (
SELECT project_id, COUNT(*) AS amount
FROM notes
WHERE created_at >=
#{
sanitize
(
since
)
}
project.ci_commits
WHERE created_at >=
#{
sanitize
(
since
)
}
GROUP BY project_id
) join_note_counts ON projects.id = join_note_counts.project_id"
...
...
app/views/projects/ci/commits/_commit.html.haml
View file @
6d19e13d
...
...
@@ -31,10 +31,9 @@
Cant find HEAD commit for this branch
-
stages_status
=
commit
.
statuses
.
stages_status
-
stages
.
each
do
|
stage
|
%td
-
if
status
=
stages_status
[
stage
]
-
if
status
=
commit
.
statuses
.
status_for_stage
(
stage
)
-
tooltip
=
"
#{
stage
.
titleize
}
:
#{
status
}
"
%span
.has-tooltip
(
title=
"#{tooltip}"
)
{
class:
"ci-status-icon-#{status}"
}
=
ci_icon_for_status
(
status
)
...
...
spec/features/pipelines_spec.rb
View file @
6d19e13d
...
...
@@ -52,15 +52,15 @@ describe "Pipelines" do
before
{
click_link
(
'Retry'
)
}
it
{
expect
(
page
).
to_not
have_link
(
'Retry'
)
}
it
{
expect
(
page
).
to
have_selector
(
'.ci-
runn
ing'
)
}
it
{
expect
(
page
).
to
have_selector
(
'.ci-
pend
ing'
)
}
end
end
context
'downloadable pipelines'
do
before
{
visit
namespace_project_pipelines_path
(
project
.
namespace
,
project
)
}
context
'with artifacts'
do
let!
(
:with_artifacts
)
{
create
(
:ci_build
,
:success
,
:artifacts
,
commit:
pipeline
,
name:
'rspec tests'
,
stage:
'test'
)
}
let!
(
:with_artifacts
)
{
create
(
:ci_build
,
:artifacts
,
:success
,
commit:
pipeline
,
name:
'rspec tests'
,
stage:
'test'
)
}
before
{
visit
namespace_project_pipelines_path
(
project
.
namespace
,
project
)
}
it
{
expect
(
page
).
to
have_selector
(
'.build-artifacts'
)
}
it
{
expect
(
page
).
to
have_link
(
with_artifacts
.
name
)
}
...
...
@@ -78,10 +78,10 @@ describe "Pipelines" do
let
(
:pipeline
)
{
create
(
:ci_commit
,
project:
project
,
ref:
'master'
)
}
before
do
@success
=
create
(
:ci_build
,
:success
,
commit:
pipeline
,
stage:
'build'
)
@failed
=
create
(
:ci_build
,
:failed
,
commit:
pipeline
,
stage:
'test'
,
commands:
'test'
)
@running
=
create
(
:ci_build
,
:running
,
commit:
pipeline
,
stage:
'deploy'
)
@external
=
create
(
:generic_commit_status
,
:success
,
commit:
pipeline
,
stage:
'external'
)
@success
=
create
(
:ci_build
,
:success
,
commit:
pipeline
,
stage:
'build'
,
name:
'build'
)
@failed
=
create
(
:ci_build
,
:failed
,
commit:
pipeline
,
stage:
'test'
,
name:
'test'
,
commands:
'test'
)
@running
=
create
(
:ci_build
,
:running
,
commit:
pipeline
,
stage:
'deploy'
,
name:
'deploy'
)
@external
=
create
(
:generic_commit_status
,
status:
'success'
,
commit:
pipeline
,
name:
'jenkins'
,
stage:
'external'
)
end
before
{
visit
namespace_project_pipeline_path
(
project
.
namespace
,
project
,
pipeline
)
}
...
...
@@ -126,7 +126,10 @@ describe "Pipelines" do
before
{
visit
new_namespace_project_pipeline_path
(
project
.
namespace
,
project
)
}
context
'for valid commit'
do
before
{
fill_in
(
'Create for'
,
with:
'master'
)
}
before
do
fill_in
(
'Create for'
,
with:
'master'
)
stub_ci_commit_to_return_yaml_file
end
it
{
expect
{
click_on
'Create pipeline'
}.
to
change
{
Ci
::
Commit
.
count
}.
by
(
1
)
}
end
...
...
spec/models/commit_status_spec.rb
View file @
6d19e13d
...
...
@@ -219,17 +219,5 @@ describe CommitStatus, models: true do
is_expected
.
to
eq
(
%w(build test deploy)
)
end
end
context
'stages with statuses'
do
subject
{
CommitStatus
.
where
(
commit:
commit
).
stages_status
}
it
'return list of stages with statuses'
do
is_expected
.
to
eq
({
'build'
=>
'failed'
,
'test'
=>
'success'
,
'deploy'
=>
'running'
})
end
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