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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
c8286886
Commit
c8286886
authored
Sep 17, 2020
by
Kamil Trzciński
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add feature flag and specs
Cover `Bridge::Common` with tests and additional feature flag
parent
bc050db6
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
70 additions
and
4 deletions
+70
-4
config/feature_flags/development/ci_bridge_pipeline_details.yml
.../feature_flags/development/ci_bridge_pipeline_details.yml
+7
-0
lib/gitlab/ci/status/bridge/common.rb
lib/gitlab/ci/status/bridge/common.rb
+14
-4
spec/lib/gitlab/ci/status/bridge/common_spec.rb
spec/lib/gitlab/ci/status/bridge/common_spec.rb
+49
-0
No files found.
config/feature_flags/development/ci_bridge_pipeline_details.yml
0 → 100644
View file @
c8286886
---
name
:
ci_bridge_pipeline_details
introduced_by_url
:
https://gitlab.com/gitlab-org/gitlab/-/merge_requests/41263
rollout_issue_url
:
https://gitlab.com/gitlab-org/gitlab/-/issues/250683
group
:
group::memory
type
:
development
default_enabled
:
true
lib/gitlab/ci/status/bridge/common.rb
View file @
c8286886
...
@@ -10,19 +10,29 @@ module Gitlab
...
@@ -10,19 +10,29 @@ module Gitlab
end
end
def
has_details?
def
has_details?
can?
(
user
,
:read_pipeline
,
subject
.
downstream_pipeline
)
!!
details_path
end
end
def
details_path
def
details_path
return
unless
subject
.
downstream_pipeline
return
unless
Feature
.
enabled?
(
:ci_bridge_pipeline_details
,
subject
.
project
,
default_enabled:
true
)
return
unless
can?
(
user
,
:read_pipeline
,
downstream_pipeline
)
pipeline
=
subject
.
downstream_pipeline
project_pipeline_path
(
downstream_project
,
downstream_pipeline
)
project_pipeline_path
(
pipeline
.
project
,
pipeline
)
end
end
def
has_action?
def
has_action?
false
false
end
end
private
def
downstream_pipeline
subject
.
downstream_pipeline
end
def
downstream_project
downstream_pipeline
&
.
project
end
end
end
end
end
end
end
...
...
spec/lib/gitlab/ci/status/bridge/common_spec.rb
0 → 100644
View file @
c8286886
# frozen_string_literal: true
require
'spec_helper'
RSpec
.
describe
Gitlab
::
Ci
::
Status
::
Bridge
::
Common
do
let_it_be
(
:user
)
{
create
(
:user
)
}
let_it_be
(
:bridge
)
{
create
(
:ci_bridge
)
}
let_it_be
(
:downstream_pipeline
)
{
create
(
:ci_pipeline
)
}
before_all
do
create
(
:ci_sources_pipeline
,
source_pipeline:
bridge
.
pipeline
,
source_project:
bridge
.
pipeline
.
project
,
source_job:
bridge
,
pipeline:
downstream_pipeline
,
project:
downstream_pipeline
.
project
)
end
subject
do
Gitlab
::
Ci
::
Status
::
Core
.
new
(
bridge
,
user
)
.
extend
(
described_class
)
end
describe
'#details_path'
do
context
'when user has access to read downstream pipeline'
do
before
do
downstream_pipeline
.
project
.
add_developer
(
user
)
end
it
{
expect
(
subject
).
to
have_details
}
it
{
expect
(
subject
.
details_path
).
to
include
"pipelines/
#{
downstream_pipeline
.
id
}
"
}
context
'when ci_bridge_pipeline_details is disabled'
do
before
do
stub_feature_flags
(
ci_bridge_pipeline_details:
false
)
end
it
{
expect
(
subject
).
not_to
have_details
}
it
{
expect
(
subject
.
details_path
).
to
be_nil
}
end
end
context
'when user does not have access to read downstream pipeline'
do
it
{
expect
(
subject
).
not_to
have_details
}
it
{
expect
(
subject
.
details_path
).
to
be_nil
}
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