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
f3aaf906
Commit
f3aaf906
authored
Feb 02, 2017
by
Jose Ivan Vargas
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added tests for the variables controller #update action
parent
d9d417d4
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
3 deletions
+29
-3
variables_controller.rb
app/controllers/projects/variables_controller.rb
+3
-2
variables_controller_spec.rb
spec/controllers/projects/variables_controller_spec.rb
+26
-1
No files found.
app/controllers/projects/variables_controller.rb
View file @
f3aaf906
...
...
@@ -15,10 +15,11 @@ class Projects::VariablesController < Projects::ApplicationController
@variable
=
@project
.
variables
.
find
(
params
[
:id
])
if
@variable
.
update_attributes
(
project_params
)
redirect_to
namespace_project_settings_ci_cd_path
(
project
.
namespace
,
project
),
notice:
'Variable was
successfully updated.'
flash
[
:notice
]
=
'Variables were
successfully updated.'
else
render
action:
"show"
flash
[
:alert
]
=
@variable
.
errors
.
full_messages
.
join
(
','
).
html_safe
end
redirect_to
namespace_project_settings_ci_cd_path
(
project
.
namespace
,
project
)
end
def
create
...
...
spec/controllers/projects/variables_controller_spec.rb
View file @
f3aaf906
...
...
@@ -20,7 +20,7 @@ describe Projects::VariablesController do
end
context
'variable is invalid'
do
it
'shows a
failure
flash message'
do
it
'shows a
n alert
flash message'
do
post
:create
,
namespace_id:
project
.
namespace
.
to_param
,
project_id:
project
.
to_param
,
variable:
{
key:
"..one"
,
value:
"two"
}
expect
(
flash
[
:alert
]).
to
include
'Key can contain only letters, digits and \'_\'.'
...
...
@@ -28,4 +28,29 @@ describe Projects::VariablesController do
end
end
end
describe
'POST #update'
do
let
(
:variable
)
{
create
(
:ci_variable
)
}
context
'updating a variable with valid characters'
do
before
do
variable
.
gl_project_id
=
project
.
id
project
.
variables
<<
variable
end
it
'shows a success flash message'
do
post
:update
,
namespace_id:
project
.
namespace
.
to_param
,
project_id:
project
.
to_param
,
id:
variable
.
id
,
variable:
{
key:
variable
.
key
,
value:
'two'
}
expect
(
flash
[
:notice
]).
to
include
'Variables were successfully updated.'
expect
(
response
).
to
redirect_to
(
namespace_project_settings_ci_cd_path
(
project
.
namespace
,
project
))
end
it
'shows an alert flash message'
do
post
:update
,
namespace_id:
project
.
namespace
.
to_param
,
project_id:
project
.
to_param
,
id:
variable
.
id
,
variable:
{
key:
'?'
,
value:
variable
.
value
}
expect
(
flash
[
:alert
]).
to
include
'Key can contain only letters, digits and \'_\'.'
expect
(
response
).
to
redirect_to
(
namespace_project_settings_ci_cd_path
(
project
.
namespace
,
project
))
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