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
Boxiang Sun
gitlab-ce
Commits
a8887a0d
Commit
a8887a0d
authored
Jan 29, 2018
by
Matija Čupić
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use `resource` in Group Variables routing scheme
parent
0bfcdd66
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
35 additions
and
12 deletions
+35
-12
app/controllers/groups/variables_controller.rb
app/controllers/groups/variables_controller.rb
+12
-1
app/presenters/ci/group_variable_presenter.rb
app/presenters/ci/group_variable_presenter.rb
+2
-2
config/routes/group.rb
config/routes/group.rb
+1
-3
spec/controllers/groups/variables_controller_spec.rb
spec/controllers/groups/variables_controller_spec.rb
+18
-4
spec/presenters/ci/group_variable_presenter_spec.rb
spec/presenters/ci/group_variable_presenter_spec.rb
+2
-2
No files found.
app/controllers/groups/variables_controller.rb
View file @
a8887a0d
...
@@ -2,7 +2,18 @@ module Groups
...
@@ -2,7 +2,18 @@ module Groups
class
VariablesController
<
Groups
::
ApplicationController
class
VariablesController
<
Groups
::
ApplicationController
before_action
:authorize_admin_build!
before_action
:authorize_admin_build!
def
save_multiple
def
show
respond_to
do
|
format
|
format
.
json
do
variables
=
@group
.
variables
.
map
{
|
variable
|
variable
.
present
(
current_user:
current_user
)
}
render
status: :ok
,
json:
{
variables:
variables
}
end
end
end
def
update
respond_to
do
|
format
|
respond_to
do
|
format
|
format
.
json
do
format
.
json
do
return
head
:ok
if
@group
.
update
(
variables_params
)
return
head
:ok
if
@group
.
update
(
variables_params
)
...
...
app/presenters/ci/group_variable_presenter.rb
View file @
a8887a0d
...
@@ -11,11 +11,11 @@ module Ci
...
@@ -11,11 +11,11 @@ module Ci
end
end
def
edit_path
def
edit_path
group_variables_
save_multiple_
path
(
group
)
group_variables_path
(
group
)
end
end
def
delete_path
def
delete_path
group_variables_
save_multiple_
path
(
group
)
group_variables_path
(
group
)
end
end
end
end
end
end
config/routes/group.rb
View file @
a8887a0d
...
@@ -27,9 +27,7 @@ constraints(GroupUrlConstrainer.new) do
...
@@ -27,9 +27,7 @@ constraints(GroupUrlConstrainer.new) do
resource
:ci_cd
,
only:
[
:show
],
controller:
'ci_cd'
resource
:ci_cd
,
only:
[
:show
],
controller:
'ci_cd'
end
end
namespace
:variables
do
resource
:variables
,
only:
[
:show
,
:update
]
post
:save_multiple
end
resources
:children
,
only:
[
:index
]
resources
:children
,
only:
[
:index
]
...
...
spec/controllers/groups/variables_controller_spec.rb
View file @
a8887a0d
...
@@ -9,12 +9,26 @@ describe Groups::VariablesController do
...
@@ -9,12 +9,26 @@ describe Groups::VariablesController do
group
.
add_master
(
user
)
group
.
add_master
(
user
)
end
end
describe
'POST #save_multiple'
do
describe
'GET #show'
do
let!
(
:variable
)
{
create
(
:ci_group_variable
,
group:
group
)
}
subject
do
get
:show
,
group_id:
group
,
format: :json
end
it
'renders the ci_variable as json'
do
subject
expect
(
response
.
body
).
to
include
(
variable
.
to_json
)
end
end
describe
'POST #update'
do
let!
(
:variable
)
{
create
(
:ci_group_variable
,
group:
group
)
}
let!
(
:variable
)
{
create
(
:ci_group_variable
,
group:
group
)
}
context
'with invalid new variable parameters'
do
context
'with invalid new variable parameters'
do
subject
do
subject
do
post
:
save_multipl
e
,
post
:
updat
e
,
group_id:
group
,
group_id:
group
,
variables_attributes:
[{
id:
variable
.
id
,
key:
variable
.
key
,
variables_attributes:
[{
id:
variable
.
id
,
key:
variable
.
key
,
value:
'other_value'
,
value:
'other_value'
,
...
@@ -41,7 +55,7 @@ describe Groups::VariablesController do
...
@@ -41,7 +55,7 @@ describe Groups::VariablesController do
context
'with valid new variable parameters'
do
context
'with valid new variable parameters'
do
subject
do
subject
do
post
:
save_multipl
e
,
post
:
updat
e
,
group_id:
group
,
group_id:
group
,
variables_attributes:
[{
id:
variable
.
id
,
key:
variable
.
key
,
variables_attributes:
[{
id:
variable
.
id
,
key:
variable
.
key
,
value:
'other_value'
,
value:
'other_value'
,
...
@@ -68,7 +82,7 @@ describe Groups::VariablesController do
...
@@ -68,7 +82,7 @@ describe Groups::VariablesController do
context
'with a deleted variable'
do
context
'with a deleted variable'
do
subject
do
subject
do
post
:
save_multipl
e
,
post
:
updat
e
,
group_id:
group
,
group_id:
group
,
variables_attributes:
[{
id:
variable
.
id
,
key:
variable
.
key
,
variables_attributes:
[{
id:
variable
.
id
,
key:
variable
.
key
,
value:
variable
.
value
,
value:
variable
.
value
,
...
...
spec/presenters/ci/group_variable_presenter_spec.rb
View file @
a8887a0d
...
@@ -43,12 +43,12 @@ describe Ci::GroupVariablePresenter do
...
@@ -43,12 +43,12 @@ describe Ci::GroupVariablePresenter do
describe
'#edit_path'
do
describe
'#edit_path'
do
subject
{
described_class
.
new
(
variable
).
edit_path
}
subject
{
described_class
.
new
(
variable
).
edit_path
}
it
{
is_expected
.
to
eq
(
group_variables_
save_multiple_
path
(
group
))
}
it
{
is_expected
.
to
eq
(
group_variables_path
(
group
))
}
end
end
describe
'#delete_path'
do
describe
'#delete_path'
do
subject
{
described_class
.
new
(
variable
).
delete_path
}
subject
{
described_class
.
new
(
variable
).
delete_path
}
it
{
is_expected
.
to
eq
(
group_variables_
save_multiple_
path
(
group
))
}
it
{
is_expected
.
to
eq
(
group_variables_path
(
group
))
}
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