diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-03-18 21:09:35 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-03-18 21:09:35 +0300 |
commit | 5bfb8d1fad825eec90b0af688c7cd1b352c9056e (patch) | |
tree | 385411919c4186d11a769385ad8dafeef6cc36a7 /spec | |
parent | aaf59610548d9b0fd01acfd50e831cbe519ecba2 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec')
40 files changed, 77 insertions, 70 deletions
diff --git a/spec/graphql/features/authorization_spec.rb b/spec/graphql/features/authorization_spec.rb index 44f47e6c739..4f54695e5be 100644 --- a/spec/graphql/features/authorization_spec.rb +++ b/spec/graphql/features/authorization_spec.rb @@ -9,7 +9,7 @@ describe 'Gitlab::Graphql::Authorization' do let(:permission_single) { :foo } let(:permission_collection) { [:foo, :bar] } let(:test_object) { double(name: 'My name') } - let(:query_string) { '{ item() { name } }' } + let(:query_string) { '{ item { name } }' } let(:result) { execute_query(query_type)['data'] } subject { result['item'] } @@ -177,7 +177,7 @@ describe 'Gitlab::Graphql::Authorization' do end describe 'type authorizations when applied to a relay connection' do - let(:query_string) { '{ item() { edges { node { name } } } }' } + let(:query_string) { '{ item { edges { node { name } } } }' } let(:second_test_object) { double(name: 'Second thing') } let(:type) do diff --git a/spec/graphql/features/feature_flag_spec.rb b/spec/graphql/features/feature_flag_spec.rb index 13b1e472fab..51914cf0ca8 100644 --- a/spec/graphql/features/feature_flag_spec.rb +++ b/spec/graphql/features/feature_flag_spec.rb @@ -9,7 +9,7 @@ describe 'Graphql Field feature flags' do let(:feature_flag) { 'test_feature' } let(:test_object) { double(name: 'My name') } - let(:query_string) { '{ item() { name } }' } + let(:query_string) { '{ item { name } }' } let(:result) { execute_query(query_type)['data'] } subject { result } diff --git a/spec/graphql/gitlab_schema_spec.rb b/spec/graphql/gitlab_schema_spec.rb index d0eb0475879..bd22458355c 100644 --- a/spec/graphql/gitlab_schema_spec.rb +++ b/spec/graphql/gitlab_schema_spec.rb @@ -27,11 +27,11 @@ describe GitlabSchema do end it 'has the base mutation' do - expect(described_class.mutation).to eq(::Types::MutationType.to_graphql) + expect(described_class.mutation).to eq(::Types::MutationType) end it 'has the base query' do - expect(described_class.query).to eq(::Types::QueryType.to_graphql) + expect(described_class.query).to eq(::Types::QueryType) end it 'paginates active record relations using `Connections::Keyset::Connection`' do diff --git a/spec/graphql/types/award_emojis/award_emoji_type_spec.rb b/spec/graphql/types/award_emojis/award_emoji_type_spec.rb index 5663a3d7195..de5ece3b749 100644 --- a/spec/graphql/types/award_emojis/award_emoji_type_spec.rb +++ b/spec/graphql/types/award_emojis/award_emoji_type_spec.rb @@ -5,7 +5,7 @@ require 'spec_helper' describe GitlabSchema.types['AwardEmoji'] do it { expect(described_class.graphql_name).to eq('AwardEmoji') } - it { is_expected.to require_graphql_authorizations(:read_emoji) } + it { expect(described_class).to require_graphql_authorizations(:read_emoji) } it { expect(described_class).to have_graphql_fields(:description, :unicode_version, :emoji, :name, :unicode, :user) } end diff --git a/spec/graphql/types/board_type_spec.rb b/spec/graphql/types/board_type_spec.rb index 9d18065bbcd..1ca4bf18b57 100644 --- a/spec/graphql/types/board_type_spec.rb +++ b/spec/graphql/types/board_type_spec.rb @@ -10,6 +10,6 @@ describe GitlabSchema.types['Board'] do it 'has specific fields' do expected_fields = %w[id name] - is_expected.to include_graphql_fields(*expected_fields) + expect(described_class).to include_graphql_fields(*expected_fields) end end diff --git a/spec/graphql/types/diff_refs_type_spec.rb b/spec/graphql/types/diff_refs_type_spec.rb index 85225e5809c..a6ead27455f 100644 --- a/spec/graphql/types/diff_refs_type_spec.rb +++ b/spec/graphql/types/diff_refs_type_spec.rb @@ -5,7 +5,7 @@ require 'spec_helper' describe GitlabSchema.types['DiffRefs'] do it { expect(described_class.graphql_name).to eq('DiffRefs') } - it { is_expected.to have_graphql_fields(:head_sha, :base_sha, :start_sha).only } + it { expect(described_class).to have_graphql_fields(:head_sha, :base_sha, :start_sha).only } it { expect(described_class.fields['headSha'].type).to be_non_null } it { expect(described_class.fields['baseSha'].type).not_to be_non_null } diff --git a/spec/graphql/types/environment_type_spec.rb b/spec/graphql/types/environment_type_spec.rb index cf30893b3ca..9e8f13e4c2e 100644 --- a/spec/graphql/types/environment_type_spec.rb +++ b/spec/graphql/types/environment_type_spec.rb @@ -10,8 +10,8 @@ describe GitlabSchema.types['Environment'] do name id ] - is_expected.to have_graphql_fields(*expected_fields) + expect(described_class).to have_graphql_fields(*expected_fields) end - it { is_expected.to require_graphql_authorizations(:read_environment) } + it { expect(described_class).to require_graphql_authorizations(:read_environment) } end diff --git a/spec/graphql/types/error_tracking/sentry_detailed_error_type_spec.rb b/spec/graphql/types/error_tracking/sentry_detailed_error_type_spec.rb index 3a512fee3b3..44652f831b5 100644 --- a/spec/graphql/types/error_tracking/sentry_detailed_error_type_spec.rb +++ b/spec/graphql/types/error_tracking/sentry_detailed_error_type_spec.rb @@ -37,6 +37,6 @@ describe GitlabSchema.types['SentryDetailedError'] do tags ] - is_expected.to have_graphql_fields(*expected_fields) + expect(described_class).to have_graphql_fields(*expected_fields) end end diff --git a/spec/graphql/types/error_tracking/sentry_error_collection_type_spec.rb b/spec/graphql/types/error_tracking/sentry_error_collection_type_spec.rb index 3de0a359c15..20ec31391d8 100644 --- a/spec/graphql/types/error_tracking/sentry_error_collection_type_spec.rb +++ b/spec/graphql/types/error_tracking/sentry_error_collection_type_spec.rb @@ -15,7 +15,7 @@ describe GitlabSchema.types['SentryErrorCollection'] do error_stack_trace ] - is_expected.to have_graphql_fields(*expected_fields) + expect(described_class).to have_graphql_fields(*expected_fields) end describe 'errors field' do diff --git a/spec/graphql/types/error_tracking/sentry_error_stack_trace_entry_type_spec.rb b/spec/graphql/types/error_tracking/sentry_error_stack_trace_entry_type_spec.rb index ce5fade6fcc..05cc2ca7612 100644 --- a/spec/graphql/types/error_tracking/sentry_error_stack_trace_entry_type_spec.rb +++ b/spec/graphql/types/error_tracking/sentry_error_stack_trace_entry_type_spec.rb @@ -14,6 +14,6 @@ describe GitlabSchema.types['SentryErrorStackTraceEntry'] do trace_context ] - is_expected.to have_graphql_fields(*expected_fields) + expect(described_class).to have_graphql_fields(*expected_fields) end end diff --git a/spec/graphql/types/error_tracking/sentry_error_stack_trace_type_spec.rb b/spec/graphql/types/error_tracking/sentry_error_stack_trace_type_spec.rb index ac41e6903e5..2a422228f72 100644 --- a/spec/graphql/types/error_tracking/sentry_error_stack_trace_type_spec.rb +++ b/spec/graphql/types/error_tracking/sentry_error_stack_trace_type_spec.rb @@ -14,6 +14,6 @@ describe GitlabSchema.types['SentryErrorStackTrace'] do stack_trace_entries ] - is_expected.to have_graphql_fields(*expected_fields) + expect(described_class).to have_graphql_fields(*expected_fields) end end diff --git a/spec/graphql/types/error_tracking/sentry_error_type_spec.rb b/spec/graphql/types/error_tracking/sentry_error_type_spec.rb index 51acd035024..4676d91ef9c 100644 --- a/spec/graphql/types/error_tracking/sentry_error_type_spec.rb +++ b/spec/graphql/types/error_tracking/sentry_error_type_spec.rb @@ -26,6 +26,6 @@ describe GitlabSchema.types['SentryError'] do frequency ] - is_expected.to have_graphql_fields(*expected_fields) + expect(described_class).to have_graphql_fields(*expected_fields) end end diff --git a/spec/graphql/types/grafana_integration_type_spec.rb b/spec/graphql/types/grafana_integration_type_spec.rb index ddfedc5a75c..ac26911acbf 100644 --- a/spec/graphql/types/grafana_integration_type_spec.rb +++ b/spec/graphql/types/grafana_integration_type_spec.rb @@ -18,5 +18,5 @@ describe GitlabSchema.types['GrafanaIntegration'] do it { expect(described_class).to require_graphql_authorizations(:admin_operations) } - it { is_expected.to have_graphql_fields(*expected_fields) } + it { expect(described_class).to have_graphql_fields(*expected_fields) } end diff --git a/spec/graphql/types/group_type_spec.rb b/spec/graphql/types/group_type_spec.rb index 240dd9fa5e2..532f1a4b53d 100644 --- a/spec/graphql/types/group_type_spec.rb +++ b/spec/graphql/types/group_type_spec.rb @@ -19,7 +19,7 @@ describe GitlabSchema.types['Group'] do mentions_disabled parent boards ] - is_expected.to include_graphql_fields(*expected_fields) + expect(described_class).to include_graphql_fields(*expected_fields) end describe 'boards field' do diff --git a/spec/graphql/types/issue_type_spec.rb b/spec/graphql/types/issue_type_spec.rb index daa2224ef20..ebe48c17c11 100644 --- a/spec/graphql/types/issue_type_spec.rb +++ b/spec/graphql/types/issue_type_spec.rb @@ -9,7 +9,7 @@ describe GitlabSchema.types['Issue'] do it { expect(described_class).to require_graphql_authorizations(:read_issue) } - it { expect(described_class.interfaces).to include(Types::Notes::NoteableType.to_graphql) } + it { expect(described_class.interfaces).to include(Types::Notes::NoteableType) } it 'has specific fields' do fields = %i[iid title description state reference author assignees participants labels milestone due_date diff --git a/spec/graphql/types/label_type_spec.rb b/spec/graphql/types/label_type_spec.rb index a023a75eeff..71b86d9b528 100644 --- a/spec/graphql/types/label_type_spec.rb +++ b/spec/graphql/types/label_type_spec.rb @@ -5,8 +5,8 @@ describe GitlabSchema.types['Label'] do it 'has the correct fields' do expected_fields = [:id, :description, :description_html, :title, :color, :text_color] - is_expected.to have_graphql_fields(*expected_fields) + expect(described_class).to have_graphql_fields(*expected_fields) end - it { is_expected.to require_graphql_authorizations(:read_label) } + it { expect(described_class).to require_graphql_authorizations(:read_label) } end diff --git a/spec/graphql/types/merge_request_type_spec.rb b/spec/graphql/types/merge_request_type_spec.rb index 04e9bb6861f..0c83ebd3de9 100644 --- a/spec/graphql/types/merge_request_type_spec.rb +++ b/spec/graphql/types/merge_request_type_spec.rb @@ -7,7 +7,7 @@ describe GitlabSchema.types['MergeRequest'] do it { expect(described_class).to require_graphql_authorizations(:read_merge_request) } - it { expect(described_class.interfaces).to include(Types::Notes::NoteableType.to_graphql) } + it { expect(described_class.interfaces).to include(Types::Notes::NoteableType) } it 'has the expected fields' do expected_fields = %w[ @@ -25,6 +25,6 @@ describe GitlabSchema.types['MergeRequest'] do total_time_spent reference ] - is_expected.to have_graphql_fields(*expected_fields) + expect(described_class).to have_graphql_fields(*expected_fields) end end diff --git a/spec/graphql/types/metadata_type_spec.rb b/spec/graphql/types/metadata_type_spec.rb index 2988f3c6ba5..c8270a8c2f5 100644 --- a/spec/graphql/types/metadata_type_spec.rb +++ b/spec/graphql/types/metadata_type_spec.rb @@ -4,5 +4,5 @@ require 'spec_helper' describe GitlabSchema.types['Metadata'] do it { expect(described_class.graphql_name).to eq('Metadata') } - it { is_expected.to require_graphql_authorizations(:read_instance_metadata) } + it { expect(described_class).to require_graphql_authorizations(:read_instance_metadata) } end diff --git a/spec/graphql/types/namespace_type_spec.rb b/spec/graphql/types/namespace_type_spec.rb index f476dd7286f..6c2ba70cf4c 100644 --- a/spec/graphql/types/namespace_type_spec.rb +++ b/spec/graphql/types/namespace_type_spec.rb @@ -11,8 +11,8 @@ describe GitlabSchema.types['Namespace'] do lfs_enabled request_access_enabled projects root_storage_statistics ] - is_expected.to have_graphql_fields(*expected_fields) + expect(described_class).to have_graphql_fields(*expected_fields) end - it { is_expected.to require_graphql_authorizations(:read_namespace) } + it { expect(described_class).to require_graphql_authorizations(:read_namespace) } end diff --git a/spec/graphql/types/notes/diff_position_type_spec.rb b/spec/graphql/types/notes/diff_position_type_spec.rb index aa08daaacd4..01f355cb278 100644 --- a/spec/graphql/types/notes/diff_position_type_spec.rb +++ b/spec/graphql/types/notes/diff_position_type_spec.rb @@ -7,6 +7,6 @@ describe GitlabSchema.types['DiffPosition'] do :new_path, :position_type, :old_line, :new_line, :x, :y, :width, :height] - is_expected.to have_graphql_fields(*expected_fields) + expect(described_class).to have_graphql_fields(*expected_fields) end end diff --git a/spec/graphql/types/notes/discussion_type_spec.rb b/spec/graphql/types/notes/discussion_type_spec.rb index ba7fc961212..804785ba67d 100644 --- a/spec/graphql/types/notes/discussion_type_spec.rb +++ b/spec/graphql/types/notes/discussion_type_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' describe GitlabSchema.types['Discussion'] do - it { is_expected.to have_graphql_fields(:id, :created_at, :notes, :reply_id) } + it { expect(described_class).to have_graphql_fields(:id, :created_at, :notes, :reply_id) } - it { is_expected.to require_graphql_authorizations(:read_note) } + it { expect(described_class).to require_graphql_authorizations(:read_note) } end diff --git a/spec/graphql/types/notes/note_type_spec.rb b/spec/graphql/types/notes/note_type_spec.rb index e8a58da4b17..809f54c120c 100644 --- a/spec/graphql/types/notes/note_type_spec.rb +++ b/spec/graphql/types/notes/note_type_spec.rb @@ -7,9 +7,9 @@ describe GitlabSchema.types['Note'] do :updated_at, :discussion, :resolvable, :position, :user_permissions, :resolved_by, :resolved_at, :system, :body_html] - is_expected.to have_graphql_fields(*expected_fields) + expect(described_class).to have_graphql_fields(*expected_fields) end - it { is_expected.to expose_permissions_using(Types::PermissionTypes::Note) } - it { is_expected.to require_graphql_authorizations(:read_note) } + it { expect(described_class).to expose_permissions_using(Types::PermissionTypes::Note) } + it { expect(described_class).to require_graphql_authorizations(:read_note) } end diff --git a/spec/graphql/types/notes/noteable_type_spec.rb b/spec/graphql/types/notes/noteable_type_spec.rb index d10c79b5344..a4259e160e0 100644 --- a/spec/graphql/types/notes/noteable_type_spec.rb +++ b/spec/graphql/types/notes/noteable_type_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' describe Types::Notes::NoteableType do - it { is_expected.to have_graphql_fields(:notes, :discussions) } + it { expect(described_class).to have_graphql_fields(:notes, :discussions) } describe ".resolve_type" do it 'knows the correct type for objects' do diff --git a/spec/graphql/types/permission_types/base_permission_type_spec.rb b/spec/graphql/types/permission_types/base_permission_type_spec.rb index aa6b4320006..4c6d5fd369a 100644 --- a/spec/graphql/types/permission_types/base_permission_type_spec.rb +++ b/spec/graphql/types/permission_types/base_permission_type_spec.rb @@ -19,13 +19,13 @@ describe Types::PermissionTypes::BasePermissionType do describe '.permission_field' do it 'adds a field for the required permission' do - is_expected.to have_graphql_field(:do_stuff) + expect(test_type).to have_graphql_field(:do_stuff) end end describe '.ability_field' do it 'adds a field for the required permission' do - is_expected.to have_graphql_field(:read_issue) + expect(test_type).to have_graphql_field(:read_issue) end it 'does not add a resolver block if another resolving param is passed' do @@ -44,7 +44,7 @@ describe Types::PermissionTypes::BasePermissionType do describe '.abilities' do it 'adds a field for the passed permissions' do - is_expected.to have_graphql_field(:admin_issue) + expect(test_type).to have_graphql_field(:admin_issue) end end end diff --git a/spec/graphql/types/permission_types/note_spec.rb b/spec/graphql/types/permission_types/note_spec.rb index a7811fc20e5..a2becb6892b 100644 --- a/spec/graphql/types/permission_types/note_spec.rb +++ b/spec/graphql/types/permission_types/note_spec.rb @@ -8,6 +8,6 @@ describe GitlabSchema.types['NotePermissions'] do :read_note, :create_note, :admin_note, :resolve_note, :award_emoji ] - is_expected.to have_graphql_fields(expected_permissions) + expect(described_class).to have_graphql_fields(expected_permissions) end end diff --git a/spec/graphql/types/project_statistics_type_spec.rb b/spec/graphql/types/project_statistics_type_spec.rb index e9feac57a36..fbea780494b 100644 --- a/spec/graphql/types/project_statistics_type_spec.rb +++ b/spec/graphql/types/project_statistics_type_spec.rb @@ -4,7 +4,7 @@ require 'spec_helper' describe GitlabSchema.types['ProjectStatistics'] do it "has all the required fields" do - is_expected.to have_graphql_fields(:storage_size, :repository_size, :lfs_objects_size, + expect(described_class).to have_graphql_fields(:storage_size, :repository_size, :lfs_objects_size, :build_artifacts_size, :packages_size, :commit_count, :wiki_size) end diff --git a/spec/graphql/types/project_type_spec.rb b/spec/graphql/types/project_type_spec.rb index 9c6d1e3f35c..475ae9ff5f6 100644 --- a/spec/graphql/types/project_type_spec.rb +++ b/spec/graphql/types/project_type_spec.rb @@ -27,7 +27,7 @@ describe GitlabSchema.types['Project'] do boards ] - is_expected.to include_graphql_fields(*expected_fields) + expect(described_class).to include_graphql_fields(*expected_fields) end describe 'issue field' do diff --git a/spec/graphql/types/repository_type_spec.rb b/spec/graphql/types/repository_type_spec.rb index 236f9bb9459..f746e75b574 100644 --- a/spec/graphql/types/repository_type_spec.rb +++ b/spec/graphql/types/repository_type_spec.rb @@ -7,7 +7,7 @@ describe GitlabSchema.types['Repository'] do it { expect(described_class).to require_graphql_authorizations(:download_code) } - it { is_expected.to have_graphql_field(:root_ref) } + it { expect(described_class).to have_graphql_field(:root_ref) } - it { is_expected.to have_graphql_field(:tree) } + it { expect(described_class).to have_graphql_field(:tree) } end diff --git a/spec/graphql/types/root_storage_statistics_type_spec.rb b/spec/graphql/types/root_storage_statistics_type_spec.rb index 8c69c13aa73..b796b974b82 100644 --- a/spec/graphql/types/root_storage_statistics_type_spec.rb +++ b/spec/graphql/types/root_storage_statistics_type_spec.rb @@ -6,9 +6,9 @@ describe GitlabSchema.types['RootStorageStatistics'] do it { expect(described_class.graphql_name).to eq('RootStorageStatistics') } it 'has all the required fields' do - is_expected.to have_graphql_fields(:storage_size, :repository_size, :lfs_objects_size, + expect(described_class).to have_graphql_fields(:storage_size, :repository_size, :lfs_objects_size, :build_artifacts_size, :packages_size, :wiki_size) end - it { is_expected.to require_graphql_authorizations(:read_statistics) } + it { expect(described_class).to require_graphql_authorizations(:read_statistics) } end diff --git a/spec/graphql/types/snippet_type_spec.rb b/spec/graphql/types/snippet_type_spec.rb index 97573f8c46b..afac480d06b 100644 --- a/spec/graphql/types/snippet_type_spec.rb +++ b/spec/graphql/types/snippet_type_spec.rb @@ -10,7 +10,7 @@ describe GitlabSchema.types['Snippet'] do :web_url, :raw_url, :notes, :discussions, :user_permissions, :description_html, :blob] - is_expected.to have_graphql_fields(*expected_fields) + expect(described_class).to have_graphql_fields(*expected_fields) end describe 'authorizations' do diff --git a/spec/graphql/types/snippets/blob_type_spec.rb b/spec/graphql/types/snippets/blob_type_spec.rb index b6253e96d60..da36ab80f44 100644 --- a/spec/graphql/types/snippets/blob_type_spec.rb +++ b/spec/graphql/types/snippets/blob_type_spec.rb @@ -8,6 +8,6 @@ describe GitlabSchema.types['SnippetBlob'] do :raw_path, :size, :binary, :name, :path, :simple_viewer, :rich_viewer, :mode] - is_expected.to have_graphql_fields(*expected_fields) + expect(described_class).to have_graphql_fields(*expected_fields) end end diff --git a/spec/graphql/types/snippets/blob_viewer_type_spec.rb b/spec/graphql/types/snippets/blob_viewer_type_spec.rb index f1f7608cb69..a51d09813ab 100644 --- a/spec/graphql/types/snippets/blob_viewer_type_spec.rb +++ b/spec/graphql/types/snippets/blob_viewer_type_spec.rb @@ -7,6 +7,6 @@ describe GitlabSchema.types['SnippetBlobViewer'] do expected_fields = [:type, :load_async, :too_large, :collapsed, :render_error, :file_type, :loading_partial_name] - is_expected.to have_graphql_fields(*expected_fields) + expect(described_class).to have_graphql_fields(*expected_fields) end end diff --git a/spec/graphql/types/todo_type_spec.rb b/spec/graphql/types/todo_type_spec.rb index a5ea5bcffb0..59118259d09 100644 --- a/spec/graphql/types/todo_type_spec.rb +++ b/spec/graphql/types/todo_type_spec.rb @@ -6,7 +6,7 @@ describe GitlabSchema.types['Todo'] do it 'has the correct fields' do expected_fields = [:id, :project, :group, :author, :action, :target_type, :body, :state, :created_at] - is_expected.to have_graphql_fields(*expected_fields) + expect(described_class).to have_graphql_fields(*expected_fields) end it { expect(described_class).to require_graphql_authorizations(:read_todo) } diff --git a/spec/graphql/types/user_type_spec.rb b/spec/graphql/types/user_type_spec.rb index b9174b9a90b..8c76ce43e95 100644 --- a/spec/graphql/types/user_type_spec.rb +++ b/spec/graphql/types/user_type_spec.rb @@ -12,7 +12,7 @@ describe GitlabSchema.types['User'] do user_permissions snippets name username avatarUrl webUrl todos ] - is_expected.to have_graphql_fields(*expected_fields) + expect(described_class).to have_graphql_fields(*expected_fields) end describe 'snippets field' do diff --git a/spec/lib/feature_spec.rb b/spec/lib/feature_spec.rb index cbe617359ef..2890b8d4f3b 100644 --- a/spec/lib/feature_spec.rb +++ b/spec/lib/feature_spec.rb @@ -42,7 +42,7 @@ describe Feature do .once .and_call_original - expect(Gitlab::ThreadMemoryCache.cache_backend) + expect(Gitlab::ProcessMemoryCache.cache_backend) .to receive(:fetch) .once .with('flipper:persisted_names', expires_in: 1.minute) diff --git a/spec/rubocop/cop/migration/safer_boolean_column_spec.rb b/spec/rubocop/cop/migration/safer_boolean_column_spec.rb index 915b73ed5a7..b27a4cd4f80 100644 --- a/spec/rubocop/cop/migration/safer_boolean_column_spec.rb +++ b/spec/rubocop/cop/migration/safer_boolean_column_spec.rb @@ -17,7 +17,7 @@ describe RuboCop::Cop::Migration::SaferBooleanColumn do allow(cop).to receive(:in_migration?).and_return(true) end - described_class::SMALL_TABLES.each do |table| + described_class::WHITELISTED_TABLES.each do |table| context "for the #{table} table" do sources_and_offense = [ ["add_column :#{table}, :column, :boolean, default: true", 'should disallow nulls'], @@ -62,14 +62,14 @@ describe RuboCop::Cop::Migration::SaferBooleanColumn do end end - it 'registers no offense for tables not listed in SMALL_TABLES' do + it 'registers no offense for tables not listed in WHITELISTED_TABLES' do inspect_source("add_column :large_table, :column, :boolean") expect(cop.offenses).to be_empty end it 'registers no offense for non-boolean columns' do - table = described_class::SMALL_TABLES.sample + table = described_class::WHITELISTED_TABLES.sample inspect_source("add_column :#{table}, :column, :string") expect(cop.offenses).to be_empty @@ -78,7 +78,7 @@ describe RuboCop::Cop::Migration::SaferBooleanColumn do context 'outside of migration' do it 'registers no offense' do - table = described_class::SMALL_TABLES.sample + table = described_class::WHITELISTED_TABLES.sample inspect_source("add_column :#{table}, :column, :boolean") expect(cop.offenses).to be_empty diff --git a/spec/rubocop/cop/migration/update_large_table_spec.rb b/spec/rubocop/cop/migration/update_large_table_spec.rb index 0463b6550a8..bdb0ca3466b 100644 --- a/spec/rubocop/cop/migration/update_large_table_spec.rb +++ b/spec/rubocop/cop/migration/update_large_table_spec.rb @@ -18,7 +18,7 @@ describe RuboCop::Cop::Migration::UpdateLargeTable do end shared_examples 'large tables' do |update_method| - described_class::LARGE_TABLES.each do |table| + described_class::BLACKLISTED_TABLES.each do |table| it "registers an offense for the #{table} table" do inspect_source("#{update_method} :#{table}, :column, default: true") @@ -53,7 +53,7 @@ describe RuboCop::Cop::Migration::UpdateLargeTable do end it 'registers no offense for non-blacklisted methods' do - table = described_class::LARGE_TABLES.sample + table = described_class::BLACKLISTED_TABLES.sample inspect_source("some_other_method :#{table}, :column, default: true") @@ -62,7 +62,7 @@ describe RuboCop::Cop::Migration::UpdateLargeTable do end context 'outside of migration' do - let(:table) { described_class::LARGE_TABLES.sample } + let(:table) { described_class::BLACKLISTED_TABLES.sample } it 'registers no offense for add_column_with_default' do inspect_source("add_column_with_default :#{table}, :column, default: true") diff --git a/spec/support/helpers/graphql_helpers.rb b/spec/support/helpers/graphql_helpers.rb index 370162b45f0..1bb942ff39b 100644 --- a/spec/support/helpers/graphql_helpers.rb +++ b/spec/support/helpers/graphql_helpers.rb @@ -71,10 +71,10 @@ module GraphqlHelpers mutation_name = GraphqlHelpers.fieldnamerize(name) input_variable_name = "$#{input_variable_name_for_mutation(name)}" mutation_field = GitlabSchema.mutation.fields[mutation_name] - fields ||= all_graphql_fields_for(mutation_field.type) + fields ||= all_graphql_fields_for(mutation_field.type.to_graphql) query = <<~MUTATION - mutation(#{input_variable_name}: #{mutation_field.arguments['input'].type}) { + mutation(#{input_variable_name}: #{mutation_field.arguments['input'].type.to_graphql}) { #{mutation_name}(input: #{input_variable_name}) { #{fields} } @@ -118,15 +118,22 @@ module GraphqlHelpers GraphqlHelpers.fieldnamerize(input_type) end - def query_graphql_field(name, attributes = {}, fields = nil) - field_params = if attributes.present? + def field_with_params(name, attributes = {}) + namerized = GraphqlHelpers.fieldnamerize(name.to_s) + return "#{namerized}" if attributes.blank? + + field_params = if attributes.is_a?(Hash) "(#{attributes_to_graphql(attributes)})" else - '' + "(#{attributes})" end + "#{namerized}#{field_params}" + end + + def query_graphql_field(name, attributes = {}, fields = nil) <<~QUERY - #{GraphqlHelpers.fieldnamerize(name.to_s)}#{field_params} + #{field_with_params(name, attributes)} #{wrap_fields(fields || all_graphql_fields_for(name.to_s.classify))} QUERY end @@ -300,7 +307,7 @@ module GraphqlHelpers end def field_type(field) - field_type = field.type + field_type = field.type.respond_to?(:to_graphql) ? field.type.to_graphql : field.type # The type could be nested. For example `[GraphQL::STRING_TYPE]`: # - List diff --git a/spec/support/matchers/graphql_matchers.rb b/spec/support/matchers/graphql_matchers.rb index 31b0290bb15..6439b68764e 100644 --- a/spec/support/matchers/graphql_matchers.rb +++ b/spec/support/matchers/graphql_matchers.rb @@ -2,7 +2,7 @@ RSpec::Matchers.define :require_graphql_authorizations do |*expected| match do |field| - expect(field.metadata[:authorize]).to eq(*expected) + expect(field.to_graphql.metadata[:authorize]).to eq(*expected) end end @@ -87,13 +87,13 @@ end RSpec::Matchers.define :have_graphql_type do |expected| match do |field| - expect(field.type).to eq(expected.to_graphql) + expect(field.type).to eq(expected) end end RSpec::Matchers.define :have_non_null_graphql_type do |expected| match do |field| - expect(field.type).to eq(!expected.to_graphql) + expect(field.type.to_graphql).to eq(!expected.to_graphql) end end @@ -101,16 +101,16 @@ RSpec::Matchers.define :have_graphql_resolver do |expected| match do |field| case expected when Method - expect(field.metadata[:type_class].resolve_proc).to eq(expected) + expect(field.to_graphql.metadata[:type_class].resolve_proc).to eq(expected) else - expect(field.metadata[:type_class].resolver).to eq(expected) + expect(field.to_graphql.metadata[:type_class].resolver).to eq(expected) end end end RSpec::Matchers.define :have_graphql_extension do |expected| match do |field| - expect(field.metadata[:type_class].extensions).to include(expected) + expect(field.to_graphql.metadata[:type_class].extensions).to include(expected) end end diff --git a/spec/support/shared_contexts/requests/api/graphql/group_and_project_boards_query_shared_context.rb b/spec/support/shared_contexts/requests/api/graphql/group_and_project_boards_query_shared_context.rb index ca77c68c130..4c80bbef153 100644 --- a/spec/support/shared_contexts/requests/api/graphql/group_and_project_boards_query_shared_context.rb +++ b/spec/support/shared_contexts/requests/api/graphql/group_and_project_boards_query_shared_context.rb @@ -15,7 +15,7 @@ RSpec.shared_context 'group and project boards query context' do board_parent_type, { 'fullPath' => board_parent.full_path }, <<~BOARDS - boards(#{board_params}) { + #{field_with_params('boards', board_params)} { pageInfo { startCursor endCursor @@ -35,7 +35,7 @@ RSpec.shared_context 'group and project boards query context' do board_parent_type, { 'fullPath' => board_parent.full_path }, <<~BOARD - board(#{board_params}) { + #{field_with_params('board', board_params)} { #{all_graphql_fields_for('board'.classify)} } BOARD |