Commit 775247c3 authored by Kerri Miller's avatar Kerri Miller

Merge branch 'ajk-gql-mrs-updated-at-arguments' into 'master'

Enable searching for MRs by updated_at

See merge request gitlab-org/gitlab!79872
parents 64985d9a 544d23eb
......@@ -61,6 +61,12 @@ module Resolvers
argument :created_before, Types::TimeType,
required: false,
description: 'Merge requests created before this timestamp.'
argument :updated_after, Types::TimeType,
required: false,
description: 'Merge requests updated after this timestamp.'
argument :updated_before, Types::TimeType,
required: false,
description: 'Merge requests updated before this timestamp.'
argument :labels, [GraphQL::Types::String],
required: false,
......
This diff is collapsed.
......@@ -300,6 +300,8 @@ RSpec.describe GitlabSchema.types['Project'] do
:merged_before,
:created_after,
:created_before,
:updated_after,
:updated_before,
:author_username,
:assignee_username,
:reviewer_username,
......
......@@ -29,6 +29,10 @@ RSpec.describe 'getting merge request listings nested in a project' do
create(:merge_request, :unique_branches, source_project: project)
end
let(:all_merge_requests) do
[merge_request_a, merge_request_b, merge_request_c, merge_request_d, merge_request_e]
end
let(:results) { graphql_data.dig('project', 'mergeRequests', 'nodes') }
let(:search_params) { nil }
......@@ -180,6 +184,39 @@ RSpec.describe 'getting merge request listings nested in a project' do
it_behaves_like 'when searching with parameters'
end
context 'when searching by update time' do
let(:start_time) { 10.days.ago }
let(:cutoff) { start_time + 36.hours }
before do
all_merge_requests.each_with_index do |mr, i|
mr.updated_at = start_time + i.days
mr.save!(touch: false)
end
end
context 'when searching by updated_after' do
let(:search_params) { { updated_after: cutoff } }
let(:mrs) { all_merge_requests[2..] }
it_behaves_like 'when searching with parameters'
end
context 'when searching by updated_before' do
let(:search_params) { { updated_before: cutoff } }
let(:mrs) { all_merge_requests[0..1] }
it_behaves_like 'when searching with parameters'
end
context 'when searching by updated_before and updated_after' do
let(:search_params) { { updated_after: cutoff, updated_before: cutoff + 2.days } }
let(:mrs) { all_merge_requests[2..3] }
it_behaves_like 'when searching with parameters'
end
end
context 'when searching by combination' do
let(:search_params) { { state: :closed, labels: [label.title] } }
let(:mrs) { [merge_request_c] }
......
......@@ -41,6 +41,7 @@ module Graphql
when Hash then "{#{new(value)}}"
when Integer, Float, Symbol then value.to_s
when String then "\"#{value.gsub(/"/, '\\"')}\""
when Time, Date then "\"#{value.iso8601}\""
when nil then 'null'
when true then 'true'
when false then 'false'
......
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