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
21f3e9ce
Commit
21f3e9ce
authored
May 08, 2017
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move custom compound status method to commit status
parent
64e09a1b
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
31 additions
and
3 deletions
+31
-3
app/models/commit_status.rb
app/models/commit_status.rb
+6
-0
app/models/concerns/has_status.rb
app/models/concerns/has_status.rb
+1
-3
spec/models/commit_status_spec.rb
spec/models/commit_status_spec.rb
+24
-0
No files found.
app/models/commit_status.rb
View file @
21f3e9ce
...
@@ -103,6 +103,12 @@ class CommitStatus < ActiveRecord::Base
...
@@ -103,6 +103,12 @@ class CommitStatus < ActiveRecord::Base
end
end
end
end
def
self
.
status
super
.
tap
do
|
status
|
return
'success'
if
status
==
'skipped'
&&
all
.
failed_but_allowed
.
any?
end
end
def
locking_enabled?
def
locking_enabled?
status_changed?
status_changed?
end
end
...
...
app/models/concerns/has_status.rb
View file @
21f3e9ce
...
@@ -37,9 +37,7 @@ module HasStatus
...
@@ -37,9 +37,7 @@ module HasStatus
end
end
def
status
def
status
all
.
pluck
(
status_sql
).
first
.
tap
do
|
status
|
all
.
pluck
(
status_sql
).
first
return
'success'
if
status
==
'skipped'
&&
all
.
failed_but_allowed
.
any?
end
end
end
def
started_at
def
started_at
...
...
spec/models/commit_status_spec.rb
View file @
21f3e9ce
...
@@ -284,6 +284,30 @@ describe CommitStatus, :models do
...
@@ -284,6 +284,30 @@ describe CommitStatus, :models do
end
end
end
end
describe
'.status'
do
context
'when there are multiple statuses present'
do
before
do
create_status
(
status:
'running'
)
create_status
(
status:
'success'
)
create_status
(
allow_failure:
true
,
status:
'failed'
)
end
it
'returns a correct compound status'
do
expect
(
described_class
.
all
.
status
).
to
eq
'running'
end
end
context
'when there are only allowed to fail commit statuses present'
do
before
do
create_status
(
allow_failure:
true
,
status:
'failed'
)
end
it
'returns status that indicates success'
do
expect
(
described_class
.
all
.
status
).
to
eq
'success'
end
end
end
describe
'#before_sha'
do
describe
'#before_sha'
do
subject
{
commit_status
.
before_sha
}
subject
{
commit_status
.
before_sha
}
...
...
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