diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-04-08 06:09:31 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-04-08 06:09:31 +0300 |
commit | e2ee1eec50aa8df8543d7ecc585ec0ba5ee544ac (patch) | |
tree | 7998650d27ada12ee7d06a21cbb3b5e89f298378 /spec/lib/gitlab/graphql | |
parent | 060c842402c00f830a810702600cbe39dfa6cf62 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/lib/gitlab/graphql')
-rw-r--r-- | spec/lib/gitlab/graphql/pagination/externally_paginated_array_connection_spec.rb (renamed from spec/lib/gitlab/graphql/connections/externally_paginated_array_connection_spec.rb) | 18 | ||||
-rw-r--r-- | spec/lib/gitlab/graphql/pagination/filterable_array_connection_spec.rb (renamed from spec/lib/gitlab/graphql/connections/filterable_array_connection_spec.rb) | 12 | ||||
-rw-r--r-- | spec/lib/gitlab/graphql/pagination/keyset/conditions/not_null_condition_spec.rb (renamed from spec/lib/gitlab/graphql/connections/keyset/conditions/not_null_condition_spec.rb) | 4 | ||||
-rw-r--r-- | spec/lib/gitlab/graphql/pagination/keyset/conditions/null_condition_spec.rb (renamed from spec/lib/gitlab/graphql/connections/keyset/conditions/null_condition_spec.rb) | 4 | ||||
-rw-r--r-- | spec/lib/gitlab/graphql/pagination/keyset/connection_spec.rb (renamed from spec/lib/gitlab/graphql/connections/keyset/connection_spec.rb) | 19 | ||||
-rw-r--r-- | spec/lib/gitlab/graphql/pagination/keyset/order_info_spec.rb (renamed from spec/lib/gitlab/graphql/connections/keyset/order_info_spec.rb) | 2 | ||||
-rw-r--r-- | spec/lib/gitlab/graphql/pagination/keyset/query_builder_spec.rb (renamed from spec/lib/gitlab/graphql/connections/keyset/query_builder_spec.rb) | 4 |
7 files changed, 29 insertions, 34 deletions
diff --git a/spec/lib/gitlab/graphql/connections/externally_paginated_array_connection_spec.rb b/spec/lib/gitlab/graphql/pagination/externally_paginated_array_connection_spec.rb index 83c94ed6260..85a5b1dacc7 100644 --- a/spec/lib/gitlab/graphql/connections/externally_paginated_array_connection_spec.rb +++ b/spec/lib/gitlab/graphql/pagination/externally_paginated_array_connection_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Gitlab::Graphql::Connections::ExternallyPaginatedArrayConnection do +describe Gitlab::Graphql::Pagination::ExternallyPaginatedArrayConnection do let(:prev_cursor) { 1 } let(:next_cursor) { 6 } let(:values) { [2, 3, 4, 5] } @@ -10,21 +10,13 @@ describe Gitlab::Graphql::Connections::ExternallyPaginatedArrayConnection do let(:arguments) { {} } subject(:connection) do - described_class.new(all_nodes, arguments) + described_class.new(all_nodes, { max_page_size: values.size }.merge(arguments)) end - describe '#sliced_nodes' do - let(:sliced_nodes) { connection.sliced_nodes } + describe '#nodes' do + let(:paged_nodes) { connection.nodes } - it 'returns all the nodes' do - expect(connection.sliced_nodes).to eq(values) - end - end - - describe '#paged_nodes' do - let(:paged_nodes) { connection.send(:paged_nodes) } - - it_behaves_like "connection with paged nodes" do + it_behaves_like 'connection with paged nodes' do let(:paged_nodes_size) { values.size } end end diff --git a/spec/lib/gitlab/graphql/connections/filterable_array_connection_spec.rb b/spec/lib/gitlab/graphql/pagination/filterable_array_connection_spec.rb index b2f0862be62..c82e3ad3019 100644 --- a/spec/lib/gitlab/graphql/connections/filterable_array_connection_spec.rb +++ b/spec/lib/gitlab/graphql/pagination/filterable_array_connection_spec.rb @@ -2,19 +2,19 @@ require 'spec_helper' -describe Gitlab::Graphql::Connections::FilterableArrayConnection do +describe Gitlab::Graphql::Pagination::FilterableArrayConnection do let(:callback) { proc { |nodes| nodes } } let(:all_nodes) { Gitlab::Graphql::FilterableArray.new(callback, 1, 2, 3, 4, 5) } let(:arguments) { {} } subject(:connection) do - described_class.new(all_nodes, arguments, max_page_size: 3) + described_class.new(all_nodes, { max_page_size: 3 }.merge(arguments)) end - describe '#paged_nodes' do - let(:paged_nodes) { subject.paged_nodes } + describe '#nodes' do + let(:paged_nodes) { subject.nodes } - it_behaves_like "connection with paged nodes" do + it_behaves_like 'connection with paged nodes' do let(:paged_nodes_size) { 3 } end @@ -22,7 +22,7 @@ describe Gitlab::Graphql::Connections::FilterableArrayConnection do let(:callback) { proc { |nodes| nodes[1..-1] } } it 'does not return filtered elements' do - expect(subject.paged_nodes).to contain_exactly(all_nodes[1], all_nodes[2]) + expect(subject.nodes).to contain_exactly(all_nodes[1], all_nodes[2]) end end end diff --git a/spec/lib/gitlab/graphql/connections/keyset/conditions/not_null_condition_spec.rb b/spec/lib/gitlab/graphql/pagination/keyset/conditions/not_null_condition_spec.rb index 26fc5344871..33dc6bdea97 100644 --- a/spec/lib/gitlab/graphql/connections/keyset/conditions/not_null_condition_spec.rb +++ b/spec/lib/gitlab/graphql/pagination/keyset/conditions/not_null_condition_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Gitlab::Graphql::Connections::Keyset::Conditions::NotNullCondition do +describe Gitlab::Graphql::Pagination::Keyset::Conditions::NotNullCondition do describe '#build' do let(:operators) { ['>', '>'] } let(:before_or_after) { :after } @@ -75,7 +75,7 @@ describe Gitlab::Graphql::Connections::Keyset::Conditions::NotNullCondition do context 'when ordering by LOWER' do let(:arel_table) { Project.arel_table } let(:relation) { Project.order(arel_table['name'].lower.asc).order(:id) } - let(:order_list) { Gitlab::Graphql::Connections::Keyset::OrderInfo.build_order_list(relation) } + let(:order_list) { Gitlab::Graphql::Pagination::Keyset::OrderInfo.build_order_list(relation) } let(:values) { ['Test', 500] } context 'when :after' do diff --git a/spec/lib/gitlab/graphql/connections/keyset/conditions/null_condition_spec.rb b/spec/lib/gitlab/graphql/pagination/keyset/conditions/null_condition_spec.rb index be0a21b2438..1c74f2fb0ab 100644 --- a/spec/lib/gitlab/graphql/connections/keyset/conditions/null_condition_spec.rb +++ b/spec/lib/gitlab/graphql/pagination/keyset/conditions/null_condition_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Gitlab::Graphql::Connections::Keyset::Conditions::NullCondition do +describe Gitlab::Graphql::Pagination::Keyset::Conditions::NullCondition do describe '#build' do let(:values) { [nil, 500] } let(:operators) { [nil, '>'] } @@ -58,7 +58,7 @@ describe Gitlab::Graphql::Connections::Keyset::Conditions::NullCondition do context 'when ordering by LOWER' do let(:arel_table) { Project.arel_table } let(:relation) { Project.order(arel_table['name'].lower.asc).order(:id) } - let(:order_list) { Gitlab::Graphql::Connections::Keyset::OrderInfo.build_order_list(relation) } + let(:order_list) { Gitlab::Graphql::Pagination::Keyset::OrderInfo.build_order_list(relation) } context 'when :after' do it 'generates sql' do diff --git a/spec/lib/gitlab/graphql/connections/keyset/connection_spec.rb b/spec/lib/gitlab/graphql/pagination/keyset/connection_spec.rb index c193ab2b50f..fdacecbaca6 100644 --- a/spec/lib/gitlab/graphql/connections/keyset/connection_spec.rb +++ b/spec/lib/gitlab/graphql/pagination/keyset/connection_spec.rb @@ -2,25 +2,28 @@ require 'spec_helper' -describe Gitlab::Graphql::Connections::Keyset::Connection do +describe Gitlab::Graphql::Pagination::Keyset::Connection do let(:nodes) { Project.all.order(id: :asc) } let(:arguments) { {} } + let(:query_type) { GraphQL::ObjectType.new } + let(:schema) { GraphQL::Schema.define(query: query_type, mutation: nil)} + let(:context) { GraphQL::Query::Context.new(query: OpenStruct.new(schema: schema), values: nil, object: nil) } subject(:connection) do - described_class.new(nodes, arguments, max_page_size: 3) + described_class.new(nodes, { context: context, max_page_size: 3 }.merge(arguments)) end def encoded_cursor(node) - described_class.new(nodes, {}).cursor_from_node(node) + described_class.new(nodes, { context: context }).cursor_for(node) end def decoded_cursor(cursor) JSON.parse(Base64Bp.urlsafe_decode64(cursor)) end - describe '#cursor_from_nodes' do + describe '#cursor_for' do let(:project) { create(:project) } - let(:cursor) { connection.cursor_from_node(project) } + let(:cursor) { connection.cursor_for(project) } it 'returns an encoded ID' do expect(decoded_cursor(cursor)).to eq('id' => project.id.to_s) @@ -264,11 +267,11 @@ describe Gitlab::Graphql::Connections::Keyset::Connection do end end - describe '#paged_nodes' do + describe '#nodes' do let_it_be(:all_nodes) { create_list(:project, 5) } - let(:paged_nodes) { subject.paged_nodes } + let(:paged_nodes) { subject.nodes } - it_behaves_like "connection with paged nodes" do + it_behaves_like 'connection with paged nodes' do let(:paged_nodes_size) { 3 } end diff --git a/spec/lib/gitlab/graphql/connections/keyset/order_info_spec.rb b/spec/lib/gitlab/graphql/pagination/keyset/order_info_spec.rb index eb823fc0122..cb5656d7c00 100644 --- a/spec/lib/gitlab/graphql/connections/keyset/order_info_spec.rb +++ b/spec/lib/gitlab/graphql/pagination/keyset/order_info_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Gitlab::Graphql::Connections::Keyset::OrderInfo do +describe Gitlab::Graphql::Pagination::Keyset::OrderInfo do describe '#build_order_list' do let(:order_list) { described_class.build_order_list(relation) } diff --git a/spec/lib/gitlab/graphql/connections/keyset/query_builder_spec.rb b/spec/lib/gitlab/graphql/pagination/keyset/query_builder_spec.rb index b46ce4bf023..7fd5b889cf9 100644 --- a/spec/lib/gitlab/graphql/connections/keyset/query_builder_spec.rb +++ b/spec/lib/gitlab/graphql/pagination/keyset/query_builder_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Gitlab::Graphql::Connections::Keyset::QueryBuilder do +describe Gitlab::Graphql::Pagination::Keyset::QueryBuilder do context 'when number of ordering fields is 0' do it 'raises an error' do expect { described_class.new(Issue.arel_table, [], {}, :after) } @@ -12,7 +12,7 @@ describe Gitlab::Graphql::Connections::Keyset::QueryBuilder do describe '#conditions' do let(:relation) { Issue.order(relative_position: :desc).order(:id) } - let(:order_list) { Gitlab::Graphql::Connections::Keyset::OrderInfo.build_order_list(relation) } + let(:order_list) { Gitlab::Graphql::Pagination::Keyset::OrderInfo.build_order_list(relation) } let(:arel_table) { Issue.arel_table } let(:builder) { described_class.new(arel_table, order_list, decoded_cursor, before_or_after) } let(:before_or_after) { :after } |