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
8faf0c7a
Commit
8faf0c7a
authored
Jan 17, 2017
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add detailed statuses for external commit statuses
parent
2d6d52ca
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
112 additions
and
0 deletions
+112
-0
lib/gitlab/ci/status/external/common.rb
lib/gitlab/ci/status/external/common.rb
+22
-0
lib/gitlab/ci/status/external/factory.rb
lib/gitlab/ci/status/external/factory.rb
+13
-0
spec/lib/gitlab/ci/status/external/common_spec.rb
spec/lib/gitlab/ci/status/external/common_spec.rb
+39
-0
spec/lib/gitlab/ci/status/external/factory_spec.rb
spec/lib/gitlab/ci/status/external/factory_spec.rb
+38
-0
No files found.
lib/gitlab/ci/status/external/common.rb
0 → 100644
View file @
8faf0c7a
module
Gitlab
module
Ci
module
Status
module
External
module
Common
def
has_details?
can?
(
user
,
:read_commit_status
,
subject
)
&&
subject
.
target_url
.
present?
end
def
details_path
subject
.
target_url
end
def
has_action?
false
end
end
end
end
end
end
lib/gitlab/ci/status/external/factory.rb
0 → 100644
View file @
8faf0c7a
module
Gitlab
module
Ci
module
Status
module
External
class
Factory
<
Status
::
Factory
def
self
.
common_helpers
Status
::
External
::
Common
end
end
end
end
end
end
spec/lib/gitlab/ci/status/external/common_spec.rb
0 → 100644
View file @
8faf0c7a
require
'spec_helper'
describe
Gitlab
::
Ci
::
Status
::
External
::
Common
do
let
(
:user
)
{
create
(
:user
)
}
let
(
:project
)
{
external_status
.
project
}
let
(
:external_target_url
)
{
'http://example.gitlab.com/status'
}
let
(
:external_status
)
do
create
(
:generic_commit_status
,
target_url:
external_target_url
)
end
subject
do
Gitlab
::
Ci
::
Status
::
Core
.
new
(
external_status
,
user
)
.
extend
(
described_class
)
end
describe
'#has_action?'
do
it
{
is_expected
.
not_to
have_action
}
end
describe
'#has_details?'
do
context
'when user has access to read commit status'
do
before
{
project
.
team
<<
[
user
,
:developer
]
}
it
{
is_expected
.
to
have_details
}
end
context
'when user does not have access to read commit status'
do
it
{
is_expected
.
not_to
have_details
}
end
end
describe
'#details_path'
do
it
'links to the external target URL'
do
expect
(
subject
.
details_path
).
to
eq
external_target_url
end
end
end
spec/lib/gitlab/ci/status/external/factory_spec.rb
0 → 100644
View file @
8faf0c7a
require
'spec_helper'
describe
Gitlab
::
Ci
::
Status
::
External
::
Factory
do
let
(
:user
)
{
create
(
:user
)
}
let
(
:project
)
{
resource
.
project
}
let
(
:status
)
{
factory
.
fabricate!
}
let
(
:factory
)
{
described_class
.
new
(
resource
,
user
)
}
let
(
:external_url
)
{
'http://gitlab.com/status'
}
before
do
project
.
team
<<
[
user
,
:developer
]
end
context
'when external status has a simple core status'
do
HasStatus
::
AVAILABLE_STATUSES
.
each
do
|
simple_status
|
context
"when core status is
#{
simple_status
}
"
do
let
(
:resource
)
do
create
(
:generic_commit_status
,
status:
simple_status
,
target_url:
external_url
)
end
let
(
:expected_status
)
do
Gitlab
::
Ci
::
Status
.
const_get
(
simple_status
.
capitalize
)
end
it
"fabricates a core status
#{
simple_status
}
"
do
expect
(
status
).
to
be_a
expected_status
end
it
'extends core status with common methods'
do
expect
(
status
).
to
have_details
expect
(
status
).
not_to
have_action
expect
(
status
.
details_path
).
to
eq
external_url
end
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