Commit cac83114 authored by Felipe Artur's avatar Felipe Artur

Add additional specs/changelog and code improvements

parent 591d3d35
......@@ -123,6 +123,8 @@ You can also sort epics list by:
- **Start 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)
## Permissions
......
......@@ -13,6 +13,8 @@ Epics in the view can be sorted by:
- **Start 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)
## Timeline duration
......
......@@ -9,7 +9,7 @@ module Groups
# show roadmap for a group
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
@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,6 +70,7 @@ describe Groups::EpicsController do
end
context 'when there is a logged user' do
context 'when epics_sort is nil' do
it 'stores sorting param in user preferences' do
get :index, group_id: group, sort: 'start_date_asc'
......@@ -78,6 +79,18 @@ describe Groups::EpicsController do
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
context 'with page param' do
let(:last_page) { group.epics.page.total_pages }
......
......@@ -44,6 +44,7 @@ describe Groups::RoadmapController do
end
context 'when there is a user logged in' do
context 'when epics_sort is nil' do
it 'stores epics sorting param in user preference' do
get :show, group_id: group, sort: 'start_date_asc'
......@@ -51,6 +52,18 @@ describe Groups::RoadmapController do
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
......@@ -44,7 +44,7 @@ describe 'epics list', :js do
end
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
expect(find('.top-area')).to have_content('All 3')
......@@ -67,7 +67,7 @@ describe 'epics list', :js do
it 'sorts by the selected value and stores the selection for epic list & roadmap' 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)
expect(sort_options[0]).to eq('Created date')
......
......@@ -48,10 +48,18 @@ describe Epic do
expect(epics(:start_date_asc)).to eq([epic1, epic2, epic4, epic3])
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
expect(epics(:end_date_asc)).to eq([epic3, epic1, epic4, epic2])
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
expect(epics(:updated_asc)).to eq([epic2, epic3, epic1, epic4])
end
......
......@@ -86,6 +86,7 @@ describe IssuableCollections do
it 'only allows whitelisted params' do
allow(controller).to receive(:cookies).and_return({})
allow(controller).to receive(:current_user).and_return(nil)
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