Commit 1de120a2 authored by Kushal Pandya's avatar Kushal Pandya

Jan Provaznik: Add support for Epics on group roadmap

parent 739951e3
......@@ -96,7 +96,9 @@ constraints(GroupUrlConstrainer.new) do
path
end
get 'boards(/*extra_params)', as: :legacy_ee_group_boards_redirect, to: legacy_ee_group_boards_redirect
## EE-specific
resource :roadmap, only: [:show], controller: 'roadmap'
end
scope(path: '*id',
......
......@@ -96,4 +96,8 @@ class Groups::EpicsController < Groups::ApplicationController
def authorize_create_epic!
return render_404 unless can?(current_user, :create_epic, group)
end
def filter_params
super.merge(start_date: params[:start_date], end_date: params[:end_date])
end
end
module Groups
class RoadmapController < Groups::ApplicationController
before_action :group
def show
# show roadmap for a group
@epics_count = EpicsFinder.new(current_user, group_id: @group.id).execute.count
end
end
end
......@@ -53,9 +53,14 @@ class EpicsFinder < IssuableFinder
def by_timeframe(items)
return items unless params[:start_date] && params[:end_date]
end_date = params[:end_date].to_datetime.end_of_day
start_date = params[:start_date].to_datetime.beginning_of_day
items
.where('epics.start_date is not NULL or epics.end_date is not NULL')
.where('epics.start_date is NULL or epics.start_date <= ?', params[:end_date].end_of_day)
.where('epics.end_date is NULL or epics.end_date >= ?', params[:start_date].beginning_of_day)
.where('epics.start_date is NULL or epics.start_date <= ?', end_date)
.where('epics.end_date is NULL or epics.end_date >= ?', start_date)
rescue ArgumentError
items
end
end
class EpicEntity < IssuableEntity
expose :group_id
expose :group_name do |epic|
epic.group.name
end
expose :group_full_name do |epic|
epic.group.full_name
end
expose :start_date
expose :end_date
expose :web_url do |epic|
......
......@@ -92,19 +92,30 @@ describe EpicsFinder do
context 'by timeframe' do
it 'returns epics which start in the timeframe' do
expect(epics(start_date: 2.days.ago, end_date: 1.day.ago)).to contain_exactly(epic2)
params = {
start_date: 2.days.ago.strftime('%Y-%m-%d'),
end_date: 1.day.ago.strftime('%Y-%m-%d')
}
expect(epics(params)).to contain_exactly(epic2)
end
it 'returns epics which end in the timeframe' do
expect(epics(start_date: 4.days.ago, end_date: 3.days.ago)).to contain_exactly(epic3)
params = {
start_date: 4.days.ago.strftime('%Y-%m-%d'),
end_date: 3.days.ago.strftime('%Y-%m-%d')
}
expect(epics(params)).to contain_exactly(epic3)
end
it 'returns epics which start before and end after the timeframe' do
expect(epics(start_date: 4.days.ago, end_date: 4.days.ago)).to contain_exactly(epic3)
end
params = {
start_date: 4.days.ago.strftime('%Y-%m-%d'),
end_date: 4.days.ago.strftime('%Y-%m-%d')
}
it 'ignores epics which do not have start and end date set' do
expect(epics(start_date: 2.days.ago, end_date: 1.day.ago)).not_to include(epic1)
expect(epics(params)).to contain_exactly(epic3)
end
end
end
......
......@@ -14,6 +14,6 @@ describe EpicEntity do
end
it 'has epic specific attributes' do
expect(subject).to include(:start_date, :end_date, :group_id, :web_url)
expect(subject).to include(:start_date, :end_date, :group_id, :group_name, :group_full_name, :web_url)
end
end
......@@ -20,6 +20,8 @@
"web_url": { "type": "string" },
"milestone": { "type": ["object", "null"] },
"labels": { "type": ["array", "null"] },
"group_name": { "type": "string" },
"group_full_name": { "type": "string" },
"group": {
"id": { "type": "integer" },
"path": { "type": "string" }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment