2019-10-12 21:52:04 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-08-17 22:00:37 +05:30
|
|
|
require 'spec_helper'
|
|
|
|
|
2018-11-08 19:23:39 +05:30
|
|
|
describe 'Milestones sorting', :js do
|
2017-08-17 22:00:37 +05:30
|
|
|
let(:user) { create(:user) }
|
2017-09-10 17:25:29 +05:30
|
|
|
let(:project) { create(:project, name: 'test', namespace: user.namespace) }
|
2017-08-17 22:00:37 +05:30
|
|
|
|
|
|
|
before do
|
|
|
|
# Milestones
|
|
|
|
create(:milestone,
|
|
|
|
due_date: 10.days.from_now,
|
|
|
|
created_at: 2.hours.ago,
|
|
|
|
title: "aaa", project: project)
|
|
|
|
create(:milestone,
|
|
|
|
due_date: 11.days.from_now,
|
|
|
|
created_at: 1.hour.ago,
|
|
|
|
title: "bbb", project: project)
|
2017-09-10 17:25:29 +05:30
|
|
|
sign_in(user)
|
2017-08-17 22:00:37 +05:30
|
|
|
end
|
|
|
|
|
2018-11-08 19:23:39 +05:30
|
|
|
it 'visit project milestones and sort by due_date_asc' do
|
2017-09-10 17:25:29 +05:30
|
|
|
visit project_milestones_path(project)
|
2017-08-17 22:00:37 +05:30
|
|
|
|
|
|
|
expect(page).to have_button('Due soon')
|
|
|
|
|
|
|
|
# assert default sorting
|
|
|
|
within '.milestones' do
|
|
|
|
expect(page.all('ul.content-list > li').first.text).to include('aaa')
|
|
|
|
expect(page.all('ul.content-list > li').last.text).to include('bbb')
|
|
|
|
end
|
|
|
|
|
|
|
|
click_button 'Due soon'
|
|
|
|
|
|
|
|
sort_options = find('ul.dropdown-menu-sort li').all('a').collect(&:text)
|
|
|
|
|
|
|
|
expect(sort_options[0]).to eq('Due soon')
|
|
|
|
expect(sort_options[1]).to eq('Due later')
|
|
|
|
expect(sort_options[2]).to eq('Start soon')
|
|
|
|
expect(sort_options[3]).to eq('Start later')
|
|
|
|
expect(sort_options[4]).to eq('Name, ascending')
|
|
|
|
expect(sort_options[5]).to eq('Name, descending')
|
|
|
|
|
|
|
|
click_link 'Due later'
|
|
|
|
|
|
|
|
expect(page).to have_button('Due later')
|
|
|
|
|
|
|
|
within '.milestones' do
|
|
|
|
expect(page.all('ul.content-list > li').first.text).to include('bbb')
|
|
|
|
expect(page.all('ul.content-list > li').last.text).to include('aaa')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|