Commit cac83114 authored by Felipe Artur's avatar Felipe Artur

Add additional specs/changelog and code improvements

parent 591d3d35
...@@ -121,7 +121,9 @@ You can also sort epics list by: ...@@ -121,7 +121,9 @@ You can also sort epics list by:
- **Created date** - **Created date**
- **Last updated** - **Last updated**
- **Start date** - **Start date**
- **Due date** - **Due date**
Each option contains a button that can toggle the order between **ascending** and **descending**. The sort option and order will be persisted to be used wherever epics are browsed including the [roadmap](../roadmap/index.md).
![epics sort](img/epics_sort.png) ![epics sort](img/epics_sort.png)
......
...@@ -13,6 +13,8 @@ Epics in the view can be sorted by: ...@@ -13,6 +13,8 @@ Epics in the view can be sorted by:
- **Start date** - **Start date**
- **Due date** - **Due date**
Each option contains a button that can toggle the order between **ascending** and **descending**. The sort option and order will be persisted to be used wherever epics are browsed including the [epics list view](../epics/index.md).
![roadmap view](img/roadmap_view.png) ![roadmap view](img/roadmap_view.png)
## Timeline duration ## Timeline duration
......
...@@ -9,7 +9,7 @@ module Groups ...@@ -9,7 +9,7 @@ module Groups
# show roadmap for a group # show roadmap for a group
def show def show
# Used only to show to correct sort dropdown option on filter bar # Used to persist the order and show the correct sorting dropdown on UI.
@sort = set_sort_order @sort = set_sort_order
@epics_count = EpicsFinder.new(current_user, group_id: @group.id).execute.count @epics_count = EpicsFinder.new(current_user, group_id: @group.id).execute.count
......
---
title: Add sort direction button with sort dropdown for Epics and Roadmap
merge_request:
author:
type: changed
...@@ -70,11 +70,24 @@ describe Groups::EpicsController do ...@@ -70,11 +70,24 @@ describe Groups::EpicsController do
end end
context 'when there is a logged user' do context 'when there is a logged user' do
it 'stores sorting param in user preferences' do context 'when epics_sort is nil' do
get :index, group_id: group, sort: 'start_date_asc' it 'stores sorting param in user preferences' do
get :index, group_id: group, sort: 'start_date_asc'
expect(user.user_preference.epics_sort).to eq('start_date_asc') expect(user.user_preference.epics_sort).to eq('start_date_asc')
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(200)
end
end
context 'when epics_sort is present' do
it 'update epics_sort with current value' do
user.user_preference.update(epics_sort: 'created_desc')
get :index, group_id: group, sort: 'start_date_asc'
expect(user.reload.user_preference.epics_sort).to eq('start_date_asc')
expect(response).to have_gitlab_http_status(200)
end
end end
end end
......
...@@ -44,11 +44,24 @@ describe Groups::RoadmapController do ...@@ -44,11 +44,24 @@ describe Groups::RoadmapController do
end end
context 'when there is a user logged in' do context 'when there is a user logged in' do
it 'stores epics sorting param in user preference' do context 'when epics_sort is nil' do
get :show, group_id: group, sort: 'start_date_asc' it 'stores epics sorting param in user preference' do
get :show, group_id: group, sort: 'start_date_asc'
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(200)
expect(user.reload.user_preference.epics_sort).to eq('start_date_asc') expect(user.reload.user_preference.epics_sort).to eq('start_date_asc')
end
end
context 'when epics_sort is present' do
it 'update epics_sort with current value' do
user.user_preference.update(epics_sort: 'created_desc')
get :show, group_id: group, sort: 'start_date_asc'
expect(user.reload.user_preference.epics_sort).to eq('start_date_asc')
expect(response).to have_gitlab_http_status(200)
end
end end
end end
end end
......
...@@ -44,7 +44,7 @@ describe 'epics list', :js do ...@@ -44,7 +44,7 @@ describe 'epics list', :js do
end end
it 'sorts by created_at DESC by default' do it 'sorts by created_at DESC by default' do
expect(page).to have_button('Last created') expect(page).to have_button('Created date')
page.within('.content-wrapper .content') do page.within('.content-wrapper .content') do
expect(find('.top-area')).to have_content('All 3') expect(find('.top-area')).to have_content('All 3')
...@@ -67,7 +67,7 @@ describe 'epics list', :js do ...@@ -67,7 +67,7 @@ describe 'epics list', :js do
it 'sorts by the selected value and stores the selection for epic list & roadmap' do it 'sorts by the selected value and stores the selection for epic list & roadmap' do
page.within('.epics-other-filters') do page.within('.epics-other-filters') do
click_button 'Due date' click_button 'Created date'
sort_options = find('ul.dropdown-menu-sort li').all('a').collect(&:text) sort_options = find('ul.dropdown-menu-sort li').all('a').collect(&:text)
expect(sort_options[0]).to eq('Created date') expect(sort_options[0]).to eq('Created date')
......
...@@ -48,10 +48,18 @@ describe Epic do ...@@ -48,10 +48,18 @@ describe Epic do
expect(epics(:start_date_asc)).to eq([epic1, epic2, epic4, epic3]) expect(epics(:start_date_asc)).to eq([epic1, epic2, epic4, epic3])
end end
it 'orders by start_date DESC' do
expect(epics(:start_date_desc)).to eq([epic2, epic1, epic4, epic3])
end
it 'orders by end_date ASC' do it 'orders by end_date ASC' do
expect(epics(:end_date_asc)).to eq([epic3, epic1, epic4, epic2]) expect(epics(:end_date_asc)).to eq([epic3, epic1, epic4, epic2])
end end
it 'orders by end_date DESC' do
expect(epics(:end_date_desc)).to eq([epic1, epic3, epic4, epic2])
end
it 'orders by updated_at ASC' do it 'orders by updated_at ASC' do
expect(epics(:updated_asc)).to eq([epic2, epic3, epic1, epic4]) expect(epics(:updated_asc)).to eq([epic2, epic3, epic1, epic4])
end end
......
...@@ -86,6 +86,7 @@ describe IssuableCollections do ...@@ -86,6 +86,7 @@ describe IssuableCollections do
it 'only allows whitelisted params' do it 'only allows whitelisted params' do
allow(controller).to receive(:cookies).and_return({}) allow(controller).to receive(:cookies).and_return({})
allow(controller).to receive(:current_user).and_return(nil)
finder_options = controller.send(:finder_options) finder_options = controller.send(:finder_options)
......
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