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
04263b9f
Commit
04263b9f
authored
Jan 30, 2018
by
Matija Čupić
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add GroupVariableSerializer for Ci::GroupVariable
parent
9be519c1
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
29 additions
and
5 deletions
+29
-5
app/controllers/groups/variables_controller.rb
app/controllers/groups/variables_controller.rb
+2
-2
app/serializers/group_variable_entity.rb
app/serializers/group_variable_entity.rb
+7
-0
app/serializers/group_variable_serializer.rb
app/serializers/group_variable_serializer.rb
+3
-0
spec/controllers/groups/variables_controller_spec.rb
spec/controllers/groups/variables_controller_spec.rb
+3
-3
spec/serializers/group_variable_entity_spec.rb
spec/serializers/group_variable_entity_spec.rb
+14
-0
No files found.
app/controllers/groups/variables_controller.rb
View file @
04263b9f
...
...
@@ -8,7 +8,7 @@ module Groups
variables
=
@group
.
variables
.
map
{
|
variable
|
variable
.
present
(
current_user:
current_user
)
}
render
status: :ok
,
json:
{
variables:
variables
}
render
status: :ok
,
json:
{
variables:
GroupVariableSerializer
.
new
.
represent
(
variables
)
}
end
end
end
...
...
@@ -20,7 +20,7 @@ module Groups
variables
=
@group
.
variables
.
map
{
|
variable
|
variable
.
present
(
current_user:
current_user
)
}
return
render
status: :ok
,
json:
{
variables:
variables
}
return
render
status: :ok
,
json:
{
variables:
GroupVariableSerializer
.
new
.
represent
(
variables
)
}
end
render
status: :bad_request
,
json:
@group
.
errors
.
full_messages
...
...
app/serializers/group_variable_entity.rb
0 → 100644
View file @
04263b9f
class
GroupVariableEntity
<
Grape
::
Entity
expose
:id
expose
:key
expose
:value
expose
:protected?
,
as: :protected
end
app/serializers/group_variable_serializer.rb
0 → 100644
View file @
04263b9f
class
GroupVariableSerializer
<
BaseSerializer
entity
GroupVariableEntity
end
spec/controllers/groups/variables_controller_spec.rb
View file @
04263b9f
...
...
@@ -19,7 +19,7 @@ describe Groups::VariablesController do
it
'renders the ci_group_variable as json'
do
subject
expect
(
response
.
body
).
to
include
(
variable
.
to_json
)
expect
(
response
).
to
match_response_schema
(
'variable'
)
end
end
...
...
@@ -82,7 +82,7 @@ describe Groups::VariablesController do
it
'has all variables in response'
do
subject
expect
(
response
.
body
).
to
include
(
group
.
variables
.
reload
.
to_json
)
expect
(
response
).
to
match_response_schema
(
'variable'
)
end
end
...
...
@@ -111,7 +111,7 @@ describe Groups::VariablesController do
it
'has all variables in response'
do
subject
expect
(
response
.
body
).
to
include
(
group
.
variables
.
reload
.
to_json
)
expect
(
json_response
[
'variables'
].
count
).
to
eq
(
0
)
end
end
end
...
...
spec/serializers/group_variable_entity_spec.rb
0 → 100644
View file @
04263b9f
require
'spec_helper'
describe
GroupVariableEntity
do
let
(
:variable
)
{
create
(
:ci_group_variable
)
}
let
(
:entity
)
{
described_class
.
new
(
variable
)
}
describe
'#as_json'
do
subject
{
entity
.
as_json
}
it
'contains required fields'
do
expect
(
subject
).
to
include
(
:id
,
:key
,
:value
,
:protected
)
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