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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
61249683
Commit
61249683
authored
Mar 06, 2018
by
Kushal Pandya
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
jprovaznik: Add `epic_show_app_data` and `epic_endpoint_query_params`
parent
2c060a54
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
45 additions
and
12 deletions
+45
-12
ee/app/helpers/epics_helper.rb
ee/app/helpers/epics_helper.rb
+27
-8
ee/spec/helpers/epics_helper_spec.rb
ee/spec/helpers/epics_helper_spec.rb
+18
-4
No files found.
ee/app/helpers/epics_helper.rb
View file @
61249683
module
EpicsHelper
def
epic_meta_data
author
=
@epic
.
author
def
epic_show_app_data
(
epic
,
opts
)
author
=
epic
.
author
group
=
epic
.
group
da
ta
=
{
created:
@
epic
.
created_at
,
epic_me
ta
=
{
created:
epic
.
created_at
,
author:
{
name:
author
.
name
,
url:
user_path
(
author
),
username:
"@
#{
author
.
username
}
"
,
src:
avatar_icon_for_user
(
@epic
.
author
)
src:
opts
[
:author_icon
]
},
start_date:
@
epic
.
start_date
,
end_date:
@
epic
.
end_date
start_date:
epic
.
start_date
,
end_date:
epic
.
end_date
}
data
.
to_json
{
initial:
opts
[
:initial
].
merge
(
labels:
epic
.
labels
).
to_json
,
meta:
epic_meta
.
to_json
,
namespace:
group
.
path
,
labels_path:
group_labels_path
(
group
,
format: :json
,
only_group_labels:
true
,
include_ancestor_groups:
true
),
labels_web_url:
group_labels_path
(
group
),
epics_web_url:
group_epics_path
(
group
)
}
end
def
epic_endpoint_query_params
(
opts
)
opts
[
:data
]
||=
{}
opts
[
:data
][
:endpoint_query_params
]
=
{
only_group_labels:
true
,
include_ancestor_groups:
true
,
include_descendant_groups:
true
}.
to_json
opts
end
end
ee/spec/helpers/epics_helper_spec.rb
View file @
61249683
...
...
@@ -3,18 +3,32 @@ require 'spec_helper'
describe
EpicsHelper
do
include
ApplicationHelper
describe
'#epic_
meta
_data'
do
describe
'#epic_
show_app
_data'
do
it
'returns the correct json'
do
user
=
create
(
:user
)
@epic
=
create
(
:epic
,
author:
user
)
expect
(
JSON
.
parse
(
epic_meta_data
).
keys
).
to
match_array
(
%w[created author start_date end_date]
)
expect
(
JSON
.
parse
(
epic_meta_data
)[
'author'
]).
to
eq
({
data
=
epic_show_app_data
(
@epic
,
initial:
{},
author_icon:
'icon_path'
)
meta_data
=
JSON
.
parse
(
data
[
:meta
])
expected_keys
=
%i(initial meta namespace labels_path labels_web_url epics_web_url)
expect
(
data
.
keys
).
to
match_array
(
expected_keys
)
expect
(
meta_data
.
keys
).
to
match_array
(
%w[created author start_date end_date]
)
expect
(
meta_data
[
'author'
]).
to
eq
({
'name'
=>
user
.
name
,
'url'
=>
"/
#{
user
.
username
}
"
,
'username'
=>
"@
#{
user
.
username
}
"
,
'src'
=>
"
#{
avatar_icon_for_user
(
user
)
}
"
'src'
=>
'icon_path'
})
end
end
describe
'#epic_endpoint_query_params'
do
it
'it includes epic specific options in JSON format'
do
opts
=
epic_endpoint_query_params
({})
expected
=
"{
\"
only_group_labels
\"
:true,
\"
include_ancestor_groups
\"
:true,
\"
include_descendant_groups
\"
:true}"
expect
(
opts
[
:data
][
:endpoint_query_params
]).
to
eq
(
expected
)
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