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
42e3f0fd
Commit
42e3f0fd
authored
Jan 27, 2017
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Return serializable hash from a represented serializer
parent
256a7735
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
29 additions
and
40 deletions
+29
-40
base_serializer.rb
app/serializers/base_serializer.rb
+1
-0
analytics_build_serializer_spec.rb
spec/serializers/analytics_build_serializer_spec.rb
+3
-7
analytics_issue_serializer_spec.rb
spec/serializers/analytics_issue_serializer_spec.rb
+2
-3
analytics_merge_request_serializer_spec.rb
spec/serializers/analytics_merge_request_serializer_spec.rb
+2
-3
analytics_stage_serializer_spec.rb
spec/serializers/analytics_stage_serializer_spec.rb
+7
-7
analytics_summary_serializer_spec.rb
spec/serializers/analytics_summary_serializer_spec.rb
+9
-10
environment_serializer_spec.rb
spec/serializers/environment_serializer_spec.rb
+4
-5
pipeline_serializer_spec.rb
spec/serializers/pipeline_serializer_spec.rb
+1
-5
No files found.
app/serializers/base_serializer.rb
View file @
42e3f0fd
...
...
@@ -6,6 +6,7 @@ class BaseSerializer
def
represent
(
resource
,
opts
=
{})
self
.
class
.
entity_class
.
represent
(
resource
,
opts
.
merge
(
request:
@request
))
.
as_json
end
def
self
.
entity
(
entity_class
)
...
...
spec/serializers/analytics_build_serializer_spec.rb
View file @
42e3f0fd
require
'spec_helper'
describe
AnalyticsBuildSerializer
do
let
(
:serializer
)
do
described_class
.
new
.
represent
(
resource
)
end
let
(
:json
)
{
serializer
.
as_json
}
let
(
:resource
)
{
create
(
:ci_build
)
}
subject
{
described_class
.
new
.
represent
(
resource
)
}
context
'when there is a single object provided'
do
it
'contains important elements of analyticsBuild'
do
expect
(
json
)
expect
(
subject
)
.
to
include
(
:name
,
:branch
,
:short_sha
,
:date
,
:total_time
,
:url
,
:author
)
end
end
...
...
spec/serializers/analytics_issue_serializer_spec.rb
View file @
42e3f0fd
require
'spec_helper'
describe
AnalyticsIssueSerializer
do
let
(
:serializer
)
do
subject
do
described_class
.
new
(
project:
project
,
entity: :merge_request
)
.
represent
(
resource
)
end
let
(
:user
)
{
create
(
:user
)
}
let
(
:json
)
{
serializer
.
as_json
}
let
(
:project
)
{
create
(
:project
)
}
let
(
:resource
)
do
{
...
...
@@ -23,7 +22,7 @@ describe AnalyticsIssueSerializer do
context
'when there is a single object provided'
do
it
'contains important elements of the issue'
do
expect
(
json
).
to
include
(
:title
,
:iid
,
:created_at
,
:total_time
,
:url
,
:author
)
expect
(
subject
).
to
include
(
:title
,
:iid
,
:created_at
,
:total_time
,
:url
,
:author
)
end
end
end
spec/serializers/analytics_merge_request_serializer_spec.rb
View file @
42e3f0fd
require
'spec_helper'
describe
AnalyticsMergeRequestSerializer
do
let
(
:serializer
)
do
subject
do
described_class
.
new
(
project:
project
,
entity: :merge_request
)
.
represent
(
resource
)
end
let
(
:user
)
{
create
(
:user
)
}
let
(
:json
)
{
serializer
.
as_json
}
let
(
:project
)
{
create
(
:project
)
}
let
(
:resource
)
do
{
...
...
@@ -24,7 +23,7 @@ describe AnalyticsMergeRequestSerializer do
context
'when there is a single object provided'
do
it
'contains important elements of the merge request'
do
expect
(
json
).
to
include
(
:title
,
:iid
,
:created_at
,
:total_time
,
:url
,
:author
,
:state
)
expect
(
subject
).
to
include
(
:title
,
:iid
,
:created_at
,
:total_time
,
:url
,
:author
,
:state
)
end
end
end
spec/serializers/analytics_stage_serializer_spec.rb
View file @
42e3f0fd
require
'spec_helper'
describe
AnalyticsStageSerializer
do
let
(
:serializer
)
do
described_class
.
new
.
represent
(
resource
)
subject
do
described_class
.
new
.
represent
(
resource
)
end
let
(
:json
)
{
serializer
.
as_json
}
let
(
:resource
)
{
Gitlab
::
CycleAnalytics
::
CodeStage
.
new
(
project:
double
,
options:
{})
}
let
(
:resource
)
do
Gitlab
::
CycleAnalytics
::
CodeStage
.
new
(
project:
double
,
options:
{})
end
before
do
allow_any_instance_of
(
Gitlab
::
CycleAnalytics
::
BaseStage
).
to
receive
(
:median
).
and_return
(
1.12
)
...
...
@@ -15,10 +15,10 @@ describe AnalyticsStageSerializer do
end
it
'it generates payload for single object'
do
expect
(
json
).
to
be_kind_of
Hash
expect
(
subject
).
to
be_kind_of
Hash
end
it
'contains important elements of AnalyticsStage'
do
expect
(
json
).
to
include
(
:title
,
:description
,
:value
)
expect
(
subject
).
to
include
(
:title
,
:description
,
:value
)
end
end
spec/serializers/analytics_summary_serializer_spec.rb
View file @
42e3f0fd
require
'spec_helper'
describe
AnalyticsSummarySerializer
do
let
(
:serializer
)
do
described_class
.
new
.
represent
(
resource
)
subject
do
described_class
.
new
.
represent
(
resource
)
end
let
(
:json
)
{
serializer
.
as_json
}
let
(
:project
)
{
create
(
:empty_project
)
}
let
(
:user
)
{
create
(
:user
)
}
let
(
:resource
)
do
Gitlab
::
CycleAnalytics
::
Summary
::
Issue
.
new
(
project:
double
,
from:
1
.
day
.
ago
,
current_user:
user
)
Gitlab
::
CycleAnalytics
::
Summary
::
Issue
.
new
(
project:
double
,
from:
1
.
day
.
ago
,
current_user:
user
)
end
before
do
allow_any_instance_of
(
Gitlab
::
CycleAnalytics
::
Summary
::
Issue
).
to
receive
(
:value
).
and_return
(
1.12
)
allow_any_instance_of
(
Gitlab
::
CycleAnalytics
::
Summary
::
Issue
)
.
to
receive
(
:value
).
and_return
(
1.12
)
end
it
'it generates payload for single object'
do
expect
(
json
).
to
be_kind_of
Hash
expect
(
subject
).
to
be_kind_of
Hash
end
it
'contains important elements of AnalyticsStage'
do
expect
(
json
).
to
include
(
:title
,
:value
)
expect
(
subject
).
to
include
(
:title
,
:value
)
end
end
spec/serializers/environment_serializer_spec.rb
View file @
42e3f0fd
require
'spec_helper'
describe
EnvironmentSerializer
do
let
(
:serializer
)
do
let
(
:user
)
{
create
(
:user
)
}
let
(
:project
)
{
create
(
:project
)
}
let
(
:json
)
do
described_class
.
new
(
user:
user
,
project:
project
)
.
represent
(
resource
)
end
let
(
:json
)
{
serializer
.
as_json
}
let
(
:user
)
{
create
(
:user
)
}
let
(
:project
)
{
create
(
:project
)
}
context
'when there is a single object provided'
do
before
do
create
(
:ci_build
,
:manual
,
name:
'manual1'
,
...
...
spec/serializers/pipeline_serializer_spec.rb
View file @
42e3f0fd
...
...
@@ -7,11 +7,7 @@ describe PipelineSerializer do
described_class
.
new
(
user:
user
)
end
let
(
:entity
)
do
serializer
.
represent
(
resource
)
end
subject
{
entity
.
as_json
}
subject
{
serializer
.
represent
(
resource
)
}
describe
'#represent'
do
context
'when used without pagination'
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