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
8502eb4a
Commit
8502eb4a
authored
Nov 06, 2017
by
Jarka Kadlecova
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implement epics index action
parent
b97bce0a
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
175 additions
and
1 deletion
+175
-1
app/controllers/concerns/issuable_collections.rb
app/controllers/concerns/issuable_collections.rb
+4
-0
config/application.rb
config/application.rb
+1
-0
ee/app/controllers/groups/epics_controller.rb
ee/app/controllers/groups/epics_controller.rb
+22
-1
ee/app/finders/epics_finder.rb
ee/app/finders/epics_finder.rb
+35
-0
ee/app/views/groups/ee/epics/_epics.html.haml
ee/app/views/groups/ee/epics/_epics.html.haml
+1
-0
ee/app/views/groups/ee/epics/index.html.haml
ee/app/views/groups/ee/epics/index.html.haml
+2
-0
spec/ee/spec/controllers/groups/epics_controller_spec.rb
spec/ee/spec/controllers/groups/epics_controller_spec.rb
+36
-0
spec/ee/spec/finders/epics_finder_spec.rb
spec/ee/spec/finders/epics_finder_spec.rb
+74
-0
No files found.
app/controllers/concerns/issuable_collections.rb
View file @
8502eb4a
...
...
@@ -143,6 +143,8 @@ module IssuableCollections
'Issue'
when
MergeRequestsFinder
'MergeRequest'
when
EpicsFinder
'Epic'
end
end
...
...
@@ -155,6 +157,8 @@ module IssuableCollections
:source_project
,
:target_project
,
:author
,
:assignee
,
:labels
,
:milestone
,
head_pipeline: :project
,
target_project: :namespace
,
merge_request_diff: :merge_request_diff_commits
]
when
'Epic'
[
:group
,
:author
]
end
end
end
config/application.rb
View file @
8502eb4a
...
...
@@ -40,6 +40,7 @@ module Gitlab
config
.
eager_load_paths
.
push
(
*
%W[
#{
config
.
root
}
/ee/lib
#{
config
.
root
}
/ee/app/controllers
#{
config
.
root
}
/ee/app/finders
#{
config
.
root
}
/ee/app/helpers
#{
config
.
root
}
/ee/app/mailers
#{
config
.
root
}
/ee/app/models
...
...
ee/app/controllers/groups/epics_controller.rb
View file @
8502eb4a
class
Groups::EpicsController
<
Groups
::
ApplicationController
include
IssuableActions
include
IssuableCollections
before_action
:epic
before_action
:epic
,
except: :index
before_action
:set_issuables_index
,
only: :index
before_action
:authorize_update_issuable!
,
only: :update
skip_before_action
:labels
def
index
@epics
=
@issuables
respond_to
do
|
format
|
format
.
html
do
render
'groups/ee/epics/index'
end
format
.
json
do
render
json:
{
html:
view_to_html_string
(
"groups/ee/epics/_epics"
)
}
end
end
end
private
def
epic
...
...
@@ -41,4 +58,8 @@ class Groups::EpicsController < Groups::ApplicationController
def
show_view
'groups/ee/epics/show'
end
def
finder_type
EpicsFinder
end
end
ee/app/finders/epics_finder.rb
0 → 100644
View file @
8502eb4a
class
EpicsFinder
<
IssuableFinder
def
klass
Epic
end
def
execute
raise
ArgumentError
,
'group_id argument is missing'
unless
group
items
=
init_collection
items
=
by_created_at
(
items
)
items
=
by_search
(
items
)
items
=
by_author
(
items
)
items
=
by_iids
(
items
)
sort
(
items
)
end
def
row_count
execute
.
count
end
def
group
return
nil
unless
params
[
:group_id
]
return
@group
if
defined?
(
@group
)
group
=
Group
.
find
(
params
[
:group_id
])
group
=
nil
unless
Ability
.
allowed?
(
current_user
,
:read_epic
,
group
)
@group
=
group
end
def
init_collection
group
.
epics
end
end
ee/app/views/groups/ee/epics/_epics.html.haml
0 → 100644
View file @
8502eb4a
%ul
.content-list.issues-list.issuable-list
ee/app/views/groups/ee/epics/index.html.haml
0 → 100644
View file @
8502eb4a
-
page_title
"Epics"
spec/ee/spec/controllers/groups/epics_controller_spec.rb
View file @
8502eb4a
...
...
@@ -9,6 +9,42 @@ describe Groups::EpicsController do
sign_in
(
user
)
end
describe
"GET #index"
do
let!
(
:epic_list
)
{
create_list
(
:epic
,
2
,
group:
group
)
}
before
do
sign_in
(
user
)
group
.
add_developer
(
user
)
end
it
"returns index"
do
get
:index
,
group_id:
group
expect
(
response
).
to
have_gitlab_http_status
(
200
)
end
context
'with page param'
do
let
(
:last_page
)
{
group
.
epics
.
page
.
total_pages
}
before
do
allow
(
Kaminari
.
config
).
to
receive
(
:default_per_page
).
and_return
(
1
)
end
it
'redirects to last_page if page number is larger than number of pages'
do
get
:index
,
group_id:
group
,
page:
(
last_page
+
1
).
to_param
expect
(
response
).
to
redirect_to
(
group_epics_path
(
page:
last_page
,
state:
controller
.
params
[
:state
],
scope:
controller
.
params
[
:scope
]))
end
it
'renders the specified page'
do
get
:index
,
group_id:
group
,
page:
last_page
.
to_param
expect
(
assigns
(
:epics
).
current_page
).
to
eq
(
last_page
)
expect
(
response
).
to
have_gitlab_http_status
(
200
)
end
end
end
describe
'GET #show'
do
def
show_epic
(
format
=
:html
)
get
:show
,
group_id:
group
,
id:
epic
.
to_param
,
format:
format
...
...
spec/ee/spec/finders/epics_finder_spec.rb
0 → 100644
View file @
8502eb4a
require
'spec_helper'
describe
EpicsFinder
do
let
(
:user
)
{
create
(
:user
)
}
let
(
:search_user
)
{
create
(
:user
)
}
let
(
:group
)
{
create
(
:group
,
:private
)
}
let
(
:another_group
)
{
create
(
:group
)
}
let!
(
:epic1
)
{
create
(
:epic
,
group:
group
,
title:
'This is awesome epic'
,
created_at:
1
.
week
.
ago
)
}
let!
(
:epic2
)
{
create
(
:epic
,
group:
group
,
created_at:
4
.
days
.
ago
,
author:
user
)
}
let!
(
:epic3
)
{
create
(
:epic
,
group:
group
,
description:
'not so awesome'
)
}
let!
(
:epic4
)
{
create
(
:epic
,
group:
another_group
)
}
describe
'#execute'
do
def
epics
(
params
=
{})
params
[
:group_id
]
=
group
.
id
described_class
.
new
(
search_user
,
params
).
execute
end
context
'without param'
do
it
'raises an error when group_id param is missing'
do
expect
{
described_class
.
new
(
search_user
).
execute
}.
to
raise_error
{
ArgumentError
}
end
end
context
'when user can not read epics of a group'
do
it
'raises an error when group_id param is missing'
do
expect
{
epics
}.
to
raise_error
{
ArgumentError
}
end
end
context
'wtih correct params'
do
before
do
group
.
add_developer
(
search_user
)
end
it
'returns all epics that belong to the given group'
do
expect
(
epics
).
to
contain_exactly
(
epic1
,
epic2
,
epic3
)
end
context
'by created_at'
do
it
'returns all epics created before the given date'
do
expect
(
epics
(
created_before:
2
.
days
.
ago
)).
to
contain_exactly
(
epic1
,
epic2
)
end
it
'returns all epics created after the given date'
do
expect
(
epics
(
created_after:
2
.
days
.
ago
)).
to
contain_exactly
(
epic3
)
end
it
'returns all epics created within the given interval'
do
expect
(
epics
(
created_after:
5
.
days
.
ago
,
created_before:
1
.
day
.
ago
)).
to
contain_exactly
(
epic2
)
end
end
context
'by search'
do
it
'returns all epics that match the search'
do
expect
(
epics
(
search:
'awesome'
)).
to
contain_exactly
(
epic1
,
epic3
)
end
end
context
'by author'
do
it
'returns all epics authored by the given user'
do
expect
(
epics
(
author_id:
user
.
id
)).
to
contain_exactly
(
epic2
)
end
end
context
'by iids'
do
it
'returns all epics by the given iids'
do
expect
(
epics
(
iids:
[
epic1
.
iid
,
epic3
.
iid
])).
to
contain_exactly
(
epic1
,
epic3
)
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