Skip to content
Snippets Groups Projects
Commit 5bfb8d1f authored by GitLab Bot's avatar GitLab Bot
Browse files

Add latest changes from gitlab-org/gitlab@master

parent aaf59610
No related branches found
No related tags found
No related merge requests found
Showing
with 37 additions and 30 deletions
Loading
Loading
@@ -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
Loading
Loading
@@ -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
Loading
Loading
Loading
Loading
@@ -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
Loading
Loading
@@ -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
Loading
Loading
@@ -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) }
Loading
Loading
Loading
Loading
@@ -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
Loading
Loading
Loading
Loading
@@ -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)
Loading
Loading
Loading
Loading
@@ -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'],
Loading
Loading
@@ -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
Loading
Loading
@@ -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
Loading
Loading
Loading
Loading
@@ -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")
 
Loading
Loading
@@ -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")
 
Loading
Loading
@@ -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")
Loading
Loading
Loading
Loading
@@ -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}
}
Loading
Loading
@@ -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
Loading
Loading
@@ -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
Loading
Loading
Loading
Loading
@@ -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
 
Loading
Loading
@@ -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
 
Loading
Loading
@@ -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
 
Loading
Loading
Loading
Loading
@@ -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
Loading
Loading
@@ -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
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment