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
Tatuya Kamada
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
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
3 deletions
+29
-3
app/controllers/projects/variables_controller.rb
app/controllers/projects/variables_controller.rb
+3
-2
spec/controllers/projects/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
...
@@ -15,10 +15,11 @@ class Projects::VariablesController < Projects::ApplicationController
@variable
=
@project
.
variables
.
find
(
params
[
:id
])
@variable
=
@project
.
variables
.
find
(
params
[
:id
])
if
@variable
.
update_attributes
(
project_params
)
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
else
render
action:
"show"
flash
[
:alert
]
=
@variable
.
errors
.
full_messages
.
join
(
','
).
html_safe
end
end
redirect_to
namespace_project_settings_ci_cd_path
(
project
.
namespace
,
project
)
end
end
def
create
def
create
...
...
spec/controllers/projects/variables_controller_spec.rb
View file @
f3aaf906
...
@@ -20,7 +20,7 @@ describe Projects::VariablesController do
...
@@ -20,7 +20,7 @@ describe Projects::VariablesController do
end
end
context
'variable is invalid'
do
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
,
post
:create
,
namespace_id:
project
.
namespace
.
to_param
,
project_id:
project
.
to_param
,
variable:
{
key:
"..one"
,
value:
"two"
}
variable:
{
key:
"..one"
,
value:
"two"
}
expect
(
flash
[
:alert
]).
to
include
'Key can contain only letters, digits and \'_\'.'
expect
(
flash
[
:alert
]).
to
include
'Key can contain only letters, digits and \'_\'.'
...
@@ -28,4 +28,29 @@ describe Projects::VariablesController do
...
@@ -28,4 +28,29 @@ describe Projects::VariablesController do
end
end
end
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
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