2016-07-23 23:28:12 +00:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2017-06-29 04:13:10 +00:00
|
|
|
describe 'Projects > Issuables > Default sort order' do
|
2017-08-02 19:55:11 +00:00
|
|
|
let(:project) { create(:project, :public) }
|
2016-07-23 23:28:12 +00:00
|
|
|
|
|
|
|
let(:first_created_issuable) { issuables.order_created_asc.first }
|
|
|
|
let(:last_created_issuable) { issuables.order_created_desc.first }
|
|
|
|
|
|
|
|
let(:first_updated_issuable) { issuables.order_updated_asc.first }
|
|
|
|
let(:last_updated_issuable) { issuables.order_updated_desc.first }
|
|
|
|
|
|
|
|
context 'for merge requests' do
|
|
|
|
include MergeRequestHelpers
|
|
|
|
|
|
|
|
let!(:issuables) do
|
|
|
|
timestamps = [{ created_at: 3.minutes.ago, updated_at: 20.seconds.ago },
|
|
|
|
{ created_at: 2.minutes.ago, updated_at: 30.seconds.ago },
|
|
|
|
{ created_at: 4.minutes.ago, updated_at: 10.seconds.ago }]
|
|
|
|
|
|
|
|
timestamps.each_with_index do |ts, i|
|
|
|
|
create issuable_type, { title: "#{issuable_type}_#{i}",
|
|
|
|
source_branch: "#{issuable_type}_#{i}",
|
|
|
|
source_project: project }.merge(ts)
|
|
|
|
end
|
|
|
|
|
|
|
|
MergeRequest.all
|
|
|
|
end
|
|
|
|
|
2017-10-03 08:35:01 +00:00
|
|
|
context 'in the "merge requests" tab', :js do
|
2016-07-23 23:28:12 +00:00
|
|
|
let(:issuable_type) { :merge_request }
|
|
|
|
|
|
|
|
it 'is "last created"' do
|
|
|
|
visit_merge_requests project
|
|
|
|
|
|
|
|
expect(first_merge_request).to include(last_created_issuable.title)
|
|
|
|
expect(last_merge_request).to include(first_created_issuable.title)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2017-10-03 08:35:01 +00:00
|
|
|
context 'in the "merge requests / open" tab', :js do
|
2016-07-23 23:28:12 +00:00
|
|
|
let(:issuable_type) { :merge_request }
|
|
|
|
|
2017-09-23 00:46:53 +00:00
|
|
|
it 'is "created date"' do
|
2016-07-23 23:28:12 +00:00
|
|
|
visit_merge_requests_with_state(project, 'open')
|
|
|
|
|
2017-09-23 00:46:53 +00:00
|
|
|
expect(selected_sort_order).to eq('created date')
|
2016-07-23 23:28:12 +00:00
|
|
|
expect(first_merge_request).to include(last_created_issuable.title)
|
|
|
|
expect(last_merge_request).to include(first_created_issuable.title)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2017-10-03 08:35:01 +00:00
|
|
|
context 'in the "merge requests / merged" tab', :js do
|
2016-07-23 23:28:12 +00:00
|
|
|
let(:issuable_type) { :merged_merge_request }
|
|
|
|
|
|
|
|
it 'is "last updated"' do
|
|
|
|
visit_merge_requests_with_state(project, 'merged')
|
|
|
|
|
2016-08-11 16:48:32 +00:00
|
|
|
expect(find('.issues-other-filters')).to have_content('Last updated')
|
2016-07-23 23:28:12 +00:00
|
|
|
expect(first_merge_request).to include(last_updated_issuable.title)
|
|
|
|
expect(last_merge_request).to include(first_updated_issuable.title)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2017-10-03 08:35:01 +00:00
|
|
|
context 'in the "merge requests / closed" tab', :js do
|
2016-07-23 23:28:12 +00:00
|
|
|
let(:issuable_type) { :closed_merge_request }
|
|
|
|
|
|
|
|
it 'is "last updated"' do
|
|
|
|
visit_merge_requests_with_state(project, 'closed')
|
|
|
|
|
2016-08-11 16:48:32 +00:00
|
|
|
expect(find('.issues-other-filters')).to have_content('Last updated')
|
2016-07-23 23:28:12 +00:00
|
|
|
expect(first_merge_request).to include(last_updated_issuable.title)
|
|
|
|
expect(last_merge_request).to include(first_updated_issuable.title)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2017-10-03 08:35:01 +00:00
|
|
|
context 'in the "merge requests / all" tab', :js do
|
2016-07-23 23:28:12 +00:00
|
|
|
let(:issuable_type) { :merge_request }
|
|
|
|
|
2017-09-23 00:46:53 +00:00
|
|
|
it 'is "created date"' do
|
2016-07-23 23:28:12 +00:00
|
|
|
visit_merge_requests_with_state(project, 'all')
|
|
|
|
|
2017-09-23 00:46:53 +00:00
|
|
|
expect(find('.issues-other-filters')).to have_content('Created date')
|
2016-07-23 23:28:12 +00:00
|
|
|
expect(first_merge_request).to include(last_created_issuable.title)
|
|
|
|
expect(last_merge_request).to include(first_created_issuable.title)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'for issues' do
|
|
|
|
include IssueHelpers
|
|
|
|
|
|
|
|
let!(:issuables) do
|
|
|
|
timestamps = [{ created_at: 3.minutes.ago, updated_at: 20.seconds.ago },
|
|
|
|
{ created_at: 2.minutes.ago, updated_at: 30.seconds.ago },
|
|
|
|
{ created_at: 4.minutes.ago, updated_at: 10.seconds.ago }]
|
|
|
|
|
|
|
|
timestamps.each_with_index do |ts, i|
|
|
|
|
create issuable_type, { title: "#{issuable_type}_#{i}",
|
|
|
|
project: project }.merge(ts)
|
|
|
|
end
|
|
|
|
|
|
|
|
Issue.all
|
|
|
|
end
|
|
|
|
|
2017-10-03 08:35:01 +00:00
|
|
|
context 'in the "issues" tab', :js do
|
2016-07-23 23:28:12 +00:00
|
|
|
let(:issuable_type) { :issue }
|
|
|
|
|
2017-09-23 00:46:53 +00:00
|
|
|
it 'is "created date"' do
|
2016-07-23 23:28:12 +00:00
|
|
|
visit_issues project
|
|
|
|
|
2017-09-23 00:46:53 +00:00
|
|
|
expect(find('.issues-other-filters')).to have_content('Created date')
|
2016-07-23 23:28:12 +00:00
|
|
|
expect(first_issue).to include(last_created_issuable.title)
|
|
|
|
expect(last_issue).to include(first_created_issuable.title)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2017-10-03 08:35:01 +00:00
|
|
|
context 'in the "issues / open" tab', :js do
|
2016-07-23 23:28:12 +00:00
|
|
|
let(:issuable_type) { :issue }
|
|
|
|
|
2017-09-23 00:46:53 +00:00
|
|
|
it 'is "created date"' do
|
2016-07-23 23:28:12 +00:00
|
|
|
visit_issues_with_state(project, 'open')
|
|
|
|
|
2017-09-23 00:46:53 +00:00
|
|
|
expect(find('.issues-other-filters')).to have_content('Created date')
|
2016-07-23 23:28:12 +00:00
|
|
|
expect(first_issue).to include(last_created_issuable.title)
|
|
|
|
expect(last_issue).to include(first_created_issuable.title)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2017-10-03 08:35:01 +00:00
|
|
|
context 'in the "issues / closed" tab', :js do
|
2016-07-23 23:28:12 +00:00
|
|
|
let(:issuable_type) { :closed_issue }
|
|
|
|
|
|
|
|
it 'is "last updated"' do
|
|
|
|
visit_issues_with_state(project, 'closed')
|
|
|
|
|
2016-08-11 16:48:32 +00:00
|
|
|
expect(find('.issues-other-filters')).to have_content('Last updated')
|
2016-07-23 23:28:12 +00:00
|
|
|
expect(first_issue).to include(last_updated_issuable.title)
|
|
|
|
expect(last_issue).to include(first_updated_issuable.title)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2017-10-03 08:35:01 +00:00
|
|
|
context 'in the "issues / all" tab', :js do
|
2016-07-23 23:28:12 +00:00
|
|
|
let(:issuable_type) { :issue }
|
|
|
|
|
2017-09-23 00:46:53 +00:00
|
|
|
it 'is "created date"' do
|
2016-07-23 23:28:12 +00:00
|
|
|
visit_issues_with_state(project, 'all')
|
|
|
|
|
2017-09-23 00:46:53 +00:00
|
|
|
expect(find('.issues-other-filters')).to have_content('Created date')
|
2016-07-23 23:28:12 +00:00
|
|
|
expect(first_issue).to include(last_created_issuable.title)
|
|
|
|
expect(last_issue).to include(first_created_issuable.title)
|
|
|
|
end
|
|
|
|
end
|
2016-08-18 22:16:06 +00:00
|
|
|
|
|
|
|
context 'when the sort in the URL is id_desc' do
|
|
|
|
let(:issuable_type) { :issue }
|
|
|
|
|
2017-06-14 18:18:56 +00:00
|
|
|
before do
|
|
|
|
visit_issues(project, sort: 'id_desc')
|
|
|
|
end
|
2016-08-18 22:16:06 +00:00
|
|
|
|
2017-09-23 00:46:53 +00:00
|
|
|
it 'shows the sort order as created date' do
|
|
|
|
expect(find('.issues-other-filters')).to have_content('Created date')
|
2016-08-18 22:16:06 +00:00
|
|
|
expect(first_issue).to include(last_created_issuable.title)
|
|
|
|
expect(last_issue).to include(first_created_issuable.title)
|
|
|
|
end
|
|
|
|
end
|
2016-07-23 23:28:12 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def selected_sort_order
|
2017-03-08 12:17:01 +00:00
|
|
|
find('.filter-dropdown-container .dropdown button').text.downcase
|
2016-07-23 23:28:12 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def visit_merge_requests_with_state(project, state)
|
2016-12-30 15:44:16 +00:00
|
|
|
visit_merge_requests project, state: state
|
2016-07-23 23:28:12 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def visit_issues_with_state(project, state)
|
2016-12-30 15:44:16 +00:00
|
|
|
visit_issues project, state: state
|
2016-07-23 23:28:12 +00:00
|
|
|
end
|
|
|
|
end
|