Commit d41c040f authored by GitLab Bot's avatar GitLab Bot

Add latest changes from gitlab-org/gitlab@master

parent 4689bac8
......@@ -5,6 +5,9 @@ module Types
class IssueSortEnum < IssuableSortEnum
graphql_name 'IssueSort'
description 'Values for sorting issues'
value 'DUE_DATE_ASC', 'Due date by ascending order', value: 'due_date_asc'
value 'DUE_DATE_DESC', 'Due date by descending order', value: 'due_date_desc'
end
# rubocop: enable Graphql/AuthorizeTypes
end
......@@ -138,8 +138,8 @@ class Issue < ApplicationRecord
def self.sort_by_attribute(method, excluded_labels: [])
case method.to_s
when 'closest_future_date', 'closest_future_date_asc' then order_closest_future_date
when 'due_date', 'due_date_asc' then order_due_date_asc
when 'due_date_desc' then order_due_date_desc
when 'due_date', 'due_date_asc' then order_due_date_asc.with_order_id_desc
when 'due_date_desc' then order_due_date_desc.with_order_id_desc
when 'relative_position', 'relative_position_asc' then order_relative_position_asc.with_order_id_desc
else
super
......
---
title: 'Issues queried in GraphQL now sortable by due date'
merge_request: 18094
author:
type: added
......@@ -2676,6 +2676,16 @@ type IssuePermissions {
Values for sorting issues
"""
enum IssueSort {
"""
Due date by ascending order
"""
DUE_DATE_ASC
"""
Due date by descending order
"""
DUE_DATE_DESC
"""
Created at ascending order
"""
......
......@@ -13406,6 +13406,18 @@
"description": "Created at ascending order",
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "DUE_DATE_ASC",
"description": "Due date by ascending order",
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "DUE_DATE_DESC",
"description": "Due date by descending order",
"isDeprecated": false,
"deprecationReason": null
}
],
"possibleTypes": null
......
......@@ -85,3 +85,11 @@ after(:all) do
Page::Main::Menu.perform(&:sign_out)
end
```
## Tag tests that require Administrator access
We don't run tests that require Administrator access against our Production environments.
When you add a new test that requires Administrator access, apply the RSpec metadata `:requires_admin` so that the test will not be included in the test suites executed against Production and other environments on which we don't want to run those tests.
Note: When running tests locally or configuring a pipeline, the environment variable `QA_CAN_TEST_ADMIN_FEATURES` can be set to `false` to skip tests that have the `:requires_admin` tag.
......@@ -51,10 +51,6 @@ module Sentry
raise Client::ResponseInvalidSizeError, "Sentry API response is too big. Limit is #{Gitlab::Utils::DeepSize.human_default_max_size}."
end
def valid_size?(issues)
Gitlab::Utils::DeepSize.new(issues).valid?
end
def handle_mapping_exceptions(&block)
yield
rescue KeyError => e
......
......@@ -2,7 +2,7 @@
module QA
context 'Plan' do
describe 'check xss occurence in @mentions in issues' do
describe 'check xss occurence in @mentions in issues', :requires_admin do
it 'user mentions a user in comment' do
QA::Runtime::Env.personal_access_token = QA::Runtime::Env.admin_personal_access_token
......
......@@ -2,7 +2,7 @@
module QA
context 'Performance bar' do
context 'when logged in as an admin user' do
context 'when logged in as an admin user', :requires_admin do
before do
Runtime::Browser.visit(:gitlab, Page::Main::Login)
Page::Main::Login.perform(&:sign_in_using_admin_credentials)
......
......@@ -72,9 +72,34 @@ describe Resolvers::IssuesResolver do
expect(resolve_issues(search: 'foo')).to contain_exactly(issue2)
end
it 'sort issues' do
describe 'sorting' do
context 'when sorting by created' do
it 'sorts issues ascending' do
expect(resolve_issues(sort: 'created_asc')).to eq [issue1, issue2]
end
it 'sorts issues descending' do
expect(resolve_issues(sort: 'created_desc')).to eq [issue2, issue1]
end
end
context 'when sorting by due date' do
let(:project) { create(:project) }
let!(:due_issue1) { create(:issue, project: project, due_date: 3.days.from_now) }
let!(:due_issue2) { create(:issue, project: project, due_date: nil) }
let!(:due_issue3) { create(:issue, project: project, due_date: 2.days.ago) }
let!(:due_issue4) { create(:issue, project: project, due_date: nil) }
it 'sorts issues ascending' do
expect(resolve_issues(sort: :due_date_asc)).to eq [due_issue3, due_issue1, due_issue4, due_issue2]
end
it 'sorts issues descending' do
expect(resolve_issues(sort: :due_date_desc)).to eq [due_issue1, due_issue3, due_issue4, due_issue2]
end
end
end
it 'returns issues user can see' do
project.add_guest(current_user)
......
# frozen_string_literal: true
require 'spec_helper'
describe GitlabSchema.types['IssueSort'] do
it { expect(described_class.graphql_name).to eq('IssueSort') }
it_behaves_like 'common sort values'
it 'exposes all the existing issue sort values' do
expect(described_class.values.keys).to include(*%w[DUE_DATE_ASC DUE_DATE_DESC])
end
end
# frozen_string_literal: true
require 'spec_helper'
describe Gitlab::GitalyClient::BlobService do
......
# frozen_string_literal: true
require 'spec_helper'
describe Gitlab::GitalyClient::BlobsStitcher do
......
# frozen_string_literal: true
require 'spec_helper'
describe Gitlab::GitalyClient::CleanupService do
......
# frozen_string_literal: true
require 'spec_helper'
describe Gitlab::GitalyClient::CommitService do
......
# frozen_string_literal: true
require 'spec_helper'
describe Gitlab::GitalyClient::ConflictFilesStitcher do
......
# frozen_string_literal: true
require 'spec_helper'
describe Gitlab::GitalyClient::ConflictsService do
......
# frozen_string_literal: true
require 'spec_helper'
describe Gitlab::GitalyClient::Diff do
......
# frozen_string_literal: true
require 'spec_helper'
describe Gitlab::GitalyClient::DiffStitcher do
......
# frozen_string_literal: true
require 'spec_helper'
describe Gitlab::GitalyClient::HealthCheckService do
......
# frozen_string_literal: true
require 'spec_helper'
describe Gitlab::GitalyClient::OperationService do
......
# frozen_string_literal: true
require 'spec_helper'
describe Gitlab::GitalyClient::RefService do
......
# frozen_string_literal: true
require 'spec_helper'
describe Gitlab::GitalyClient::RemoteService do
......
# frozen_string_literal: true
require 'spec_helper'
describe Gitlab::GitalyClient::RepositoryService do
......
# frozen_string_literal: true
require 'spec_helper'
describe Gitlab::GitalyClient::StorageSettings do
......
# frozen_string_literal: true
require 'spec_helper'
describe Gitlab::GitalyClient::Util do
......
# frozen_string_literal: true
require 'spec_helper'
describe Gitlab::GitalyClient::WikiService do
......
......@@ -64,7 +64,7 @@ describe 'getting an issue list for a project' do
end
end
it "is expected to check permissions on the first issue only" do
it 'is expected to check permissions on the first issue only' do
allow(Ability).to receive(:allowed?).and_call_original
# Newest first, we only want to see the newest checked
expect(Ability).not_to receive(:allowed?).with(current_user, :read_issue, issues.first)
......@@ -116,4 +116,95 @@ describe 'getting an issue list for a project' do
end
end
end
describe 'sorting and pagination' do
let(:start_cursor) { graphql_data['project']['issues']['pageInfo']['startCursor'] }
let(:end_cursor) { graphql_data['project']['issues']['pageInfo']['endCursor'] }
context 'when sorting by due date' do
let(:sort_project) { create(:project, :public) }
let!(:due_issue1) { create(:issue, project: sort_project, due_date: 3.days.from_now) }
let!(:due_issue2) { create(:issue, project: sort_project, due_date: nil) }
let!(:due_issue3) { create(:issue, project: sort_project, due_date: 2.days.ago) }
let!(:due_issue4) { create(:issue, project: sort_project, due_date: nil) }
let!(:due_issue5) { create(:issue, project: sort_project, due_date: 1.day.ago) }
let(:params) { 'sort: DUE_DATE_ASC' }
def query(issue_params = params)
graphql_query_for(
'project',
{ 'fullPath' => sort_project.full_path },
<<~ISSUES
issues(#{issue_params}) {
pageInfo {
endCursor
}
edges {
node {
iid
dueDate
}
}
}
ISSUES
)
end
before do
post_graphql(query, current_user: current_user)
end
it_behaves_like 'a working graphql query'
context 'when ascending' do
it 'sorts issues' do
expect(grab_iids).to eq [due_issue3.iid, due_issue5.iid, due_issue1.iid, due_issue4.iid, due_issue2.iid]
end
context 'when paginating' do
let(:params) { 'sort: DUE_DATE_ASC, first: 2' }
it 'sorts issues' do
expect(grab_iids).to eq [due_issue3.iid, due_issue5.iid]
cursored_query = query("sort: DUE_DATE_ASC, after: \"#{end_cursor}\"")
post_graphql(cursored_query, current_user: current_user)
response_data = JSON.parse(response.body)['data']['project']['issues']['edges']
expect(grab_iids(response_data)).to eq [due_issue1.iid, due_issue4.iid, due_issue2.iid]
end
end
end
context 'when descending' do
let(:params) { 'sort: DUE_DATE_DESC' }
it 'sorts issues' do
expect(grab_iids).to eq [due_issue1.iid, due_issue5.iid, due_issue3.iid, due_issue4.iid, due_issue2.iid]
end
context 'when paginating' do
let(:params) { 'sort: DUE_DATE_DESC, first: 2' }
it 'sorts issues' do
expect(grab_iids).to eq [due_issue1.iid, due_issue5.iid]
cursored_query = query("sort: DUE_DATE_DESC, after: \"#{end_cursor}\"")
post_graphql(cursored_query, current_user: current_user)
response_data = JSON.parse(response.body)['data']['project']['issues']['edges']
expect(grab_iids(response_data)).to eq [due_issue3.iid, due_issue4.iid, due_issue2.iid]
end
end
end
end
end
def grab_iids(data = issues_data)
data.map do |issue|
issue.dig('node', 'iid').to_i
end
end
end
# frozen_string_literal: true
RSpec.shared_examples 'common sort values' do
it 'exposes all the existing common sort values' do
expect(described_class.values.keys).to include(*%w[updated_desc updated_asc created_desc created_asc])
end
end
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