Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2022-05-21 06:09:38 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2022-05-21 06:09:38 +0300
commit0437174fea59d64514b3e23dec3d10d8fac90a3e (patch)
treea431a94ca3ad61289028981123f72a02d6cb5efd /spec
parent0fd09fff507a22e2059bcfe11cfc4e657590c72c (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec')
-rw-r--r--spec/graphql/features/authorization_spec.rb20
-rw-r--r--spec/graphql/mutations/boards/issues/issue_move_list_spec.rb2
-rw-r--r--spec/graphql/mutations/ci/runner/update_spec.rb3
-rw-r--r--spec/graphql/mutations/release_asset_links/create_spec.rb2
-rw-r--r--spec/graphql/mutations/security/ci_configuration/base_security_analyzer_spec.rb4
-rw-r--r--spec/graphql/resolvers/group_labels_resolver_spec.rb2
-rw-r--r--spec/graphql/resolvers/incident_management/timeline_events_resolver_spec.rb3
-rw-r--r--spec/graphql/resolvers/issue_status_counts_resolver_spec.rb2
-rw-r--r--spec/lib/gitlab/graphql/pagination/keyset/connection_generic_keyset_spec.rb3
-rw-r--r--spec/lib/gitlab/graphql/pagination/keyset/connection_spec.rb3
-rw-r--r--spec/support/shared_examples/graphql/mutations/security/ci_configuration_shared_examples.rb6
11 files changed, 26 insertions, 24 deletions
diff --git a/spec/graphql/features/authorization_spec.rb b/spec/graphql/features/authorization_spec.rb
index 514f63a6f5a..1d518e20da7 100644
--- a/spec/graphql/features/authorization_spec.rb
+++ b/spec/graphql/features/authorization_spec.rb
@@ -10,7 +10,7 @@ RSpec.describe 'DeclarativePolicy authorization in GraphQL ' do
let(:permission_single) { :foo }
let(:permission_collection) { [:foo, :bar] }
- let(:test_object) { double(name: 'My name') }
+ let(:test_object) { double(name: 'My name', address: 'Worldwide') }
let(:authorizing_object) { test_object }
# to override when combining permissions
let(:permission_object_one) { authorizing_object }
@@ -103,47 +103,47 @@ RSpec.describe 'DeclarativePolicy authorization in GraphQL ' do
end
describe 'with a single permission' do
+ let(:query_string) { '{ item { name address } }' }
let(:type) do
type_factory do |type|
- type.field :name, GraphQL::Types::String, null: true, authorize: permission_single
+ type.field :address, GraphQL::Types::String, null: true, authorize: permission_single
end
end
it 'returns the protected field when user has permission' do
permit(permission_single)
- expect(subject).to eq('name' => test_object.name)
+ expect(subject).to include('address' => test_object.address)
end
it 'returns nil when user is not authorized' do
- expect(subject).to eq('name' => nil)
+ expect(subject).to include('address' => nil)
end
end
describe 'with a collection of permissions' do
+ let(:query_string) { '{ item { name address } }' }
let(:type) do
permissions = permission_collection
type_factory do |type|
- type.field :name, GraphQL::Types::String,
- null: true,
- authorize: permissions
+ type.field :address, GraphQL::Types::String, null: true, authorize: permissions
end
end
it 'returns the protected field when user has all permissions' do
permit(*permission_collection)
- expect(subject).to eq('name' => test_object.name)
+ expect(subject).to include('address' => test_object.address)
end
it 'returns nil when user only has one of the permissions' do
permit(permission_collection.first)
- expect(subject).to eq('name' => nil)
+ expect(subject).to include('address' => nil)
end
it 'returns nil when user only has none of the permissions' do
- expect(subject).to eq('name' => nil)
+ expect(subject).to include('address' => nil)
end
end
end
diff --git a/spec/graphql/mutations/boards/issues/issue_move_list_spec.rb b/spec/graphql/mutations/boards/issues/issue_move_list_spec.rb
index 11c0fa44110..b9d19b68001 100644
--- a/spec/graphql/mutations/boards/issues/issue_move_list_spec.rb
+++ b/spec/graphql/mutations/boards/issues/issue_move_list_spec.rb
@@ -19,7 +19,7 @@ RSpec.describe Mutations::Boards::Issues::IssueMoveList do
let_it_be(:existing_issue2) { create(:labeled_issue, project: project, labels: [testing], relative_position: 50) }
let(:current_ctx) { { current_user: user } }
- let(:params) { { board_id: global_id_of(board), project_path: project.full_path, iid: issue1.iid } }
+ let(:params) { { board_id: global_id_of(board), project_path: project.full_path, iid: issue1.iid.to_s } }
let(:move_params) do
{
from_list_id: list1.id,
diff --git a/spec/graphql/mutations/ci/runner/update_spec.rb b/spec/graphql/mutations/ci/runner/update_spec.rb
index b8efd4213fa..ffaa6e93d1b 100644
--- a/spec/graphql/mutations/ci/runner/update_spec.rb
+++ b/spec/graphql/mutations/ci/runner/update_spec.rb
@@ -2,11 +2,12 @@
require 'spec_helper'
-RSpec.describe Mutations::Ci::Runner::Update do
+RSpec.describe 'Mutations::Ci::Runner::Update' do
include GraphqlHelpers
let_it_be(:user) { create(:user) }
let_it_be(:runner) { create(:ci_runner, active: true, locked: false, run_untagged: true) }
+ let_it_be(:described_class) { Mutations::Ci::Runner::Update }
let(:current_ctx) { { current_user: user } }
let(:mutated_runner) { subject[:runner] }
diff --git a/spec/graphql/mutations/release_asset_links/create_spec.rb b/spec/graphql/mutations/release_asset_links/create_spec.rb
index 86a6c77fa3f..a5291a00799 100644
--- a/spec/graphql/mutations/release_asset_links/create_spec.rb
+++ b/spec/graphql/mutations/release_asset_links/create_spec.rb
@@ -37,7 +37,7 @@ RSpec.describe Mutations::ReleaseAssetLinks::Create do
context 'when the user has access and no validation errors occur' do
it 'creates a new release asset link', :aggregate_failures do
- expect(subject).to eq({
+ expect(subject).to include({
link: release.reload.links.first,
errors: []
})
diff --git a/spec/graphql/mutations/security/ci_configuration/base_security_analyzer_spec.rb b/spec/graphql/mutations/security/ci_configuration/base_security_analyzer_spec.rb
index 818a7d303bd..668768189df 100644
--- a/spec/graphql/mutations/security/ci_configuration/base_security_analyzer_spec.rb
+++ b/spec/graphql/mutations/security/ci_configuration/base_security_analyzer_spec.rb
@@ -7,8 +7,10 @@ RSpec.describe Mutations::Security::CiConfiguration::BaseSecurityAnalyzer do
it 'raises a NotImplementedError error if the resolve method is called on the base class' do
user = create(:user)
+ mutation = described_class.new(context: { current_user: user }, object: nil, field: nil)
project = create(:project, :public, :repository)
project.add_developer(user)
- expect { resolve(described_class, args: { project_path: project.full_path }, ctx: { current_user: user }) }.to raise_error(NotImplementedError)
+
+ expect { mutation.resolve(project_path: project.full_path ) }.to raise_error(NotImplementedError)
end
end
diff --git a/spec/graphql/resolvers/group_labels_resolver_spec.rb b/spec/graphql/resolvers/group_labels_resolver_spec.rb
index 2031e534703..71290885e6b 100644
--- a/spec/graphql/resolvers/group_labels_resolver_spec.rb
+++ b/spec/graphql/resolvers/group_labels_resolver_spec.rb
@@ -38,7 +38,7 @@ RSpec.describe Resolvers::GroupLabelsResolver do
it 'does not raise error' do
group.add_guest(current_user)
- expect { resolve_labels(subgroup) }.not_to raise_error
+ expect(resolve_labels(subgroup)).to be_instance_of(Gitlab::Graphql::Pagination::Keyset::Connection)
end
end
diff --git a/spec/graphql/resolvers/incident_management/timeline_events_resolver_spec.rb b/spec/graphql/resolvers/incident_management/timeline_events_resolver_spec.rb
index 046cf242d56..6604141abfe 100644
--- a/spec/graphql/resolvers/incident_management/timeline_events_resolver_spec.rb
+++ b/spec/graphql/resolvers/incident_management/timeline_events_resolver_spec.rb
@@ -2,9 +2,10 @@
require 'spec_helper'
-RSpec.describe Resolvers::IncidentManagement::TimelineEventsResolver do
+RSpec.describe 'Resolvers::IncidentManagement::TimelineEventsResolver' do
include GraphqlHelpers
+ let_it_be(:described_class) { Resolvers::IncidentManagement::TimelineEventsResolver }
let_it_be(:current_user) { create(:user) }
let_it_be(:project) { create(:project) }
let_it_be(:incident) { create(:incident, project: project) }
diff --git a/spec/graphql/resolvers/issue_status_counts_resolver_spec.rb b/spec/graphql/resolvers/issue_status_counts_resolver_spec.rb
index 77f4ce4cac5..86a4154f23b 100644
--- a/spec/graphql/resolvers/issue_status_counts_resolver_spec.rb
+++ b/spec/graphql/resolvers/issue_status_counts_resolver_spec.rb
@@ -70,7 +70,7 @@ RSpec.describe Resolvers::IssueStatusCountsResolver do
end
context 'when both assignee_username and assignee_usernames are provided' do
- it 'generates a mutually exclusive filter error' do
+ it 'returns a mutually exclusive filter error' do
expect_graphql_error_to_be_created(Gitlab::Graphql::Errors::ArgumentError, 'only one of [assigneeUsernames, assigneeUsername] arguments is allowed at the same time.') do
resolve_issue_status_counts(assignee_usernames: [current_user.username], assignee_username: current_user.username)
end
diff --git a/spec/lib/gitlab/graphql/pagination/keyset/connection_generic_keyset_spec.rb b/spec/lib/gitlab/graphql/pagination/keyset/connection_generic_keyset_spec.rb
index b6c3cb4e04a..13079150a81 100644
--- a/spec/lib/gitlab/graphql/pagination/keyset/connection_generic_keyset_spec.rb
+++ b/spec/lib/gitlab/graphql/pagination/keyset/connection_generic_keyset_spec.rb
@@ -9,8 +9,7 @@ RSpec.describe Gitlab::Graphql::Pagination::Keyset::Connection do
# The spec will be merged with connection_spec.rb in the future.
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(:schema) { empty_schema }
let(:context) { GraphQL::Query::Context.new(query: query_double(schema: schema), values: nil, object: nil) }
let_it_be(:column_order_id) { Gitlab::Pagination::Keyset::ColumnOrderDefinition.new(attribute_name: 'id', order_expression: Project.arel_table[:id].asc) }
diff --git a/spec/lib/gitlab/graphql/pagination/keyset/connection_spec.rb b/spec/lib/gitlab/graphql/pagination/keyset/connection_spec.rb
index a4ba288b7f1..5e00d2eceab 100644
--- a/spec/lib/gitlab/graphql/pagination/keyset/connection_spec.rb
+++ b/spec/lib/gitlab/graphql/pagination/keyset/connection_spec.rb
@@ -7,8 +7,7 @@ RSpec.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(:schema) { empty_schema }
let(:context) { GraphQL::Query::Context.new(query: query_double(schema: schema), values: nil, object: nil) }
subject(:connection) do
diff --git a/spec/support/shared_examples/graphql/mutations/security/ci_configuration_shared_examples.rb b/spec/support/shared_examples/graphql/mutations/security/ci_configuration_shared_examples.rb
index 21260e4d954..dfb8ce64391 100644
--- a/spec/support/shared_examples/graphql/mutations/security/ci_configuration_shared_examples.rb
+++ b/spec/support/shared_examples/graphql/mutations/security/ci_configuration_shared_examples.rb
@@ -71,7 +71,7 @@ RSpec.shared_examples_for 'graphql mutations security ci configuration' do
end
it 'returns an array of errors' do
- expect(result).to match(
+ expect(result).to include(
branch: be_nil,
success_path: be_nil,
errors: match_array([error_message])
@@ -92,7 +92,7 @@ RSpec.shared_examples_for 'graphql mutations security ci configuration' do
end
it 'returns a success path' do
- expect(result).to match(
+ expect(result).to include(
branch: branch,
success_path: success_path,
errors: []
@@ -108,7 +108,7 @@ RSpec.shared_examples_for 'graphql mutations security ci configuration' do
end
it 'returns an array of errors' do
- expect(result).to match(
+ expect(result).to include(
branch: be_nil,
success_path: be_nil,
errors: match_array([error])