BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
52d5d7da
Commit
52d5d7da
authored
Jul 20, 2016
by
Kamil Trzcinski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Create PipelinesSettingsController for showing settings page
parent
7e8ef1b8
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
79 additions
and
61 deletions
+79
-61
pipelines_controller.rb
app/controllers/projects/pipelines_controller.rb
+1
-26
pipelines_settings_controller.rb
app/controllers/projects/pipelines_settings_controller.rb
+33
-0
refs_controller.rb
app/controllers/projects/refs_controller.rb
+1
-1
_project_settings.html.haml
app/views/layouts/nav/_project_settings.html.haml
+2
-2
show.html.haml
app/views/projects/pipelines_settings/show.html.haml
+1
-1
routes.rb
config/routes.rb
+3
-1
pipelines_settings_spec.rb
spec/features/pipelines_settings_spec.rb
+35
-0
pipelines_spec.rb
spec/features/pipelines_spec.rb
+2
-29
list_spec.rb
spec/features/projects/badges/list_spec.rb
+1
-1
No files found.
app/controllers/projects/pipelines_controller.rb
View file @
52d5d7da
class
Projects
::
PipelinesController
<
Projects
::
ApplicationController
before_action
:pipeline
,
except:
[
:index
,
:new
,
:create
,
:settings
,
:update_settings
]
before_action
:pipeline
,
except:
[
:index
,
:new
,
:create
]
before_action
:commit
,
only:
[
:show
]
before_action
:authorize_read_pipeline!
before_action
:authorize_create_pipeline!
,
only:
[
:new
,
:create
]
before_action
:authorize_update_pipeline!
,
only:
[
:retry
,
:cancel
]
before_action
:authorize_admin_pipeline!
,
only:
[
:settings
,
:update_settings
]
def
index
@scope
=
params
[
:scope
]
...
...
@@ -44,36 +43,12 @@ class Projects::PipelinesController < Projects::ApplicationController
redirect_back_or_default
default:
namespace_project_pipelines_path
(
project
.
namespace
,
project
)
end
def
settings
@ref
=
params
[
:ref
]
||
@project
.
default_branch
||
'master'
@build_badge
=
Gitlab
::
Badge
::
Build
.
new
(
@project
,
@ref
)
end
def
update_settings
if
@project
.
update_attributes
(
pipelines_settings_params
)
flash
[
:notice
]
=
"CI/CD Pipelines settings for '
#{
@project
.
name
}
' was successfully updated."
redirect_to
(
settings_namespace_project_pipelines_path
(
@project
.
namespace
,
@project
),
notice:
"CI/CD Pipelines settings for '
#{
@project
.
name
}
' was successfully updated."
)
else
render
'settings'
end
end
private
def
create_params
params
.
require
(
:pipeline
).
permit
(
:ref
)
end
def
pipelines_settings_params
params
.
require
(
:project
).
permit
(
:runners_token
,
:builds_enabled
,
:build_allow_git_fetch
,
:build_timeout_in_minutes
,
:build_coverage_regex
,
:public_builds
)
end
def
pipeline
@pipeline
||=
project
.
pipelines
.
find_by!
(
id:
params
[
:id
])
end
...
...
app/controllers/projects/pipelines_settings_controller.rb
0 → 100644
View file @
52d5d7da
class
Projects
::
PipelinesSettingsController
<
Projects
::
ApplicationController
before_action
:authorize_admin_pipeline!
def
show
@ref
=
params
[
:ref
]
||
@project
.
default_branch
||
'master'
@build_badge
=
Gitlab
::
Badge
::
Build
.
new
(
@project
,
@ref
)
end
def
update
if
@project
.
update_attributes
(
update_params
)
flash
[
:notice
]
=
"CI/CD Pipelines settings for '
#{
@project
.
name
}
' was successfully updated."
redirect_to
(
namespace_project_pipelines_settings_path
(
@project
.
namespace
,
@project
),
notice:
"CI/CD Pipelines settings for '
#{
@project
.
name
}
' was successfully updated."
)
else
render
'index'
end
end
private
def
create_params
params
.
require
(
:pipeline
).
permit
(
:ref
)
end
def
update_params
params
.
require
(
:project
).
permit
(
:runners_token
,
:builds_enabled
,
:build_allow_git_fetch
,
:build_timeout_in_minutes
,
:build_coverage_regex
,
:public_builds
)
end
end
app/controllers/projects/refs_controller.rb
View file @
52d5d7da
...
...
@@ -25,7 +25,7 @@ class Projects::RefsController < Projects::ApplicationController
when
"graphs_commits"
commits_namespace_project_graph_path
(
@project
.
namespace
,
@project
,
@id
)
when
"badges"
settings_namespace_project_pipeline
s_path
(
@project
.
namespace
,
@project
,
ref:
@id
)
namespace_project_pipelines_setting
s_path
(
@project
.
namespace
,
@project
,
ref:
@id
)
else
namespace_project_commits_path
(
@project
.
namespace
,
@project
,
@id
)
end
...
...
app/views/layouts/nav/_project_settings.html.haml
View file @
52d5d7da
...
...
@@ -39,7 +39,7 @@
=
link_to
namespace_project_triggers_path
(
@project
.
namespace
,
@project
),
title:
'Triggers'
do
%span
Triggers
=
nav_link
(
controller: :pipelines
)
do
=
link_to
settings_namespace_project_pipeline
s_path
(
@project
.
namespace
,
@project
),
title:
'CI/CD Pipelines'
do
=
nav_link
(
controller: :pipelines
_settings
)
do
=
link_to
namespace_project_pipelines_setting
s_path
(
@project
.
namespace
,
@project
),
title:
'CI/CD Pipelines'
do
%span
CI/CD Pipelines
app/views/projects/pipelines
/settings
.html.haml
→
app/views/projects/pipelines
_settings/show
.html.haml
View file @
52d5d7da
...
...
@@ -7,7 +7,7 @@
.col-lg-9
%h5
.prepend-top-0
Pipelines
=
form_for
@project
,
url:
settings_namespace_project_pipeline
s_path
(
@project
.
namespace
.
becomes
(
Namespace
),
@project
),
remote:
true
,
authenticity_token:
true
do
|
f
|
=
form_for
@project
,
url:
namespace_project_pipelines_setting
s_path
(
@project
.
namespace
.
becomes
(
Namespace
),
@project
),
remote:
true
,
authenticity_token:
true
do
|
f
|
%fieldset
.builds-feature
-
unless
@repository
.
gitlab_ci_yml
.form-group
...
...
config/routes.rb
View file @
52d5d7da
...
...
@@ -732,7 +732,9 @@ Rails.application.routes.draw do
resources
:triggers
,
only:
[
:index
,
:create
,
:destroy
]
resources
:pipelines
,
only:
[
:index
,
:new
,
:create
,
:show
]
do
resource
:settings
,
only:
[
:index
,
:update
]
collection
do
resource
:pipelines_settings
,
path:
'settings'
,
only:
[
:show
,
:update
]
end
member
do
post
:cancel
...
...
spec/features/pipelines_settings_spec.rb
0 → 100644
View file @
52d5d7da
require
'spec_helper'
feature
"Pipelines settings"
,
feature:
true
do
include
GitlabRoutingHelper
let
(
:project
)
{
create
(
:empty_project
)
}
let
(
:user
)
{
create
(
:user
)
}
let
(
:role
)
{
:developer
}
background
do
login_as
(
user
)
project
.
team
<<
[
user
,
role
]
visit
namespace_project_pipelines_settings_path
(
project
.
namespace
,
project
)
end
context
'for developer'
do
given
(
:role
)
{
:developer
}
scenario
'to be disallowed to view'
do
expect
(
page
.
status_code
).
to
eq
(
404
)
end
end
context
'for master'
do
given
(
:role
)
{
:master
}
scenario
'be allowed to change'
do
fill_in
(
'Test coverage parsing'
,
with:
'coverage_regex'
)
click_on
'Save changes'
expect
(
page
.
status_code
).
to
eq
(
200
)
expect
(
page
).
to
have_field
(
'Test coverage parsing'
,
with:
'coverage_regex'
)
end
end
end
spec/features/pipelines_spec.rb
View file @
52d5d7da
require
'spec_helper'
feature
"Pipelines"
,
feature:
true
do
describe
"Pipelines"
do
include
GitlabRoutingHelper
let
(
:project
)
{
create
(
:empty_project
)
}
let
(
:user
)
{
create
(
:user
)
}
let
(
:role
)
{
:developer
}
before
do
login_as
(
user
)
project
.
team
<<
[
user
,
role
]
project
.
team
<<
[
user
,
:developer
]
end
describe
'GET /:project/pipelines'
do
...
...
@@ -209,30 +208,4 @@ feature "Pipelines", feature: true do
it
{
expect
(
page
).
to
have_content
(
'Reference not found'
)
}
end
end
describe
'Pipelines settings'
do
background
do
visit
settings_namespace_project_pipelines_path
(
project
.
namespace
,
project
)
end
context
'for developer'
do
given
(
:role
)
{
:developer
}
scenario
'to be disallowed to view'
do
expect
(
page
.
status_code
).
to
eq
(
404
)
end
end
context
'for master'
do
given
(
:role
)
{
:master
}
scenario
'be allowed to change'
do
fill_in
(
'Test coverage parsing'
,
with:
'coverage_regex'
)
click_on
'Save changes'
expect
(
page
.
status_code
).
to
eq
(
200
)
expect
(
page
).
to
have_field
(
'Test coverage parsing'
,
with:
'coverage_regex'
)
end
end
end
end
spec/features/projects/badges/list_spec.rb
View file @
52d5d7da
...
...
@@ -6,7 +6,7 @@ feature 'list of badges' do
project
=
create
(
:project
)
project
.
team
<<
[
user
,
:master
]
login_as
(
user
)
visit
settings_namespace_project_pipeline
s_path
(
project
.
namespace
,
project
)
visit
namespace_project_pipelines_setting
s_path
(
project
.
namespace
,
project
)
end
scenario
'user displays list of badges'
do
...
...
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