diff options
Diffstat (limited to 'spec')
260 files changed, 330 insertions, 0 deletions
diff --git a/spec/controllers/confirmations_controller_spec.rb b/spec/controllers/confirmations_controller_spec.rb index c9a0ae981fc..401ee36b387 100644 --- a/spec/controllers/confirmations_controller_spec.rb +++ b/spec/controllers/confirmations_controller_spec.rb @@ -18,6 +18,7 @@ RSpec.describe ConfirmationsController do context 'user is already confirmed' do let_it_be_with_reload(:user) { create(:user, :unconfirmed) } + let(:confirmation_token) { user.confirmation_token } before do @@ -57,6 +58,7 @@ RSpec.describe ConfirmationsController do context 'user accesses the link after the expiry of confirmation token has passed' do let_it_be_with_reload(:user) { create(:user, :unconfirmed) } + let(:confirmation_token) { user.confirmation_token } before do diff --git a/spec/controllers/dashboard/projects_controller_spec.rb b/spec/controllers/dashboard/projects_controller_spec.rb index ed8dc1eb7cb..0d9bd146778 100644 --- a/spec/controllers/dashboard/projects_controller_spec.rb +++ b/spec/controllers/dashboard/projects_controller_spec.rb @@ -15,6 +15,7 @@ RSpec.describe Dashboard::ProjectsController, :aggregate_failures do context 'user logged in' do let_it_be(:project) { create(:project, name: 'Project 1') } let_it_be(:project2) { create(:project, name: 'Project Two') } + let(:projects) { [project, project2] } before_all do diff --git a/spec/controllers/invites_controller_spec.rb b/spec/controllers/invites_controller_spec.rb index 7c06ed9ae62..0d9cde88eca 100644 --- a/spec/controllers/invites_controller_spec.rb +++ b/spec/controllers/invites_controller_spec.rb @@ -5,6 +5,7 @@ require 'spec_helper' RSpec.describe InvitesController do let_it_be(:user) { create(:user) } let_it_be(:member, reload: true) { create(:project_member, :invited, invite_email: user.email) } + let(:raw_invite_token) { member.raw_invite_token } let(:project_members) { member.source.users } let(:md5_member_global_id) { Digest::MD5.hexdigest(member.to_global_id.to_s) } diff --git a/spec/controllers/profiles/emails_controller_spec.rb b/spec/controllers/profiles/emails_controller_spec.rb index 950120ae564..ce16632472f 100644 --- a/spec/controllers/profiles/emails_controller_spec.rb +++ b/spec/controllers/profiles/emails_controller_spec.rb @@ -63,6 +63,7 @@ RSpec.describe Profiles::EmailsController do describe '#resend_confirmation_instructions' do let_it_be(:email) { create(:email, user: user) } + let(:params) { { id: email.id } } subject { put(:resend_confirmation_instructions, params: params) } diff --git a/spec/controllers/users/terms_controller_spec.rb b/spec/controllers/users/terms_controller_spec.rb index 0acc3008187..30b8eb5a958 100644 --- a/spec/controllers/users/terms_controller_spec.rb +++ b/spec/controllers/users/terms_controller_spec.rb @@ -6,6 +6,7 @@ RSpec.describe Users::TermsController do include TermsHelper let_it_be(:user) { create(:user) } + let(:term) { create(:term) } before do diff --git a/spec/features/cycle_analytics_spec.rb b/spec/features/cycle_analytics_spec.rb index 8c7564535b5..d0f8767884e 100644 --- a/spec/features/cycle_analytics_spec.rb +++ b/spec/features/cycle_analytics_spec.rb @@ -6,6 +6,7 @@ RSpec.describe 'Value Stream Analytics', :js do let_it_be(:user) { create(:user) } let_it_be(:guest) { create(:user) } let_it_be(:project) { create(:project, :repository) } + let(:issue) { create(:issue, project: project, created_at: 2.days.ago) } let(:milestone) { create(:milestone, project: project) } let(:mr) { create_merge_request_closing_issue(user, project, issue, commit_message: "References #{issue.to_reference}") } diff --git a/spec/features/dashboard/datetime_on_tooltips_spec.rb b/spec/features/dashboard/datetime_on_tooltips_spec.rb index 442b8904974..bf9f6895d24 100644 --- a/spec/features/dashboard/datetime_on_tooltips_spec.rb +++ b/spec/features/dashboard/datetime_on_tooltips_spec.rb @@ -5,6 +5,7 @@ require 'spec_helper' RSpec.describe 'Tooltips on .timeago dates', :js do let_it_be(:user) { create(:user) } let_it_be(:project) { create(:project, name: 'test', namespace: user.namespace) } + let(:created_date) { 1.day.ago.beginning_of_minute - 1.hour } before_all do diff --git a/spec/features/dashboard/merge_requests_spec.rb b/spec/features/dashboard/merge_requests_spec.rb index 26b376be660..aa2485d4236 100644 --- a/spec/features/dashboard/merge_requests_spec.rb +++ b/spec/features/dashboard/merge_requests_spec.rb @@ -53,6 +53,7 @@ RSpec.describe 'Dashboard Merge Requests' do context 'merge requests exist' do let_it_be(:author_user) { create(:user) } + let(:label) { create(:label) } let!(:assigned_merge_request) do @@ -181,6 +182,7 @@ RSpec.describe 'Dashboard Merge Requests' do context 'merge request review', :js do let_it_be(:author_user) { create(:user) } + let!(:review_requested_merge_request) do create(:merge_request, reviewers: [current_user], diff --git a/spec/features/file_uploads/group_import_spec.rb b/spec/features/file_uploads/group_import_spec.rb index 0f9d05c3975..a8592f99bd6 100644 --- a/spec/features/file_uploads/group_import_spec.rb +++ b/spec/features/file_uploads/group_import_spec.rb @@ -7,6 +7,7 @@ RSpec.describe 'Upload a group export archive', :api, :js do let_it_be(:user) { create(:user, :admin) } let_it_be(:personal_access_token) { create(:personal_access_token, user: user) } + let(:api_path) { '/groups/import' } let(:url) { capybara_url(api(api_path, personal_access_token: personal_access_token)) } let(:file) { fixture_file_upload('spec/fixtures/group_export.tar.gz') } diff --git a/spec/features/file_uploads/project_import_spec.rb b/spec/features/file_uploads/project_import_spec.rb index 1bf16f46c63..82b6f490d2a 100644 --- a/spec/features/file_uploads/project_import_spec.rb +++ b/spec/features/file_uploads/project_import_spec.rb @@ -7,6 +7,7 @@ RSpec.describe 'Upload a project export archive', :api, :js do let_it_be(:user) { create(:user, :admin) } let_it_be(:personal_access_token) { create(:personal_access_token, user: user) } + let(:api_path) { '/projects/import' } let(:url) { capybara_url(api(api_path, personal_access_token: personal_access_token)) } let(:file) { fixture_file_upload('spec/features/projects/import_export/test_project_export.tar.gz') } diff --git a/spec/features/file_uploads/user_avatar_spec.rb b/spec/features/file_uploads/user_avatar_spec.rb index 043115be61a..c30e3452201 100644 --- a/spec/features/file_uploads/user_avatar_spec.rb +++ b/spec/features/file_uploads/user_avatar_spec.rb @@ -4,6 +4,7 @@ require 'spec_helper' RSpec.describe 'Upload a user avatar', :js do let_it_be(:user, reload: true) { create(:user) } + let(:file) { fixture_file_upload('spec/fixtures/banana_sample.gif') } before do diff --git a/spec/features/issues/user_sees_breadcrumb_links_spec.rb b/spec/features/issues/user_sees_breadcrumb_links_spec.rb index f5793758a9b..9f8cd2a769d 100644 --- a/spec/features/issues/user_sees_breadcrumb_links_spec.rb +++ b/spec/features/issues/user_sees_breadcrumb_links_spec.rb @@ -4,6 +4,7 @@ require 'spec_helper' RSpec.describe 'New issue breadcrumb' do let_it_be(:project, reload: true) { create(:project) } + let(:user) { project.creator } before do diff --git a/spec/features/markdown/metrics_spec.rb b/spec/features/markdown/metrics_spec.rb index f9781f6c702..bc4eea119c0 100644 --- a/spec/features/markdown/metrics_spec.rb +++ b/spec/features/markdown/metrics_spec.rb @@ -180,6 +180,7 @@ RSpec.describe 'Metrics rendering', :js, :kubeclient, :use_clean_rails_memory_st end let_it_be(:cluster) { create(:cluster, :provided_by_gcp, :project, projects: [project], user: user) } + let(:params) { [project.namespace.path, project.path, cluster.id] } let(:query_params) { { group: 'Cluster Health', title: 'CPU Usage', y_label: 'CPU (cores)' } } let(:metrics_url) { urls.namespace_project_cluster_url(*params, **query_params) } diff --git a/spec/features/participants_autocomplete_spec.rb b/spec/features/participants_autocomplete_spec.rb index 2781cfffbaf..cc805e7d369 100644 --- a/spec/features/participants_autocomplete_spec.rb +++ b/spec/features/participants_autocomplete_spec.rb @@ -6,6 +6,7 @@ RSpec.describe 'Member autocomplete', :js do let_it_be(:project) { create(:project, :public, :repository) } let_it_be(:user) { create(:user) } let_it_be(:author) { create(:user) } + let(:note) { create(:note, noteable: noteable, project: noteable.project) } before do diff --git a/spec/features/snippets/embedded_snippet_spec.rb b/spec/features/snippets/embedded_snippet_spec.rb index b799fb2fc00..ff876d8cc4f 100644 --- a/spec/features/snippets/embedded_snippet_spec.rb +++ b/spec/features/snippets/embedded_snippet_spec.rb @@ -4,6 +4,7 @@ require 'spec_helper' RSpec.describe 'Embedded Snippets' do let_it_be(:snippet) { create(:personal_snippet, :public, :repository) } + let(:blobs) { snippet.blobs.first(3) } it 'loads snippet', :js do diff --git a/spec/finders/alert_management/alerts_finder_spec.rb b/spec/finders/alert_management/alerts_finder_spec.rb index 3a88db5d854..7fcbc7b20a1 100644 --- a/spec/finders/alert_management/alerts_finder_spec.rb +++ b/spec/finders/alert_management/alerts_finder_spec.rb @@ -266,6 +266,7 @@ RSpec.describe AlertManagement::AlertsFinder, '#execute' do context 'assignee username given' do let_it_be(:assignee) { create(:user) } let_it_be(:alert) { create(:alert_management_alert, project: project, assignees: [assignee]) } + let(:params) { { assignee_username: username } } context 'with valid assignee_username' do diff --git a/spec/finders/ci/commit_statuses_finder_spec.rb b/spec/finders/ci/commit_statuses_finder_spec.rb index 05a1a98cfe0..2e26e38f4b4 100644 --- a/spec/finders/ci/commit_statuses_finder_spec.rb +++ b/spec/finders/ci/commit_statuses_finder_spec.rb @@ -9,6 +9,7 @@ RSpec.describe Ci::CommitStatusesFinder, '#execute' do context 'tag refs' do let_it_be(:tags) { TagsFinder.new(project.repository, {}).execute } + let(:subject) { described_class.new(project, project.repository, user, tags).execute } context 'no pipelines' do @@ -131,6 +132,7 @@ RSpec.describe Ci::CommitStatusesFinder, '#execute' do context 'CI pipelines visible to' do let_it_be(:tags) { TagsFinder.new(project.repository, {}).execute } + let(:subject) { described_class.new(project, project.repository, user, tags).execute } before do diff --git a/spec/finders/container_repositories_finder_spec.rb b/spec/finders/container_repositories_finder_spec.rb index 983f6dba28b..d247d61ecdb 100644 --- a/spec/finders/container_repositories_finder_spec.rb +++ b/spec/finders/container_repositories_finder_spec.rb @@ -9,6 +9,7 @@ RSpec.describe ContainerRepositoriesFinder do let_it_be(:group) { create(:group) } let_it_be(:project) { create(:project, group: group) } let_it_be(:project_repository) { create(:container_repository, name: 'my_image', project: project) } + let(:params) { {} } before do diff --git a/spec/finders/deployments_finder_spec.rb b/spec/finders/deployments_finder_spec.rb index bd03b254f40..6d9d0c33de3 100644 --- a/spec/finders/deployments_finder_spec.rb +++ b/spec/finders/deployments_finder_spec.rb @@ -68,6 +68,7 @@ RSpec.describe DeploymentsFinder do context 'at project scope' do let_it_be(:project) { create(:project, :public, :test_repo) } + let(:base_params) { { project: project } } describe 'filtering' do @@ -76,6 +77,7 @@ RSpec.describe DeploymentsFinder do let_it_be(:deployment_2) { create(:deployment, :success, project: project, updated_at: 47.hours.ago) } let_it_be(:deployment_3) { create(:deployment, :success, project: project, updated_at: 4.days.ago) } let_it_be(:deployment_4) { create(:deployment, :success, project: project, updated_at: 1.hour.ago) } + let(:params) { { **base_params, updated_before: 1.day.ago, updated_after: 3.days.ago, order_by: :updated_at } } it 'returns deployments with matched updated_at' do @@ -268,6 +270,7 @@ RSpec.describe DeploymentsFinder do let_it_be(:group_project_1) { create(:project, :public, :test_repo, group: group) } let_it_be(:group_project_2) { create(:project, :public, :test_repo, group: group) } let_it_be(:subgroup_project_1) { create(:project, :public, :test_repo, group: subgroup) } + let(:base_params) { { group: group } } describe 'ordering' do diff --git a/spec/finders/events_finder_spec.rb b/spec/finders/events_finder_spec.rb index fe2e449f03d..5ecd38cd9cc 100644 --- a/spec/finders/events_finder_spec.rb +++ b/spec/finders/events_finder_spec.rb @@ -22,6 +22,7 @@ RSpec.describe EventsFinder do let!(:other_developer_event) { create(:event, :created, project: project1, author: other_user, target: opened_merge_request3 ) } let_it_be(:public_project) { create(:project, :public, creator_id: user.id, namespace: user.namespace) } + let(:confidential_issue) { create(:closed_issue, confidential: true, project: public_project, author: user) } let!(:confidential_event) { create(:event, :closed, project: public_project, author: user, target: confidential_issue) } diff --git a/spec/finders/group_descendants_finder_spec.rb b/spec/finders/group_descendants_finder_spec.rb index 3c3bb13a629..01c6eb05907 100644 --- a/spec/finders/group_descendants_finder_spec.rb +++ b/spec/finders/group_descendants_finder_spec.rb @@ -5,6 +5,7 @@ require 'spec_helper' RSpec.describe GroupDescendantsFinder do let_it_be(:user) { create(:user) } let_it_be(:group) { create(:group) } + let(:params) { {} } subject(:finder) do diff --git a/spec/finders/groups_finder_spec.rb b/spec/finders/groups_finder_spec.rb index d69720ae98e..481e2983dd7 100644 --- a/spec/finders/groups_finder_spec.rb +++ b/spec/finders/groups_finder_spec.rb @@ -180,6 +180,7 @@ RSpec.describe GroupsFinder do let_it_be(:internal_sub_subgroup) { create(:group, :internal, parent: public_subgroup) } let_it_be(:private_sub_subgroup) { create(:group, :private, parent: public_subgroup) } let_it_be(:public_sub_subgroup) { create(:group, :public, parent: public_subgroup) } + let(:params) { { include_parent_descendants: true, parent: parent_group } } context 'with nil parent' do diff --git a/spec/finders/packages/conan/package_file_finder_spec.rb b/spec/finders/packages/conan/package_file_finder_spec.rb index d0c9efa1418..c2f445c58f7 100644 --- a/spec/finders/packages/conan/package_file_finder_spec.rb +++ b/spec/finders/packages/conan/package_file_finder_spec.rb @@ -4,6 +4,7 @@ require 'spec_helper' RSpec.describe ::Packages::Conan::PackageFileFinder do let_it_be(:package) { create(:conan_package) } let_it_be(:package_file) { package.package_files.first } + let(:package_file_name) { package_file.file_name } let(:params) { {} } diff --git a/spec/finders/packages/go/module_finder_spec.rb b/spec/finders/packages/go/module_finder_spec.rb index e5c8827fc8d..a93fd855529 100644 --- a/spec/finders/packages/go/module_finder_spec.rb +++ b/spec/finders/packages/go/module_finder_spec.rb @@ -5,6 +5,7 @@ require 'spec_helper' RSpec.describe Packages::Go::ModuleFinder do let_it_be(:project) { create :project } let_it_be(:other_project) { create :project } + let(:finder) { described_class.new project, module_name } shared_examples 'an invalid path' do diff --git a/spec/finders/packages/group_packages_finder_spec.rb b/spec/finders/packages/group_packages_finder_spec.rb index 29b2f0fffd7..d7f62bdfbb4 100644 --- a/spec/finders/packages/group_packages_finder_spec.rb +++ b/spec/finders/packages/group_packages_finder_spec.rb @@ -129,6 +129,7 @@ RSpec.describe Packages::GroupPackagesFinder do context 'with package_name' do let_it_be(:named_package) { create(:maven_package, project: project, name: 'maven') } + let(:params) { { package_name: package_name } } context 'as complete name' do diff --git a/spec/finders/packages/nuget/package_finder_spec.rb b/spec/finders/packages/nuget/package_finder_spec.rb index 59cca2d06dc..4ad02ce7da8 100644 --- a/spec/finders/packages/nuget/package_finder_spec.rb +++ b/spec/finders/packages/nuget/package_finder_spec.rb @@ -11,6 +11,7 @@ RSpec.describe Packages::Nuget::PackageFinder do let_it_be(:package3) { create(:nuget_package, name: 'Another.Dummy.Package', project: project) } let_it_be(:other_package_1) { create(:nuget_package, name: package1.name, version: package1.version) } let_it_be(:other_package_2) { create(:nuget_package, name: package1.name, version: package2.version) } + let(:package_name) { package1.name } let(:package_version) { nil } let(:limit) { 50 } @@ -57,6 +58,7 @@ RSpec.describe Packages::Nuget::PackageFinder do let_it_be(:package4) { create(:nuget_package, name: package1.name, project: project) } let_it_be(:package5) { create(:nuget_package, name: package1.name, project: project) } let_it_be(:package6) { create(:nuget_package, name: package1.name, project: project) } + let(:limit) { 2 } it { is_expected.to match_array([package5, package6]) } diff --git a/spec/finders/packages/package_file_finder_spec.rb b/spec/finders/packages/package_file_finder_spec.rb index ab58f75fcae..8014f04d917 100644 --- a/spec/finders/packages/package_file_finder_spec.rb +++ b/spec/finders/packages/package_file_finder_spec.rb @@ -4,6 +4,7 @@ require 'spec_helper' RSpec.describe Packages::PackageFileFinder do let_it_be(:package) { create(:maven_package) } let_it_be(:package_file) { package.package_files.first } + let(:package_file_name) { package_file.file_name } let(:params) { {} } diff --git a/spec/finders/packages/package_finder_spec.rb b/spec/finders/packages/package_finder_spec.rb index 2bb4f05a41d..1b0c88a4771 100644 --- a/spec/finders/packages/package_finder_spec.rb +++ b/spec/finders/packages/package_finder_spec.rb @@ -25,6 +25,7 @@ RSpec.describe ::Packages::PackageFinder do context 'processing packages' do let_it_be(:nuget_package) { create(:nuget_package, :processing, project: project) } + let(:package_id) { nuget_package.id } it 'are not returned' do diff --git a/spec/finders/template_finder_spec.rb b/spec/finders/template_finder_spec.rb index b7339288c51..97eecf8a89d 100644 --- a/spec/finders/template_finder_spec.rb +++ b/spec/finders/template_finder_spec.rb @@ -123,6 +123,7 @@ RSpec.describe TemplateFinder do describe '#execute' do let_it_be(:project) { nil } + let(:params) { {} } subject(:result) { described_class.new(type, project, params).execute } @@ -149,6 +150,7 @@ RSpec.describe TemplateFinder do describe '#template_names' do let_it_be(:project) { nil } + let(:params) { {} } subject(:result) { described_class.new(type, project, params).template_names.values.flatten.map { |el| OpenStruct.new(el) } } diff --git a/spec/finders/todos_finder_spec.rb b/spec/finders/todos_finder_spec.rb index 577ad80ede1..5611a67e977 100644 --- a/spec/finders/todos_finder_spec.rb +++ b/spec/finders/todos_finder_spec.rb @@ -9,6 +9,7 @@ RSpec.describe TodosFinder do let_it_be(:project) { create(:project, :repository, namespace: group) } let_it_be(:issue) { create(:issue, project: project) } let_it_be(:merge_request) { create(:merge_request, source_project: project) } + let(:finder) { described_class } before_all do @@ -153,6 +154,7 @@ RSpec.describe TodosFinder do context 'by groups' do context 'with subgroups' do let_it_be(:subgroup) { create(:group, parent: group) } + let!(:todo3) { create(:todo, user: user, group: subgroup, target: issue) } it 'returns todos from subgroups when filtered by a group' do diff --git a/spec/finders/user_recent_events_finder_spec.rb b/spec/finders/user_recent_events_finder_spec.rb index 5a9243d150d..74c563b9bf6 100644 --- a/spec/finders/user_recent_events_finder_spec.rb +++ b/spec/finders/user_recent_events_finder_spec.rb @@ -12,6 +12,7 @@ RSpec.describe UserRecentEventsFinder do let!(:internal_event) { create(:event, project: internal_project, author: project_owner) } let!(:public_event) { create(:event, project: public_project, author: project_owner) } let_it_be(:issue) { create(:issue, project: public_project) } + let(:limit) { nil } let(:params) { { limit: limit } } @@ -43,6 +44,7 @@ RSpec.describe UserRecentEventsFinder do context 'events from multiple users' do let_it_be(:second_user, reload: true) { create(:user) } let_it_be(:private_project_second_user) { create(:project, :private, creator: second_user) } + let(:internal_project_second_user) { create(:project, :internal, creator: second_user) } let(:public_project_second_user) { create(:project, :public, creator: second_user) } let!(:private_event_second_user) { create(:event, project: private_project_second_user, author: second_user) } diff --git a/spec/frontend/fixtures/pipelines.rb b/spec/frontend/fixtures/pipelines.rb index 2a538352abe..f695b74ec87 100644 --- a/spec/frontend/fixtures/pipelines.rb +++ b/spec/frontend/fixtures/pipelines.rb @@ -13,6 +13,7 @@ RSpec.describe Projects::PipelinesController, '(JavaScript fixtures)', type: :co let!(:build_pipeline_without_author) { create(:ci_build, pipeline: pipeline_without_author, stage: 'test') } let_it_be(:pipeline_without_commit) { create(:ci_pipeline, status: :success, project: project, sha: '0000') } + let!(:build_pipeline_without_commit) { create(:ci_build, pipeline: pipeline_without_commit, stage: 'test') } let(:commit) { create(:commit, project: project) } diff --git a/spec/graphql/features/authorization_spec.rb b/spec/graphql/features/authorization_spec.rb index 64e423e2bf8..0dc3a9c85e7 100644 --- a/spec/graphql/features/authorization_spec.rb +++ b/spec/graphql/features/authorization_spec.rb @@ -7,6 +7,7 @@ RSpec.describe 'DeclarativePolicy authorization in GraphQL ' do include Graphql::ResolverFactories let_it_be(:user) { create(:user) } + let(:permission_single) { :foo } let(:permission_collection) { [:foo, :bar] } let(:test_object) { double(name: 'My name') } diff --git a/spec/graphql/gitlab_schema_spec.rb b/spec/graphql/gitlab_schema_spec.rb index 1f2c518f83c..06505536b09 100644 --- a/spec/graphql/gitlab_schema_spec.rb +++ b/spec/graphql/gitlab_schema_spec.rb @@ -4,6 +4,7 @@ require 'spec_helper' RSpec.describe GitlabSchema do let_it_be(:connections) { GitlabSchema.connections.all_wrappers } + let(:user) { build :user } it 'uses batch loading' do diff --git a/spec/graphql/mutations/custom_emoji/create_spec.rb b/spec/graphql/mutations/custom_emoji/create_spec.rb index 118c5d67188..7c98e53a72c 100644 --- a/spec/graphql/mutations/custom_emoji/create_spec.rb +++ b/spec/graphql/mutations/custom_emoji/create_spec.rb @@ -5,6 +5,7 @@ require 'spec_helper' RSpec.describe Mutations::CustomEmoji::Create do let_it_be(:group) { create(:group) } let_it_be(:user) { create(:user) } + let(:args) { { group_path: group.full_path, name: 'tanuki', url: 'https://about.gitlab.com/images/press/logo/png/gitlab-icon-rgb.png' } } before do diff --git a/spec/graphql/mutations/discussions/toggle_resolve_spec.rb b/spec/graphql/mutations/discussions/toggle_resolve_spec.rb index 162b1249ab5..b03c6cb094f 100644 --- a/spec/graphql/mutations/discussions/toggle_resolve_spec.rb +++ b/spec/graphql/mutations/discussions/toggle_resolve_spec.rb @@ -140,6 +140,7 @@ RSpec.describe Mutations::Discussions::ToggleResolve do context 'when discussion is on a merge request' do let_it_be(:noteable) { create(:merge_request, source_project: project) } + let(:discussion) { create(:diff_note_on_merge_request, noteable: noteable, project: project).to_discussion } it_behaves_like 'a working resolve method' @@ -147,6 +148,7 @@ RSpec.describe Mutations::Discussions::ToggleResolve do context 'when discussion is on a design' do let_it_be(:noteable) { create(:design, :with_file, issue: create(:issue, project: project)) } + let(:discussion) { create(:diff_note_on_design, noteable: noteable, project: project).to_discussion } it_behaves_like 'a working resolve method' diff --git a/spec/graphql/mutations/environments/canary_ingress/update_spec.rb b/spec/graphql/mutations/environments/canary_ingress/update_spec.rb index c022828cf09..2715a908f85 100644 --- a/spec/graphql/mutations/environments/canary_ingress/update_spec.rb +++ b/spec/graphql/mutations/environments/canary_ingress/update_spec.rb @@ -7,6 +7,7 @@ RSpec.describe Mutations::Environments::CanaryIngress::Update do let_it_be(:environment) { create(:environment, project: project) } let_it_be(:maintainer) { create(:user) } let_it_be(:reporter) { create(:user) } + let(:user) { maintainer } subject(:mutation) { described_class.new(object: nil, context: { current_user: user }, field: nil) } diff --git a/spec/graphql/mutations/issues/set_severity_spec.rb b/spec/graphql/mutations/issues/set_severity_spec.rb index 7698118ae3e..401db6cdb44 100644 --- a/spec/graphql/mutations/issues/set_severity_spec.rb +++ b/spec/graphql/mutations/issues/set_severity_spec.rb @@ -5,6 +5,7 @@ require 'spec_helper' RSpec.describe Mutations::Issues::SetSeverity do let_it_be(:user) { create(:user) } let_it_be(:issue) { create(:incident) } + let(:mutation) { described_class.new(object: nil, context: { current_user: user }, field: nil) } specify { expect(described_class).to require_graphql_authorizations(:update_issue) } diff --git a/spec/graphql/mutations/labels/create_spec.rb b/spec/graphql/mutations/labels/create_spec.rb index b2dd94f31bb..53a17041125 100644 --- a/spec/graphql/mutations/labels/create_spec.rb +++ b/spec/graphql/mutations/labels/create_spec.rb @@ -45,6 +45,7 @@ RSpec.describe Mutations::Labels::Create do context 'when creating a project label' do let_it_be(:parent) { create(:project) } + let(:extra_params) { { project_path: parent.full_path } } it_behaves_like 'create labels mutation' @@ -52,6 +53,7 @@ RSpec.describe Mutations::Labels::Create do context 'when creating a group label' do let_it_be(:parent) { create(:group) } + let(:extra_params) { { group_path: parent.full_path } } it_behaves_like 'create labels mutation' diff --git a/spec/graphql/mutations/notes/reposition_image_diff_note_spec.rb b/spec/graphql/mutations/notes/reposition_image_diff_note_spec.rb index d88b196cbff..e78f755d5c7 100644 --- a/spec/graphql/mutations/notes/reposition_image_diff_note_spec.rb +++ b/spec/graphql/mutations/notes/reposition_image_diff_note_spec.rb @@ -12,6 +12,7 @@ RSpec.describe Mutations::Notes::RepositionImageDiffNote do let_it_be(:noteable) { create(:merge_request) } let_it_be(:project) { noteable.project } + let(:note) { create(:image_diff_note_on_merge_request, noteable: noteable, project: project) } let(:mutation) do diff --git a/spec/lib/bulk_imports/groups/loaders/group_loader_spec.rb b/spec/lib/bulk_imports/groups/loaders/group_loader_spec.rb index 533955b057c..de0b56045b3 100644 --- a/spec/lib/bulk_imports/groups/loaders/group_loader_spec.rb +++ b/spec/lib/bulk_imports/groups/loaders/group_loader_spec.rb @@ -9,6 +9,7 @@ RSpec.describe BulkImports::Groups::Loaders::GroupLoader do let_it_be(:entity) { create(:bulk_import_entity, bulk_import: bulk_import) } let_it_be(:tracker) { create(:bulk_import_tracker, entity: entity) } let_it_be(:context) { BulkImports::Pipeline::Context.new(tracker) } + let(:service_double) { instance_double(::Groups::CreateService) } let(:data) { { foo: :bar } } diff --git a/spec/lib/extracts_path_spec.rb b/spec/lib/extracts_path_spec.rb index b69cbbf0ec0..57eda63854d 100644 --- a/spec/lib/extracts_path_spec.rb +++ b/spec/lib/extracts_path_spec.rb @@ -9,6 +9,7 @@ RSpec.describe ExtractsPath do let_it_be(:owner) { create(:user) } let_it_be(:container) { create(:project, :repository, creator: owner) } + let(:request) { double('request') } before do diff --git a/spec/lib/extracts_ref_spec.rb b/spec/lib/extracts_ref_spec.rb index 5433a512981..3cdce150de9 100644 --- a/spec/lib/extracts_ref_spec.rb +++ b/spec/lib/extracts_ref_spec.rb @@ -8,6 +8,7 @@ RSpec.describe ExtractsRef do let_it_be(:owner) { create(:user) } let_it_be(:container) { create(:snippet, :repository, author: owner) } + let(:ref) { sample_commit[:id] } let(:params) { { path: sample_commit[:line_code_path], ref: ref } } diff --git a/spec/lib/gitlab/cache/ci/project_pipeline_status_spec.rb b/spec/lib/gitlab/cache/ci/project_pipeline_status_spec.rb index 9bd89abae83..c0e4d1b5355 100644 --- a/spec/lib/gitlab/cache/ci/project_pipeline_status_spec.rb +++ b/spec/lib/gitlab/cache/ci/project_pipeline_status_spec.rb @@ -4,6 +4,7 @@ require 'spec_helper' RSpec.describe Gitlab::Cache::Ci::ProjectPipelineStatus, :clean_gitlab_redis_cache do let_it_be(:project) { create(:project, :repository) } + let(:pipeline_status) { described_class.new(project) } let(:cache_key) { pipeline_status.cache_key } diff --git a/spec/lib/gitlab/closing_issue_extractor_spec.rb b/spec/lib/gitlab/closing_issue_extractor_spec.rb index 37349c30224..279486aa2a1 100644 --- a/spec/lib/gitlab/closing_issue_extractor_spec.rb +++ b/spec/lib/gitlab/closing_issue_extractor_spec.rb @@ -7,6 +7,7 @@ RSpec.describe Gitlab::ClosingIssueExtractor do let_it_be(:project2) { create(:project) } let_it_be(:issue) { create(:issue, project: project) } let_it_be(:issue2) { create(:issue, project: project2) } + let(:reference) { issue.to_reference } let(:cross_reference) { issue2.to_reference(project) } @@ -351,6 +352,7 @@ RSpec.describe Gitlab::ClosingIssueExtractor do context 'with multiple references' do let_it_be(:other_issue) { create(:issue, project: project) } let_it_be(:third_issue) { create(:issue, project: project) } + let(:reference2) { other_issue.to_reference } let(:reference3) { third_issue.to_reference } diff --git a/spec/lib/gitlab/composer/cache_spec.rb b/spec/lib/gitlab/composer/cache_spec.rb index 00318ac14f9..071771960c6 100644 --- a/spec/lib/gitlab/composer/cache_spec.rb +++ b/spec/lib/gitlab/composer/cache_spec.rb @@ -7,6 +7,7 @@ RSpec.describe Gitlab::Composer::Cache do let_it_be(:json) { { 'name' => package_name } } let_it_be(:group) { create(:group) } let_it_be(:project) { create(:project, :custom_repo, files: { 'composer.json' => json.to_json }, group: group) } + let(:branch) { project.repository.find_branch('master') } let(:sha_regex) { /^[A-Fa-f0-9]{64}$/ } diff --git a/spec/lib/gitlab/deploy_key_access_spec.rb b/spec/lib/gitlab/deploy_key_access_spec.rb index e186e993d8f..83b97c8ba25 100644 --- a/spec/lib/gitlab/deploy_key_access_spec.rb +++ b/spec/lib/gitlab/deploy_key_access_spec.rb @@ -5,6 +5,7 @@ require 'spec_helper' RSpec.describe Gitlab::DeployKeyAccess do let_it_be(:user) { create(:user) } let_it_be(:deploy_key) { create(:deploy_key, user: user) } + let(:project) { create(:project, :repository) } let(:protected_branch) { create(:protected_branch, :no_one_can_push, project: project) } diff --git a/spec/lib/gitlab/email/handler/service_desk_handler_spec.rb b/spec/lib/gitlab/email/handler/service_desk_handler_spec.rb index 12a2dda2855..e8470657181 100644 --- a/spec/lib/gitlab/email/handler/service_desk_handler_spec.rb +++ b/spec/lib/gitlab/email/handler/service_desk_handler_spec.rb @@ -12,6 +12,7 @@ RSpec.describe Gitlab::Email::Handler::ServiceDeskHandler do let(:email_raw) { email_fixture('emails/service_desk.eml') } let_it_be(:group) { create(:group, :private, name: "email") } + let(:expected_description) do "Service desk stuff!\n\n```\na = b\n```\n\n`/label ~label1`\n`/assign @user1`\n`/close`\n![image](uploads/image.png)" end @@ -178,6 +179,7 @@ RSpec.describe Gitlab::Email::Handler::ServiceDeskHandler do context 'when using service desk key' do let_it_be(:service_desk_key) { 'mykey' } + let(:email_raw) { service_desk_fixture('emails/service_desk_custom_address.eml') } let(:receiver) { Gitlab::Email::ServiceDeskReceiver.new(email_raw) } @@ -209,6 +211,7 @@ RSpec.describe Gitlab::Email::Handler::ServiceDeskHandler do context 'when there are multiple projects with same key' do let_it_be(:project_with_same_key) { create(:project, group: group, service_desk_enabled: true) } + let(:email_raw) { service_desk_fixture('emails/service_desk_custom_address.eml', slug: project_with_same_key.full_path_slug.to_s) } before do diff --git a/spec/lib/gitlab/gitaly_client/operation_service_spec.rb b/spec/lib/gitlab/gitaly_client/operation_service_spec.rb index 9a17140a1e0..3789bc76a94 100644 --- a/spec/lib/gitlab/gitaly_client/operation_service_spec.rb +++ b/spec/lib/gitlab/gitaly_client/operation_service_spec.rb @@ -5,6 +5,7 @@ require 'spec_helper' RSpec.describe Gitlab::GitalyClient::OperationService do let_it_be(:user) { create(:user) } let_it_be(:project) { create(:project, :repository) } + let(:repository) { project.repository.raw } let(:client) { described_class.new(repository) } let(:gitaly_user) { Gitlab::Git::User.from_gitlab(user).to_gitaly } diff --git a/spec/lib/gitlab/gl_repository/repo_type_spec.rb b/spec/lib/gitlab/gl_repository/repo_type_spec.rb index 629e6c96858..71a4c693f9d 100644 --- a/spec/lib/gitlab/gl_repository/repo_type_spec.rb +++ b/spec/lib/gitlab/gl_repository/repo_type_spec.rb @@ -5,6 +5,7 @@ RSpec.describe Gitlab::GlRepository::RepoType do let_it_be(:project) { create(:project) } let_it_be(:personal_snippet) { create(:personal_snippet, author: project.owner) } let_it_be(:project_snippet) { create(:project_snippet, project: project, author: project.owner) } + let(:project_path) { project.repository.full_path } let(:wiki_path) { project.wiki.repository.full_path } let(:design_path) { project.design_repository.full_path } diff --git a/spec/lib/gitlab/group_search_results_spec.rb b/spec/lib/gitlab/group_search_results_spec.rb index 009f66d2108..ec96a069b8f 100644 --- a/spec/lib/gitlab/group_search_results_spec.rb +++ b/spec/lib/gitlab/group_search_results_spec.rb @@ -8,6 +8,7 @@ RSpec.describe Gitlab::GroupSearchResults do let_it_be(:group) { create(:group) } let_it_be(:user) { create(:user) } let_it_be(:project) { create(:project, :public, group: group) } + let(:filters) { {} } let(:limit_projects) { Project.all } let(:query) { 'gob' } diff --git a/spec/lib/gitlab/json_cache_spec.rb b/spec/lib/gitlab/json_cache_spec.rb index 563b3d35823..8265c3449bb 100644 --- a/spec/lib/gitlab/json_cache_spec.rb +++ b/spec/lib/gitlab/json_cache_spec.rb @@ -4,6 +4,7 @@ require 'spec_helper' RSpec.describe Gitlab::JsonCache do let_it_be(:broadcast_message) { create(:broadcast_message) } + let(:backend) { double('backend').as_null_object } let(:namespace) { 'geo' } let(:key) { 'foo' } diff --git a/spec/lib/gitlab/language_detection_spec.rb b/spec/lib/gitlab/language_detection_spec.rb index 14523be8ec6..9430ecf7baf 100644 --- a/spec/lib/gitlab/language_detection_spec.rb +++ b/spec/lib/gitlab/language_detection_spec.rb @@ -6,6 +6,7 @@ RSpec.describe Gitlab::LanguageDetection do let_it_be(:project) { create(:project, :repository) } let_it_be(:ruby) { create(:programming_language, name: 'Ruby') } let_it_be(:haskell) { create(:programming_language, name: 'Haskell') } + let(:repository) { project.repository } let(:detection) do [{ value: 66.63, label: "Ruby", color: "#701516", highlight: "#701516" }, diff --git a/spec/lib/gitlab/project_search_results_spec.rb b/spec/lib/gitlab/project_search_results_spec.rb index 2f28b8dfce0..3400b274b82 100644 --- a/spec/lib/gitlab/project_search_results_spec.rb +++ b/spec/lib/gitlab/project_search_results_spec.rb @@ -7,6 +7,7 @@ RSpec.describe Gitlab::ProjectSearchResults do let_it_be(:user) { create(:user) } let_it_be(:project) { create(:project) } + let(:query) { 'hello world' } let(:repository_ref) { nil } let(:filters) { {} } @@ -266,6 +267,7 @@ RSpec.describe Gitlab::ProjectSearchResults do let_it_be(:closed_result) { create(:issue, :closed, project: project, title: 'foo closed') } let_it_be(:opened_result) { create(:issue, :opened, project: project, title: 'foo opened') } let_it_be(:confidential_result) { create(:issue, :confidential, project: project, title: 'foo confidential') } + let(:query) { 'foo' } before do diff --git a/spec/lib/gitlab/prometheus/query_variables_spec.rb b/spec/lib/gitlab/prometheus/query_variables_spec.rb index 1dbdb892a5d..d9cac3e1064 100644 --- a/spec/lib/gitlab/prometheus/query_variables_spec.rb +++ b/spec/lib/gitlab/prometheus/query_variables_spec.rb @@ -5,6 +5,7 @@ require 'spec_helper' RSpec.describe Gitlab::Prometheus::QueryVariables do describe '.call' do let_it_be_with_refind(:environment) { create(:environment) } + let(:project) { environment.project } let(:slug) { environment.slug } let(:params) { {} } diff --git a/spec/lib/gitlab/reactive_cache_set_cache_spec.rb b/spec/lib/gitlab/reactive_cache_set_cache_spec.rb index 19fb2ada476..f405b2ad86e 100644 --- a/spec/lib/gitlab/reactive_cache_set_cache_spec.rb +++ b/spec/lib/gitlab/reactive_cache_set_cache_spec.rb @@ -4,6 +4,7 @@ require 'spec_helper' RSpec.describe Gitlab::ReactiveCacheSetCache, :clean_gitlab_redis_cache do let_it_be(:project) { create(:project) } + let(:cache_prefix) { 'cache_prefix' } let(:expires_in) { 10.minutes } let(:cache) { described_class.new(expires_in: expires_in) } diff --git a/spec/lib/gitlab/reference_extractor_spec.rb b/spec/lib/gitlab/reference_extractor_spec.rb index e040ddb1be4..f6e69aa6533 100644 --- a/spec/lib/gitlab/reference_extractor_spec.rb +++ b/spec/lib/gitlab/reference_extractor_spec.rb @@ -315,6 +315,7 @@ RSpec.describe Gitlab::ReferenceExtractor do describe '#references' do let_it_be(:user) { create(:user) } let_it_be(:issue) { create(:issue, project: project) } + let(:text) { "Ref. #{issue.to_reference}" } subject { described_class.new(project, user) } diff --git a/spec/lib/gitlab/search_results_spec.rb b/spec/lib/gitlab/search_results_spec.rb index a1b18172a31..06dc9b3307a 100644 --- a/spec/lib/gitlab/search_results_spec.rb +++ b/spec/lib/gitlab/search_results_spec.rb @@ -11,6 +11,7 @@ RSpec.describe Gitlab::SearchResults do let_it_be(:project) { create(:project, name: 'foo') } let_it_be(:issue) { create(:issue, project: project, title: 'foo') } let_it_be(:milestone) { create(:milestone, project: project, title: 'foo') } + let(:merge_request) { create(:merge_request, source_project: project, title: 'foo') } let(:query) { 'foo' } let(:filters) { {} } diff --git a/spec/lib/gitlab/shell_spec.rb b/spec/lib/gitlab/shell_spec.rb index b0dc34e8abf..891b3639709 100644 --- a/spec/lib/gitlab/shell_spec.rb +++ b/spec/lib/gitlab/shell_spec.rb @@ -5,6 +5,7 @@ require 'stringio' RSpec.describe Gitlab::Shell do let_it_be(:project) { create(:project, :repository) } + let(:repository) { project.repository } let(:gitlab_shell) { described_class.new } diff --git a/spec/models/abuse_report_spec.rb b/spec/models/abuse_report_spec.rb index a97574fa524..e87996fc1f0 100644 --- a/spec/models/abuse_report_spec.rb +++ b/spec/models/abuse_report_spec.rb @@ -5,6 +5,7 @@ require 'spec_helper' RSpec.describe AbuseReport do let_it_be(:report, reload: true) { create(:abuse_report) } let_it_be(:user, reload: true) { create(:admin) } + subject { report } it { expect(subject).to be_valid } diff --git a/spec/models/alert_management/alert_spec.rb b/spec/models/alert_management/alert_spec.rb index 80a45b1c1be..18d486740b8 100644 --- a/spec/models/alert_management/alert_spec.rb +++ b/spec/models/alert_management/alert_spec.rb @@ -100,6 +100,7 @@ RSpec.describe AlertManagement::Alert do describe 'fingerprint' do let_it_be(:fingerprint) { 'fingerprint' } let_it_be(:project3, refind: true) { create(:project) } + let(:new_alert) { build(:alert_management_alert, fingerprint: fingerprint, project: project3) } subject { new_alert } diff --git a/spec/models/chat_name_spec.rb b/spec/models/chat_name_spec.rb index 4d77bd53158..9ed00003ac1 100644 --- a/spec/models/chat_name_spec.rb +++ b/spec/models/chat_name_spec.rb @@ -4,6 +4,7 @@ require 'spec_helper' RSpec.describe ChatName do let_it_be(:chat_name) { create(:chat_name) } + subject { chat_name } it { is_expected.to belong_to(:integration) } diff --git a/spec/models/chat_team_spec.rb b/spec/models/chat_team_spec.rb index 08fd05324aa..2e8cdb7a316 100644 --- a/spec/models/chat_team_spec.rb +++ b/spec/models/chat_team_spec.rb @@ -4,6 +4,7 @@ require 'spec_helper' RSpec.describe ChatTeam do let_it_be(:chat_team) { create(:chat_team) } + subject { chat_team } # Associations diff --git a/spec/models/clusters/kubernetes_namespace_spec.rb b/spec/models/clusters/kubernetes_namespace_spec.rb index 3b903fe34f9..e70cd15baca 100644 --- a/spec/models/clusters/kubernetes_namespace_spec.rb +++ b/spec/models/clusters/kubernetes_namespace_spec.rb @@ -62,6 +62,7 @@ RSpec.describe Clusters::KubernetesNamespace, type: :model do describe 'namespace uniqueness validation' do let_it_be(:cluster) { create(:cluster, :project, :provided_by_gcp) } + let(:kubernetes_namespace) { build(:cluster_kubernetes_namespace, cluster: cluster, namespace: 'my-namespace') } subject { kubernetes_namespace } diff --git a/spec/models/commit_spec.rb b/spec/models/commit_spec.rb index 8ffc198fc4d..63fe6923630 100644 --- a/spec/models/commit_spec.rb +++ b/spec/models/commit_spec.rb @@ -6,6 +6,7 @@ RSpec.describe Commit do let_it_be(:project) { create(:project, :public, :repository) } let_it_be(:personal_snippet) { create(:personal_snippet, :repository) } let_it_be(:project_snippet) { create(:project_snippet, :repository) } + let(:commit) { project.commit } describe 'modules' do diff --git a/spec/models/deploy_token_spec.rb b/spec/models/deploy_token_spec.rb index dfc37f9e661..c9f7895a616 100644 --- a/spec/models/deploy_token_spec.rb +++ b/spec/models/deploy_token_spec.rb @@ -242,6 +242,7 @@ RSpec.describe DeployToken do context 'and when the token is of group type' do let_it_be(:group) { create(:group) } + let(:deploy_token) { create(:deploy_token, :group) } before do diff --git a/spec/models/deployment_spec.rb b/spec/models/deployment_spec.rb index bcd237cbd38..a0e5e9cbfe4 100644 --- a/spec/models/deployment_spec.rb +++ b/spec/models/deployment_spec.rb @@ -80,6 +80,7 @@ RSpec.describe Deployment do let_it_be(:staging) { create(:environment, :staging, project: project) } let_it_be(:other_project) { create(:project, :repository) } let_it_be(:other_production) { create(:environment, :production, project: other_project) } + let(:environment_name) { production.name } context 'when deployment belongs to the environment' do @@ -488,6 +489,7 @@ RSpec.describe Deployment do let_it_be(:project) { create(:project, :repository) } let_it_be(:commits) { project.repository.commits('master', limit: 2) } let_it_be(:deployments) { commits.reverse.map { |commit| create(:deployment, project: project, sha: commit.id) } } + let(:sha) { commits.map(&:id) } it 'finds the latest deployment with sha' do @@ -823,6 +825,7 @@ RSpec.describe Deployment do describe '#update_merge_request_metrics!' do let_it_be(:project) { create(:project, :repository) } + let(:environment) { build(:environment, environment_tier, project: project) } let!(:deployment) { create(:deployment, :success, project: project, environment: environment) } let!(:merge_request) { create(:merge_request, :simple, :merged_last_month, project: project) } diff --git a/spec/models/diff_viewer/server_side_spec.rb b/spec/models/diff_viewer/server_side_spec.rb index 686dd1249be..28660b0d4b9 100644 --- a/spec/models/diff_viewer/server_side_spec.rb +++ b/spec/models/diff_viewer/server_side_spec.rb @@ -4,6 +4,7 @@ require 'spec_helper' RSpec.describe DiffViewer::ServerSide do let_it_be(:project) { create(:project, :repository) } + let(:commit) { project.commit_by(oid: '570e7b2abdd848b95f2f578043fc23bd6f6fd24d') } let!(:diff_file) { commit.diffs.diff_file_with_new_path('files/ruby/popen.rb') } diff --git a/spec/models/environment_spec.rb b/spec/models/environment_spec.rb index ff4c8ae950d..18a172b72d7 100644 --- a/spec/models/environment_spec.rb +++ b/spec/models/environment_spec.rb @@ -219,6 +219,7 @@ RSpec.describe Environment, :use_clean_rails_memory_store_caching do let_it_be(:project) { create(:project, :repository) } let_it_be(:user) { create(:user) } + let(:environments) { Environment.all } before_all do @@ -760,6 +761,7 @@ RSpec.describe Environment, :use_clean_rails_memory_store_caching do describe '#last_visible_pipeline' do let(:user) { create(:user) } let_it_be(:project) { create(:project, :repository) } + let(:environment) { create(:environment, project: project) } let(:commit) { project.commit } @@ -1462,6 +1464,7 @@ RSpec.describe Environment, :use_clean_rails_memory_store_caching do let_it_be(:project) { create(:project, :repository) } let_it_be(:environment, reload: true) { create(:environment, project: project) } + let!(:deployment) { create(:deployment, project: project, environment: environment, deployable: build) } let!(:build) { create(:ci_build, :running, project: project, environment: environment) } diff --git a/spec/models/event_collection_spec.rb b/spec/models/event_collection_spec.rb index aca2a8c3a2f..107447c9630 100644 --- a/spec/models/event_collection_spec.rb +++ b/spec/models/event_collection_spec.rb @@ -28,6 +28,7 @@ RSpec.describe EventCollection do let_it_be(:closed_issue_event) { create(:closed_issue_event, project: project, author: user) } let_it_be(:wiki_page_event) { create(:wiki_page_event, project: project) } let_it_be(:design_event) { create(:design_event, project: project) } + let(:push_events) { push_event_payloads.map(&:event) } it 'returns an Array of events', :aggregate_failures do diff --git a/spec/models/label_note_spec.rb b/spec/models/label_note_spec.rb index 0bf202ce2b1..ee4822c653d 100644 --- a/spec/models/label_note_spec.rb +++ b/spec/models/label_note_spec.rb @@ -7,6 +7,7 @@ RSpec.describe LabelNote do let_it_be(:user) { create(:user) } let_it_be(:label) { create(:label, project: project) } let_it_be(:label2) { create(:label, project: project) } + let(:resource_parent) { project } context 'when resource is issue' do diff --git a/spec/models/lfs_file_lock_spec.rb b/spec/models/lfs_file_lock_spec.rb index d3f79c7c7cf..5afad6c184f 100644 --- a/spec/models/lfs_file_lock_spec.rb +++ b/spec/models/lfs_file_lock_spec.rb @@ -4,6 +4,7 @@ require 'spec_helper' RSpec.describe LfsFileLock do let_it_be(:lfs_file_lock, reload: true) { create(:lfs_file_lock) } + subject { lfs_file_lock } it { is_expected.to belong_to(:project) } diff --git a/spec/models/member_spec.rb b/spec/models/member_spec.rb index 1727a9f89f3..65932b6fb25 100644 --- a/spec/models/member_spec.rb +++ b/spec/models/member_spec.rb @@ -30,6 +30,7 @@ RSpec.describe Member do context "when an invite email is provided" do let_it_be(:project) { create(:project) } + let(:member) { build(:project_member, source: project, invite_email: "user@example.com", user: nil) } it "doesn't require a user" do @@ -98,6 +99,7 @@ RSpec.describe Member do context 'project bots' do let_it_be(:project_bot) { create(:user, :project_bot) } + let(:new_member) { build(:project_member, user_id: project_bot.id) } context 'not a member of any group or project' do diff --git a/spec/models/merge_request_diff_spec.rb b/spec/models/merge_request_diff_spec.rb index 865cb1a1594..e0e25031589 100644 --- a/spec/models/merge_request_diff_spec.rb +++ b/spec/models/merge_request_diff_spec.rb @@ -111,6 +111,7 @@ RSpec.describe MergeRequestDiff do let(:closed_recently) { recently_closed_mr.merge_request_diff } let_it_be(:recently_merged_mr) { create(:merge_request, :merged) } + let(:merged_recently) { recently_merged_mr.merge_request_diff } before do diff --git a/spec/models/namespace/root_storage_statistics_spec.rb b/spec/models/namespace/root_storage_statistics_spec.rb index b725d2366a1..51c191069ec 100644 --- a/spec/models/namespace/root_storage_statistics_spec.rb +++ b/spec/models/namespace/root_storage_statistics_spec.rb @@ -99,6 +99,7 @@ RSpec.describe Namespace::RootStorageStatistics, type: :model do context 'with a personal namespace' do let_it_be(:user) { create(:user) } + let(:namespace) { user.namespace } it_behaves_like 'data refresh' diff --git a/spec/models/note_spec.rb b/spec/models/note_spec.rb index d9f566f9383..2afe9a0f29b 100644 --- a/spec/models/note_spec.rb +++ b/spec/models/note_spec.rb @@ -455,6 +455,7 @@ RSpec.describe Note do describe "#system_note_viewable_by?(user)" do let_it_be(:note) { create(:note) } let_it_be(:user) { create(:user) } + let!(:metadata) { create(:system_note_metadata, note: note, action: "branch") } context "when system_note_metadata is not present" do @@ -536,6 +537,7 @@ RSpec.describe Note do context "when there is a reference to a label" do let_it_be(:private_label) { create(:label, project: private_project) } + let(:note) do create :note, noteable: ext_issue, project: ext_proj, @@ -550,6 +552,7 @@ RSpec.describe Note do context "when there are two references in note" do let_it_be(:ext_issue2) { create(:issue, project: ext_proj) } + let(:note) do create :note, noteable: ext_issue2, project: ext_proj, @@ -1239,6 +1242,7 @@ RSpec.describe Note do describe 'expiring ETag cache' do let_it_be(:issue) { create(:issue) } + let(:note) { build(:note, project: issue.project, noteable: issue) } def expect_expiration(noteable) diff --git a/spec/models/notification_setting_spec.rb b/spec/models/notification_setting_spec.rb index 010b7455f85..3f1684327e7 100644 --- a/spec/models/notification_setting_spec.rb +++ b/spec/models/notification_setting_spec.rb @@ -51,6 +51,7 @@ RSpec.describe NotificationSetting do context 'notification_email' do let_it_be(:user) { create(:user) } + subject { described_class.new(source_id: 1, source_type: 'Project', user_id: user.id) } it 'allows to change email to verified one' do diff --git a/spec/models/operations/feature_flag_spec.rb b/spec/models/operations/feature_flag_spec.rb index 55682e12642..cb9da2aea34 100644 --- a/spec/models/operations/feature_flag_spec.rb +++ b/spec/models/operations/feature_flag_spec.rb @@ -251,6 +251,7 @@ RSpec.describe Operations::FeatureFlag do describe '.for_unleash_client' do let_it_be(:project) { create(:project) } + let!(:feature_flag) do create(:operations_feature_flag, project: project, name: 'feature1', active: true, version: 2) diff --git a/spec/models/plan_limits_spec.rb b/spec/models/plan_limits_spec.rb index 07347dfb6ec..9078d72e044 100644 --- a/spec/models/plan_limits_spec.rb +++ b/spec/models/plan_limits_spec.rb @@ -5,6 +5,7 @@ require 'spec_helper' RSpec.describe PlanLimits do let_it_be(:project) { create(:project) } let_it_be(:plan_limits) { create(:plan_limits) } + let(:project_hooks_count) { 2 } before do diff --git a/spec/models/prometheus_alert_spec.rb b/spec/models/prometheus_alert_spec.rb index 8e517e1764e..bfe2c7cc2a4 100644 --- a/spec/models/prometheus_alert_spec.rb +++ b/spec/models/prometheus_alert_spec.rb @@ -4,6 +4,7 @@ require 'spec_helper' RSpec.describe PrometheusAlert do let_it_be(:project) { build(:project) } + let(:metric) { build(:prometheus_metric) } describe '.distinct_projects' do diff --git a/spec/models/protected_branch/push_access_level_spec.rb b/spec/models/protected_branch/push_access_level_spec.rb index 17a589f0485..fb8a396269c 100644 --- a/spec/models/protected_branch/push_access_level_spec.rb +++ b/spec/models/protected_branch/push_access_level_spec.rb @@ -40,6 +40,7 @@ RSpec.describe ProtectedBranch::PushAccessLevel do let_it_be(:protected_branch) { create(:protected_branch, :no_one_can_push, project: project) } let_it_be(:user) { create(:user) } let_it_be(:deploy_key) { create(:deploy_key, user: user) } + let!(:deploy_keys_project) { create(:deploy_keys_project, project: project, deploy_key: deploy_key, can_push: can_push) } let(:can_push) { true } diff --git a/spec/models/repository_spec.rb b/spec/models/repository_spec.rb index b6f09babb4b..4b0435baa98 100644 --- a/spec/models/repository_spec.rb +++ b/spec/models/repository_spec.rb @@ -41,6 +41,7 @@ RSpec.describe Repository do describe '#branch_names_contains' do let_it_be(:project) { create(:project, :repository) } + let(:repository) { project.repository } subject { repository.branch_names_contains(sample_commit.id) } @@ -398,6 +399,7 @@ RSpec.describe Repository do describe '#new_commits' do let_it_be(:project) { create(:project, :repository) } + let(:repository) { project.repository } subject { repository.new_commits(rev) } @@ -426,6 +428,7 @@ RSpec.describe Repository do describe '#commits_by' do let_it_be(:project) { create(:project, :repository) } + let(:oids) { TestEnv::BRANCH_SHA.values } subject { project.repository.commits_by(oids: oids) } @@ -2984,6 +2987,7 @@ RSpec.describe Repository do describe '#merge_base' do let_it_be(:project) { create(:project, :repository) } + subject(:repository) { project.repository } it 'only makes one gitaly call' do @@ -3082,6 +3086,7 @@ RSpec.describe Repository do describe "#blobs_metadata" do let_it_be(:project) { create(:project, :repository) } + let(:repository) { project.repository } def expect_metadata_blob(thing) diff --git a/spec/models/snippet_repository_spec.rb b/spec/models/snippet_repository_spec.rb index 11196f06529..40a28b9e0cc 100644 --- a/spec/models/snippet_repository_spec.rb +++ b/spec/models/snippet_repository_spec.rb @@ -4,6 +4,7 @@ require 'spec_helper' RSpec.describe SnippetRepository do let_it_be(:user) { create(:user) } + let(:snippet) { create(:personal_snippet, :repository, author: user) } let(:snippet_repository) { snippet.snippet_repository } let(:commit_opts) { { branch_name: 'master', message: 'whatever' } } diff --git a/spec/models/snippet_spec.rb b/spec/models/snippet_spec.rb index 06e9899c0bd..474a73a4df1 100644 --- a/spec/models/snippet_spec.rb +++ b/spec/models/snippet_spec.rb @@ -722,6 +722,7 @@ RSpec.describe Snippet do describe '#list_files' do let_it_be(:snippet) { create(:snippet, :repository) } + let(:ref) { 'test-ref' } subject { snippet.list_files(ref) } diff --git a/spec/models/terraform/state_spec.rb b/spec/models/terraform/state_spec.rb index 1319e2adb03..a113ae37203 100644 --- a/spec/models/terraform/state_spec.rb +++ b/spec/models/terraform/state_spec.rb @@ -16,6 +16,7 @@ RSpec.describe Terraform::State do describe 'scopes' do describe '.ordered_by_name' do let_it_be(:project) { create(:project) } + let(:names) { %w(state_d state_b state_a state_c) } subject { described_class.ordered_by_name } diff --git a/spec/models/u2f_registration_spec.rb b/spec/models/u2f_registration_spec.rb index 1f2e4d1e447..aba2f27d104 100644 --- a/spec/models/u2f_registration_spec.rb +++ b/spec/models/u2f_registration_spec.rb @@ -4,6 +4,7 @@ require 'spec_helper' RSpec.describe U2fRegistration do let_it_be(:user) { create(:user) } + let(:u2f_registration) do device = U2F::FakeU2F.new(FFaker::BaconIpsum.characters(5)) create(:u2f_registration, name: 'u2f_device', diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index e5c86e69ffc..45f1ad71962 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -991,6 +991,7 @@ RSpec.describe User do let_it_be(:valid_token_and_notified) { create(:personal_access_token, user: user2, expires_at: 2.days.from_now, expire_notification_delivered: true) } let_it_be(:valid_token1) { create(:personal_access_token, user: user2, expires_at: 2.days.from_now) } let_it_be(:valid_token2) { create(:personal_access_token, user: user2, expires_at: 2.days.from_now) } + let(:users) { described_class.with_expiring_and_not_notified_personal_access_tokens(from) } context 'in one day' do @@ -4208,6 +4209,7 @@ RSpec.describe User do describe '#source_groups_of_two_factor_authentication_requirement' do let_it_be(:group_not_requiring_2FA) { create :group } + let(:user) { create :user } before do diff --git a/spec/requests/api/api_spec.rb b/spec/requests/api/api_spec.rb index 46430e55ff2..81620fce448 100644 --- a/spec/requests/api/api_spec.rb +++ b/spec/requests/api/api_spec.rb @@ -81,6 +81,7 @@ RSpec.describe API::API do let_it_be(:maven_metadatum) { package.maven_metadatum } let_it_be(:package_file) { package.package_files.first } let_it_be(:deploy_token) { create(:deploy_token) } + let(:headers_with_deploy_token) do { Gitlab::Auth::AuthFinders::DEPLOY_TOKEN_HEADER => deploy_token.token @@ -138,6 +139,7 @@ RSpec.describe API::API do describe 'Marginalia comments' do context 'GET /user/:id' do let_it_be(:user) { create(:user) } + let(:component_map) do { "application" => "test", diff --git a/spec/requests/api/award_emoji_spec.rb b/spec/requests/api/award_emoji_spec.rb index 1c825949ae8..07a9f7dfd74 100644 --- a/spec/requests/api/award_emoji_spec.rb +++ b/spec/requests/api/award_emoji_spec.rb @@ -8,6 +8,7 @@ RSpec.describe API::AwardEmoji do let_it_be(:issue) { create(:issue, project: project) } let_it_be(:award_emoji) { create(:award_emoji, awardable: issue, user: user) } let_it_be(:note) { create(:note, project: project, noteable: issue) } + let!(:merge_request) { create(:merge_request, source_project: project, target_project: project) } let!(:downvote) { create(:award_emoji, :downvote, awardable: merge_request, user: user) } diff --git a/spec/requests/api/branches_spec.rb b/spec/requests/api/branches_spec.rb index 36fbe86ac76..e0a279d6ea4 100644 --- a/spec/requests/api/branches_spec.rb +++ b/spec/requests/api/branches_spec.rb @@ -4,6 +4,7 @@ require 'spec_helper' RSpec.describe API::Branches do let_it_be(:user) { create(:user) } + let(:project) { create(:project, :repository, creator: user, path: 'my.project') } let(:guest) { create(:user).tap { |u| project.add_guest(u) } } let(:branch_name) { 'feature' } diff --git a/spec/requests/api/ci/pipelines_spec.rb b/spec/requests/api/ci/pipelines_spec.rb index 092cd00630e..eb6c0861844 100644 --- a/spec/requests/api/ci/pipelines_spec.rb +++ b/spec/requests/api/ci/pipelines_spec.rb @@ -491,6 +491,7 @@ RSpec.describe API::Ci::Pipelines do describe 'GET /projects/:id/pipelines/:pipeline_id/bridges' do let_it_be(:bridge) { create(:ci_bridge, pipeline: pipeline) } + let(:downstream_pipeline) { create(:ci_pipeline) } let!(:pipeline_source) do diff --git a/spec/requests/api/composer_packages_spec.rb b/spec/requests/api/composer_packages_spec.rb index 4120edabea3..e75725cacba 100644 --- a/spec/requests/api/composer_packages_spec.rb +++ b/spec/requests/api/composer_packages_spec.rb @@ -9,6 +9,7 @@ RSpec.describe API::ComposerPackages do let_it_be(:personal_access_token) { create(:personal_access_token, user: user) } let_it_be(:package_name) { 'package-name' } let_it_be(:project, reload: true) { create(:project, :custom_repo, files: { 'composer.json' => { name: package_name }.to_json }, group: group) } + let(:snowplow_gitlab_standard_context) { { project: project, namespace: project.namespace, user: user } } let(:headers) { {} } diff --git a/spec/requests/api/deploy_tokens_spec.rb b/spec/requests/api/deploy_tokens_spec.rb index e8426270622..38380fa4460 100644 --- a/spec/requests/api/deploy_tokens_spec.rb +++ b/spec/requests/api/deploy_tokens_spec.rb @@ -7,6 +7,7 @@ RSpec.describe API::DeployTokens do let_it_be(:creator) { create(:user) } let_it_be(:project) { create(:project, creator_id: creator.id) } let_it_be(:group) { create(:group) } + let!(:deploy_token) { create(:deploy_token, projects: [project]) } let!(:revoked_deploy_token) { create(:deploy_token, projects: [project], revoked: true) } let!(:expired_deploy_token) { create(:deploy_token, projects: [project], expires_at: '1988-01-11T04:33:04-0600') } diff --git a/spec/requests/api/deployments_spec.rb b/spec/requests/api/deployments_spec.rb index bbfe37cb70b..38c96cd37af 100644 --- a/spec/requests/api/deployments_spec.rb +++ b/spec/requests/api/deployments_spec.rb @@ -456,6 +456,7 @@ RSpec.describe API::Deployments do context 'when a user member of the deployment project' do let_it_be(:project2) { create(:project) } + let!(:merge_request1) { create(:merge_request, source_project: project, target_project: project) } let!(:merge_request2) { create(:merge_request, source_project: project, target_project: project, state: 'closed') } let!(:merge_request3) { create(:merge_request, source_project: project2, target_project: project2) } diff --git a/spec/requests/api/error_tracking_spec.rb b/spec/requests/api/error_tracking_spec.rb index 8c9ca1b6a9d..39121af7bc3 100644 --- a/spec/requests/api/error_tracking_spec.rb +++ b/spec/requests/api/error_tracking_spec.rb @@ -4,6 +4,7 @@ require 'spec_helper' RSpec.describe API::ErrorTracking do let_it_be(:user) { create(:user) } + let(:setting) { create(:project_error_tracking_setting) } let(:project) { setting.project } diff --git a/spec/requests/api/feature_flags_spec.rb b/spec/requests/api/feature_flags_spec.rb index 2cd52c0a5e5..8edf8825fb2 100644 --- a/spec/requests/api/feature_flags_spec.rb +++ b/spec/requests/api/feature_flags_spec.rb @@ -8,6 +8,7 @@ RSpec.describe API::FeatureFlags do let_it_be(:developer) { create(:user) } let_it_be(:reporter) { create(:user) } let_it_be(:non_project_member) { create(:user) } + let(:user) { developer } before_all do diff --git a/spec/requests/api/freeze_periods_spec.rb b/spec/requests/api/freeze_periods_spec.rb index 5589d4d543d..3da992301d5 100644 --- a/spec/requests/api/freeze_periods_spec.rb +++ b/spec/requests/api/freeze_periods_spec.rb @@ -6,6 +6,7 @@ RSpec.describe API::FreezePeriods do let_it_be(:project) { create(:project, :repository, :private) } let_it_be(:user) { create(:user) } let_it_be(:admin) { create(:admin) } + let(:api_user) { user } let(:invalid_cron) { '0 0 0 * *' } let(:last_freeze_period) { project.freeze_periods.last } diff --git a/spec/requests/api/graphql/boards/board_lists_query_spec.rb b/spec/requests/api/graphql/boards/board_lists_query_spec.rb index cd94ce91071..2d52cddcacc 100644 --- a/spec/requests/api/graphql/boards/board_lists_query_spec.rb +++ b/spec/requests/api/graphql/boards/board_lists_query_spec.rb @@ -66,6 +66,7 @@ RSpec.describe 'get board lists' do describe 'sorting and pagination' do let_it_be(:current_user) { user } + let(:data_path) { [board_parent_type, :boards, :nodes, 0, :lists] } def pagination_query(params) diff --git a/spec/requests/api/graphql/ci/pipelines_spec.rb b/spec/requests/api/graphql/ci/pipelines_spec.rb index f207636283f..6587061094d 100644 --- a/spec/requests/api/graphql/ci/pipelines_spec.rb +++ b/spec/requests/api/graphql/ci/pipelines_spec.rb @@ -229,6 +229,7 @@ RSpec.describe 'Query.project(fullPath).pipelines' do let_it_be(:pipeline) { create(:ci_pipeline, project: project, user: user) } let_it_be(:upstream_project) { create(:project, :repository, :public) } let_it_be(:upstream_pipeline) { create(:ci_pipeline, project: upstream_project, user: user) } + let(:upstream_pipelines_graphql_data) { graphql_data.dig(*%w[project pipelines nodes]).first['upstream'] } let(:query) do diff --git a/spec/requests/api/graphql/current_user_todos_spec.rb b/spec/requests/api/graphql/current_user_todos_spec.rb index b657f15d0e9..7f37abba74a 100644 --- a/spec/requests/api/graphql/current_user_todos_spec.rb +++ b/spec/requests/api/graphql/current_user_todos_spec.rb @@ -10,6 +10,7 @@ RSpec.describe 'A Todoable that implements the CurrentUserTodos interface' do let_it_be(:todoable) { create(:issue, project: project) } let_it_be(:done_todo) { create(:todo, state: :done, target: todoable, user: current_user) } let_it_be(:pending_todo) { create(:todo, state: :pending, target: todoable, user: current_user) } + let(:state) { 'null' } let(:todoable_response) do diff --git a/spec/requests/api/graphql/issue_status_counts_spec.rb b/spec/requests/api/graphql/issue_status_counts_spec.rb index 3d8817c3bc5..89ecbf44b10 100644 --- a/spec/requests/api/graphql/issue_status_counts_spec.rb +++ b/spec/requests/api/graphql/issue_status_counts_spec.rb @@ -9,6 +9,7 @@ RSpec.describe 'getting Issue counts by status' do let_it_be(:issue_opened) { create(:issue, project: project) } let_it_be(:issue_closed) { create(:issue, :closed, project: project) } let_it_be(:other_project_issue) { create(:issue) } + let(:params) { {} } let(:fields) do diff --git a/spec/requests/api/graphql/metrics/dashboard_query_spec.rb b/spec/requests/api/graphql/metrics/dashboard_query_spec.rb index e01f59ee6a0..1b84acff0e2 100644 --- a/spec/requests/api/graphql/metrics/dashboard_query_spec.rb +++ b/spec/requests/api/graphql/metrics/dashboard_query_spec.rb @@ -6,6 +6,7 @@ RSpec.describe 'Getting Metrics Dashboard' do include GraphqlHelpers let_it_be(:current_user) { create(:user) } + let(:project) { create(:project) } let(:environment) { create(:environment, project: project) } diff --git a/spec/requests/api/graphql/mutations/admin/sidekiq_queues/delete_jobs_spec.rb b/spec/requests/api/graphql/mutations/admin/sidekiq_queues/delete_jobs_spec.rb index b8cde32877b..1692cfbcf84 100644 --- a/spec/requests/api/graphql/mutations/admin/sidekiq_queues/delete_jobs_spec.rb +++ b/spec/requests/api/graphql/mutations/admin/sidekiq_queues/delete_jobs_spec.rb @@ -6,6 +6,7 @@ RSpec.describe 'Deleting Sidekiq jobs', :clean_gitlab_redis_queues do include GraphqlHelpers let_it_be(:admin) { create(:admin) } + let(:queue) { 'authorized_projects' } let(:variables) { { user: admin.username, queue_name: queue } } diff --git a/spec/requests/api/graphql/mutations/alert_management/alerts/set_assignees_spec.rb b/spec/requests/api/graphql/mutations/alert_management/alerts/set_assignees_spec.rb index cd5cefa0a9a..fcef7b4e3ec 100644 --- a/spec/requests/api/graphql/mutations/alert_management/alerts/set_assignees_spec.rb +++ b/spec/requests/api/graphql/mutations/alert_management/alerts/set_assignees_spec.rb @@ -8,6 +8,7 @@ RSpec.describe 'Setting assignees of an alert' do let_it_be(:project) { create(:project) } let_it_be(:current_user) { create(:user) } let_it_be(:alert) { create(:alert_management_alert, project: project) } + let(:input) { { assignee_usernames: [current_user.username] } } let(:mutation) do diff --git a/spec/requests/api/graphql/mutations/alert_management/alerts/todo/create_spec.rb b/spec/requests/api/graphql/mutations/alert_management/alerts/todo/create_spec.rb index cd423d7764a..48307964345 100644 --- a/spec/requests/api/graphql/mutations/alert_management/alerts/todo/create_spec.rb +++ b/spec/requests/api/graphql/mutations/alert_management/alerts/todo/create_spec.rb @@ -7,6 +7,7 @@ RSpec.describe 'Creating a todo for the alert' do let_it_be(:user) { create(:user) } let_it_be(:project) { create(:project) } + let(:alert) { create(:alert_management_alert, project: project) } let(:mutation) do diff --git a/spec/requests/api/graphql/mutations/alert_management/alerts/update_alert_status_spec.rb b/spec/requests/api/graphql/mutations/alert_management/alerts/update_alert_status_spec.rb index ff55656a2ae..802d8d6c5a1 100644 --- a/spec/requests/api/graphql/mutations/alert_management/alerts/update_alert_status_spec.rb +++ b/spec/requests/api/graphql/mutations/alert_management/alerts/update_alert_status_spec.rb @@ -7,6 +7,7 @@ RSpec.describe 'Setting the status of an alert' do let_it_be(:user) { create(:user) } let_it_be(:project) { create(:project) } + let(:alert) { create(:alert_management_alert, project: project) } let(:input) { { status: 'ACKNOWLEDGED' } } diff --git a/spec/requests/api/graphql/mutations/alert_management/http_integration/create_spec.rb b/spec/requests/api/graphql/mutations/alert_management/http_integration/create_spec.rb index e594d67aab4..ff93da2153f 100644 --- a/spec/requests/api/graphql/mutations/alert_management/http_integration/create_spec.rb +++ b/spec/requests/api/graphql/mutations/alert_management/http_integration/create_spec.rb @@ -7,6 +7,7 @@ RSpec.describe 'Creating a new HTTP Integration' do let_it_be(:current_user) { create(:user) } let_it_be(:project) { create(:project) } + let(:variables) do { project_path: project.full_path, diff --git a/spec/requests/api/graphql/mutations/alert_management/prometheus_integration/create_spec.rb b/spec/requests/api/graphql/mutations/alert_management/prometheus_integration/create_spec.rb index dd7806bdbe0..4c359d9b357 100644 --- a/spec/requests/api/graphql/mutations/alert_management/prometheus_integration/create_spec.rb +++ b/spec/requests/api/graphql/mutations/alert_management/prometheus_integration/create_spec.rb @@ -7,6 +7,7 @@ RSpec.describe 'Creating a new Prometheus Integration' do let_it_be(:current_user) { create(:user) } let_it_be(:project) { create(:project) } + let(:variables) do { project_path: project.full_path, diff --git a/spec/requests/api/graphql/mutations/award_emojis/add_spec.rb b/spec/requests/api/graphql/mutations/award_emojis/add_spec.rb index b39062f2e71..fdf5503a3a2 100644 --- a/spec/requests/api/graphql/mutations/award_emojis/add_spec.rb +++ b/spec/requests/api/graphql/mutations/award_emojis/add_spec.rb @@ -8,6 +8,7 @@ RSpec.describe 'Adding an AwardEmoji' do let_it_be(:current_user) { create(:user) } let_it_be(:project) { create(:project) } let_it_be(:awardable) { create(:note, project: project) } + let(:emoji_name) { 'thumbsup' } let(:mutation) do variables = { diff --git a/spec/requests/api/graphql/mutations/award_emojis/toggle_spec.rb b/spec/requests/api/graphql/mutations/award_emojis/toggle_spec.rb index 170e7ff3b44..6b26e37e30c 100644 --- a/spec/requests/api/graphql/mutations/award_emojis/toggle_spec.rb +++ b/spec/requests/api/graphql/mutations/award_emojis/toggle_spec.rb @@ -8,6 +8,7 @@ RSpec.describe 'Toggling an AwardEmoji' do let_it_be(:current_user) { create(:user) } let_it_be(:project, reload: true) { create(:project) } let_it_be(:awardable) { create(:note, project: project) } + let(:emoji_name) { 'thumbsup' } let(:mutation) do variables = { diff --git a/spec/requests/api/graphql/mutations/boards/create_spec.rb b/spec/requests/api/graphql/mutations/boards/create_spec.rb index c5f981262ea..22d05f36f0f 100644 --- a/spec/requests/api/graphql/mutations/boards/create_spec.rb +++ b/spec/requests/api/graphql/mutations/boards/create_spec.rb @@ -4,6 +4,7 @@ require 'spec_helper' RSpec.describe Mutations::Boards::Create do let_it_be(:parent) { create(:project) } + let(:project_path) { parent.full_path } let(:params) do { diff --git a/spec/requests/api/graphql/mutations/branches/create_spec.rb b/spec/requests/api/graphql/mutations/branches/create_spec.rb index fc09f57a389..2f19de2af54 100644 --- a/spec/requests/api/graphql/mutations/branches/create_spec.rb +++ b/spec/requests/api/graphql/mutations/branches/create_spec.rb @@ -7,6 +7,7 @@ RSpec.describe 'Creation of a new branch' do let_it_be(:current_user) { create(:user) } let_it_be(:project) { create(:project, :public, :empty_repo) } + let(:input) { { project_path: project.full_path, name: new_branch, ref: ref } } let(:new_branch) { 'new_branch' } let(:ref) { 'master' } diff --git a/spec/requests/api/graphql/mutations/commits/create_spec.rb b/spec/requests/api/graphql/mutations/commits/create_spec.rb index 375d4f10b40..619cba99c4e 100644 --- a/spec/requests/api/graphql/mutations/commits/create_spec.rb +++ b/spec/requests/api/graphql/mutations/commits/create_spec.rb @@ -7,6 +7,7 @@ RSpec.describe 'Creation of a new commit' do let_it_be(:current_user) { create(:user) } let_it_be(:project) { create(:project, :public, :repository) } + let(:input) { { project_path: project.full_path, branch: branch, message: message, actions: actions } } let(:branch) { 'master' } let(:message) { 'Commit message' } diff --git a/spec/requests/api/graphql/mutations/container_expiration_policy/update_spec.rb b/spec/requests/api/graphql/mutations/container_expiration_policy/update_spec.rb index 23e8e366483..0156142dc6f 100644 --- a/spec/requests/api/graphql/mutations/container_expiration_policy/update_spec.rb +++ b/spec/requests/api/graphql/mutations/container_expiration_policy/update_spec.rb @@ -53,6 +53,7 @@ RSpec.describe 'Updating the container expiration policy' do RSpec.shared_examples 'rejecting invalid regex for' do |field_name| context "for field #{field_name}" do let_it_be(:invalid_regex) { '*production' } + let(:params) do { :project_path => project.full_path, diff --git a/spec/requests/api/graphql/mutations/discussions/toggle_resolve_spec.rb b/spec/requests/api/graphql/mutations/discussions/toggle_resolve_spec.rb index 450996bf76b..632a934cd95 100644 --- a/spec/requests/api/graphql/mutations/discussions/toggle_resolve_spec.rb +++ b/spec/requests/api/graphql/mutations/discussions/toggle_resolve_spec.rb @@ -7,6 +7,7 @@ RSpec.describe 'Toggling the resolve status of a discussion' do let_it_be(:project) { create(:project, :public, :repository) } let_it_be(:noteable) { create(:merge_request, source_project: project) } + let(:discussion) do create(:diff_note_on_merge_request, noteable: noteable, project: project).to_discussion end diff --git a/spec/requests/api/graphql/mutations/environments/canary_ingress/update_spec.rb b/spec/requests/api/graphql/mutations/environments/canary_ingress/update_spec.rb index f25a49291a6..3771ae0746e 100644 --- a/spec/requests/api/graphql/mutations/environments/canary_ingress/update_spec.rb +++ b/spec/requests/api/graphql/mutations/environments/canary_ingress/update_spec.rb @@ -13,6 +13,7 @@ RSpec.describe 'Update Environment Canary Ingress', :clean_gitlab_redis_cache do let_it_be(:deployment) { create(:deployment, :success, environment: environment, project: project) } let_it_be(:maintainer) { create(:user) } let_it_be(:developer) { create(:user) } + let(:environment_id) { environment.to_global_id.to_s } let(:weight) { 25 } let(:actor) { developer } diff --git a/spec/requests/api/graphql/mutations/issues/set_locked_spec.rb b/spec/requests/api/graphql/mutations/issues/set_locked_spec.rb index 4989d096925..435ed0f9eb2 100644 --- a/spec/requests/api/graphql/mutations/issues/set_locked_spec.rb +++ b/spec/requests/api/graphql/mutations/issues/set_locked_spec.rb @@ -8,6 +8,7 @@ RSpec.describe 'Setting an issue as locked' do let_it_be(:current_user) { create(:user) } let_it_be(:issue) { create(:issue) } let_it_be(:project) { issue.project } + let(:input) { { locked: true } } let(:mutation) do diff --git a/spec/requests/api/graphql/mutations/issues/set_severity_spec.rb b/spec/requests/api/graphql/mutations/issues/set_severity_spec.rb index 96fd2368765..41997f151a2 100644 --- a/spec/requests/api/graphql/mutations/issues/set_severity_spec.rb +++ b/spec/requests/api/graphql/mutations/issues/set_severity_spec.rb @@ -6,6 +6,7 @@ RSpec.describe 'Setting severity level of an incident' do include GraphqlHelpers let_it_be(:user) { create(:user) } + let(:incident) { create(:incident) } let(:project) { incident.project } let(:input) { { severity: 'CRITICAL' } } diff --git a/spec/requests/api/graphql/mutations/issues/update_spec.rb b/spec/requests/api/graphql/mutations/issues/update_spec.rb index adfa2a2bc08..b3e1ab62e54 100644 --- a/spec/requests/api/graphql/mutations/issues/update_spec.rb +++ b/spec/requests/api/graphql/mutations/issues/update_spec.rb @@ -8,6 +8,7 @@ RSpec.describe 'Update of an existing issue' do let_it_be(:current_user) { create(:user) } let_it_be(:project) { create(:project, :public) } let_it_be(:issue) { create(:issue, project: project) } + let(:input) do { 'iid' => issue.iid.to_s, diff --git a/spec/requests/api/graphql/mutations/jira_import/import_users_spec.rb b/spec/requests/api/graphql/mutations/jira_import/import_users_spec.rb index 00b93984f98..45cc70f09fd 100644 --- a/spec/requests/api/graphql/mutations/jira_import/import_users_spec.rb +++ b/spec/requests/api/graphql/mutations/jira_import/import_users_spec.rb @@ -8,6 +8,7 @@ RSpec.describe 'Importing Jira Users' do let_it_be(:user) { create(:user) } let_it_be(:project) { create(:project) } + let(:importer) { instance_double(JiraImport::UsersImporter) } let(:project_path) { project.full_path } let(:start_at) { 7 } diff --git a/spec/requests/api/graphql/mutations/jira_import/start_spec.rb b/spec/requests/api/graphql/mutations/jira_import/start_spec.rb index 75668c9e6ae..b14305281af 100644 --- a/spec/requests/api/graphql/mutations/jira_import/start_spec.rb +++ b/spec/requests/api/graphql/mutations/jira_import/start_spec.rb @@ -8,6 +8,7 @@ RSpec.describe 'Starting a Jira Import' do let_it_be(:user) { create(:user) } let_it_be(:project, reload: true) { create(:project) } + let(:jira_project_key) { 'AA' } let(:project_path) { project.full_path } diff --git a/spec/requests/api/graphql/mutations/labels/create_spec.rb b/spec/requests/api/graphql/mutations/labels/create_spec.rb index 28284408306..d19411f6c1d 100644 --- a/spec/requests/api/graphql/mutations/labels/create_spec.rb +++ b/spec/requests/api/graphql/mutations/labels/create_spec.rb @@ -61,6 +61,7 @@ RSpec.describe Mutations::Labels::Create do context 'when creating a project label' do let_it_be(:parent) { create(:project) } + let(:extra_params) { { project_path: parent.full_path } } it_behaves_like 'labels create mutation' @@ -68,6 +69,7 @@ RSpec.describe Mutations::Labels::Create do context 'when creating a group label' do let_it_be(:parent) { create(:group) } + let(:extra_params) { { group_path: parent.full_path } } it_behaves_like 'labels create mutation' diff --git a/spec/requests/api/graphql/mutations/merge_requests/accept_spec.rb b/spec/requests/api/graphql/mutations/merge_requests/accept_spec.rb index 2725b33d528..19a7c72ba80 100644 --- a/spec/requests/api/graphql/mutations/merge_requests/accept_spec.rb +++ b/spec/requests/api/graphql/mutations/merge_requests/accept_spec.rb @@ -7,6 +7,7 @@ RSpec.describe 'accepting a merge request', :request_store do let_it_be(:current_user) { create(:user) } let_it_be(:project) { create(:project, :public, :repository) } + let!(:merge_request) { create(:merge_request, source_project: project) } let(:input) do { diff --git a/spec/requests/api/graphql/mutations/merge_requests/create_spec.rb b/spec/requests/api/graphql/mutations/merge_requests/create_spec.rb index bf759521dc0..3a4508489a1 100644 --- a/spec/requests/api/graphql/mutations/merge_requests/create_spec.rb +++ b/spec/requests/api/graphql/mutations/merge_requests/create_spec.rb @@ -6,6 +6,7 @@ RSpec.describe 'Creation of a new merge request' do include GraphqlHelpers let_it_be(:current_user) { create(:user) } + let(:project) { create(:project, :public, :repository) } let(:input) do { diff --git a/spec/requests/api/graphql/mutations/metrics/dashboard/annotations/create_spec.rb b/spec/requests/api/graphql/mutations/metrics/dashboard/annotations/create_spec.rb index 2a39757e103..5bc3c68cf26 100644 --- a/spec/requests/api/graphql/mutations/metrics/dashboard/annotations/create_spec.rb +++ b/spec/requests/api/graphql/mutations/metrics/dashboard/annotations/create_spec.rb @@ -9,6 +9,7 @@ RSpec.describe Mutations::Metrics::Dashboard::Annotations::Create do let_it_be(:project) { create(:project, :private, :repository) } let_it_be(:environment) { create(:environment, project: project) } let_it_be(:cluster) { create(:cluster, projects: [project]) } + let(:dashboard_path) { 'config/prometheus/common_metrics.yml' } let(:starting_at) { Time.current.iso8601 } let(:ending_at) { 1.hour.from_now.iso8601 } diff --git a/spec/requests/api/graphql/mutations/namespace/package_settings/update_spec.rb b/spec/requests/api/graphql/mutations/namespace/package_settings/update_spec.rb index 202e7e7c333..d335642d321 100644 --- a/spec/requests/api/graphql/mutations/namespace/package_settings/update_spec.rb +++ b/spec/requests/api/graphql/mutations/namespace/package_settings/update_spec.rb @@ -126,6 +126,7 @@ RSpec.describe 'Updating the package settings' do context 'without existing package settings' do let_it_be(:namespace, reload: true) { create(:group) } + let(:package_settings) { namespace.package_settings } where(:user_role, :shared_examples_name) do diff --git a/spec/requests/api/graphql/mutations/notes/create/diff_note_spec.rb b/spec/requests/api/graphql/mutations/notes/create/diff_note_spec.rb index b5aaf304812..8f3ae9f26f6 100644 --- a/spec/requests/api/graphql/mutations/notes/create/diff_note_spec.rb +++ b/spec/requests/api/graphql/mutations/notes/create/diff_note_spec.rb @@ -6,6 +6,7 @@ RSpec.describe 'Adding a DiffNote' do include GraphqlHelpers let_it_be(:current_user) { create(:user) } + let(:noteable) { create(:merge_request, source_project: project, target_project: project) } let(:project) { create(:project, :repository) } let(:diff_refs) { noteable.diff_refs } diff --git a/spec/requests/api/graphql/mutations/notes/create/image_diff_note_spec.rb b/spec/requests/api/graphql/mutations/notes/create/image_diff_note_spec.rb index 0e5744fb64f..8f2438cb741 100644 --- a/spec/requests/api/graphql/mutations/notes/create/image_diff_note_spec.rb +++ b/spec/requests/api/graphql/mutations/notes/create/image_diff_note_spec.rb @@ -6,6 +6,7 @@ RSpec.describe 'Adding an image DiffNote' do include GraphqlHelpers let_it_be(:current_user) { create(:user) } + let(:noteable) { create(:merge_request, source_project: project, target_project: project) } let(:project) { create(:project, :repository) } let(:diff_refs) { noteable.diff_refs } diff --git a/spec/requests/api/graphql/mutations/notes/create/note_spec.rb b/spec/requests/api/graphql/mutations/notes/create/note_spec.rb index 8dd8ed361ba..87c752393ea 100644 --- a/spec/requests/api/graphql/mutations/notes/create/note_spec.rb +++ b/spec/requests/api/graphql/mutations/notes/create/note_spec.rb @@ -6,6 +6,7 @@ RSpec.describe 'Adding a Note' do include GraphqlHelpers let_it_be(:current_user) { create(:user) } + let(:noteable) { create(:merge_request, source_project: project, target_project: project) } let(:project) { create(:project) } let(:discussion) { nil } diff --git a/spec/requests/api/graphql/mutations/notes/reposition_image_diff_note_spec.rb b/spec/requests/api/graphql/mutations/notes/reposition_image_diff_note_spec.rb index 4efa7f9d509..89e3a71280f 100644 --- a/spec/requests/api/graphql/mutations/notes/reposition_image_diff_note_spec.rb +++ b/spec/requests/api/graphql/mutations/notes/reposition_image_diff_note_spec.rb @@ -7,6 +7,7 @@ RSpec.describe 'Repositioning an ImageDiffNote' do let_it_be(:noteable) { create(:merge_request) } let_it_be(:project) { noteable.project } + let(:note) { create(:image_diff_note_on_merge_request, noteable: noteable, project: project) } let(:new_position) { { x: 10 } } let(:current_user) { project.creator } diff --git a/spec/requests/api/graphql/mutations/notes/update/image_diff_note_spec.rb b/spec/requests/api/graphql/mutations/notes/update/image_diff_note_spec.rb index 1ce09881fde..cfd0b34b815 100644 --- a/spec/requests/api/graphql/mutations/notes/update/image_diff_note_spec.rb +++ b/spec/requests/api/graphql/mutations/notes/update/image_diff_note_spec.rb @@ -26,6 +26,7 @@ RSpec.describe 'Updating an image DiffNote' do let_it_be(:updated_height) { 100 } let_it_be(:updated_x) { 5 } let_it_be(:updated_y) { 10 } + let(:updated_position) do { width: updated_width, diff --git a/spec/requests/api/graphql/mutations/snippets/mark_as_spam_spec.rb b/spec/requests/api/graphql/mutations/snippets/mark_as_spam_spec.rb index 4d499310591..43d846cb297 100644 --- a/spec/requests/api/graphql/mutations/snippets/mark_as_spam_spec.rb +++ b/spec/requests/api/graphql/mutations/snippets/mark_as_spam_spec.rb @@ -10,6 +10,7 @@ RSpec.describe 'Mark snippet as spam' do let_it_be(:other_user) { create(:user) } let_it_be(:snippet) { create(:personal_snippet) } let_it_be(:user_agent_detail) { create(:user_agent_detail, subject: snippet) } + let(:current_user) { snippet.author } let(:snippet_gid) { snippet.to_global_id.to_s } diff --git a/spec/requests/api/graphql/mutations/snippets/update_spec.rb b/spec/requests/api/graphql/mutations/snippets/update_spec.rb index a3a6ce65e9f..eb7e6f840fe 100644 --- a/spec/requests/api/graphql/mutations/snippets/update_spec.rb +++ b/spec/requests/api/graphql/mutations/snippets/update_spec.rb @@ -9,6 +9,7 @@ RSpec.describe 'Updating a Snippet' do let_it_be(:original_description) { 'Initial description' } let_it_be(:original_title) { 'Initial title' } let_it_be(:original_file_name) { 'Initial file_name' } + let(:updated_content) { 'Updated content' } let(:updated_description) { 'Updated description' } let(:updated_title) { 'Updated_title' } @@ -139,6 +140,7 @@ RSpec.describe 'Updating a Snippet' do describe 'ProjectSnippet' do let_it_be(:project) { create(:project, :private) } + let(:snippet) do create(:project_snippet, :private, diff --git a/spec/requests/api/graphql/mutations/user_callouts/create_spec.rb b/spec/requests/api/graphql/mutations/user_callouts/create_spec.rb index cb67a60ebe4..716983f01d2 100644 --- a/spec/requests/api/graphql/mutations/user_callouts/create_spec.rb +++ b/spec/requests/api/graphql/mutations/user_callouts/create_spec.rb @@ -6,6 +6,7 @@ RSpec.describe 'Create a user callout' do include GraphqlHelpers let_it_be(:current_user) { create(:user) } + let(:feature_name) { ::UserCallout.feature_names.each_key.first } let(:input) do diff --git a/spec/requests/api/graphql/namespace/package_settings_spec.rb b/spec/requests/api/graphql/namespace/package_settings_spec.rb index 6af098e902f..42fd07dbdc7 100644 --- a/spec/requests/api/graphql/namespace/package_settings_spec.rb +++ b/spec/requests/api/graphql/namespace/package_settings_spec.rb @@ -8,6 +8,7 @@ RSpec.describe 'getting namespace package settings in a namespace' do let_it_be(:package_settings) { create(:namespace_package_setting) } let_it_be(:namespace) { package_settings.namespace } let_it_be(:current_user) { namespace.owner } + let(:package_settings_response) { graphql_data.dig('namespace', 'packageSettings') } let(:fields) { all_graphql_fields_for('PackageSettings') } diff --git a/spec/requests/api/graphql/project/alert_management/alert/issue_spec.rb b/spec/requests/api/graphql/project/alert_management/alert/issue_spec.rb index 9724de4fedb..05a98a9dd9c 100644 --- a/spec/requests/api/graphql/project/alert_management/alert/issue_spec.rb +++ b/spec/requests/api/graphql/project/alert_management/alert/issue_spec.rb @@ -7,6 +7,7 @@ RSpec.describe 'getting Alert Management Alert Issue' do let_it_be(:project) { create(:project) } let_it_be(:current_user) { create(:user) } + let(:payload) { {} } let(:query) { 'avg(metric) > 1.0' } diff --git a/spec/requests/api/graphql/project/alert_management/alert_status_counts_spec.rb b/spec/requests/api/graphql/project/alert_management/alert_status_counts_spec.rb index 9fbf5aaa41f..ecd93d169d3 100644 --- a/spec/requests/api/graphql/project/alert_management/alert_status_counts_spec.rb +++ b/spec/requests/api/graphql/project/alert_management/alert_status_counts_spec.rb @@ -9,6 +9,7 @@ RSpec.describe 'getting Alert Management Alert counts by status' do let_it_be(:alert_resolved) { create(:alert_management_alert, :resolved, project: project) } let_it_be(:alert_triggered) { create(:alert_management_alert, project: project) } let_it_be(:other_project_alert) { create(:alert_management_alert) } + let(:params) { {} } let(:fields) do diff --git a/spec/requests/api/graphql/project/error_tracking/sentry_detailed_error_request_spec.rb b/spec/requests/api/graphql/project/error_tracking/sentry_detailed_error_request_spec.rb index b2b42137acf..14fabaaf032 100644 --- a/spec/requests/api/graphql/project/error_tracking/sentry_detailed_error_request_spec.rb +++ b/spec/requests/api/graphql/project/error_tracking/sentry_detailed_error_request_spec.rb @@ -8,6 +8,7 @@ RSpec.describe 'getting a detailed sentry error' do let_it_be(:project_setting) { create(:project_error_tracking_setting, project: project) } let_it_be(:current_user) { project.owner } let_it_be(:sentry_detailed_error) { build(:detailed_error_tracking_error) } + let(:sentry_gid) { sentry_detailed_error.to_global_id.to_s } let(:fields) do <<~QUERY diff --git a/spec/requests/api/graphql/project/error_tracking/sentry_errors_request_spec.rb b/spec/requests/api/graphql/project/error_tracking/sentry_errors_request_spec.rb index c7d327a62af..e71e5a48ddc 100644 --- a/spec/requests/api/graphql/project/error_tracking/sentry_errors_request_spec.rb +++ b/spec/requests/api/graphql/project/error_tracking/sentry_errors_request_spec.rb @@ -17,6 +17,7 @@ RSpec.describe 'sentry errors requests' do describe 'getting a detailed sentry error' do let_it_be(:sentry_detailed_error) { build(:detailed_error_tracking_error) } + let(:sentry_gid) { sentry_detailed_error.to_global_id.to_s } let(:detailed_fields) do @@ -193,6 +194,7 @@ RSpec.describe 'sentry errors requests' do describe 'getting a stack trace' do let_it_be(:sentry_stack_trace) { build(:error_tracking_error_event) } + let(:sentry_gid) { global_id_of(Gitlab::ErrorTracking::DetailedError.new(id: 1)) } let(:stack_trace_fields) do diff --git a/spec/requests/api/graphql/project/issue/designs/designs_spec.rb b/spec/requests/api/graphql/project/issue/designs/designs_spec.rb index decab900a43..def41efddde 100644 --- a/spec/requests/api/graphql/project/issue/designs/designs_spec.rb +++ b/spec/requests/api/graphql/project/issue/designs/designs_spec.rb @@ -8,6 +8,7 @@ RSpec.describe 'Getting designs related to an issue' do let_it_be(:design) { create(:design, :with_smaller_image_versions, versions_count: 1) } let_it_be(:current_user) { design.project.owner } + let(:design_query) do <<~NODE designs { @@ -124,6 +125,7 @@ RSpec.describe 'Getting designs related to an issue' do context 'with versions' do let_it_be(:version) { design.versions.take } + let(:design_query) do <<~NODE designs { @@ -165,6 +167,7 @@ RSpec.describe 'Getting designs related to an issue' do let_it_be(:issue) { design.issue } let_it_be(:second_design, reload: true) { create(:design, :with_smaller_image_versions, issue: issue, versions_count: 1) } let_it_be(:deleted_design) { create(:design, :with_versions, issue: issue, deleted: true, versions_count: 1) } + let(:all_versions) { issue.design_versions.ordered.reverse } let(:design_query) do <<~NODE diff --git a/spec/requests/api/graphql/project/project_pipeline_statistics_spec.rb b/spec/requests/api/graphql/project/project_pipeline_statistics_spec.rb index 7d157563f5f..39a68d98d84 100644 --- a/spec/requests/api/graphql/project/project_pipeline_statistics_spec.rb +++ b/spec/requests/api/graphql/project/project_pipeline_statistics_spec.rb @@ -6,6 +6,7 @@ RSpec.describe 'rendering project pipeline statistics' do include GraphqlHelpers let_it_be(:project) { create(:project) } + let(:user) { create(:user) } let(:fields) do diff --git a/spec/requests/api/graphql/project_query_spec.rb b/spec/requests/api/graphql/project_query_spec.rb index 54375d4de1d..e44a7efb354 100644 --- a/spec/requests/api/graphql/project_query_spec.rb +++ b/spec/requests/api/graphql/project_query_spec.rb @@ -8,6 +8,7 @@ RSpec.describe 'getting project information' do let_it_be(:group) { create(:group) } let_it_be(:project, reload: true) { create(:project, :repository, group: group) } let_it_be(:current_user) { create(:user) } + let(:project_fields) { all_graphql_fields_for('project'.to_s.classify, max_depth: 1) } let(:query) do diff --git a/spec/requests/api/graphql/query_spec.rb b/spec/requests/api/graphql/query_spec.rb index 6bd0703c121..ecc7fffaef7 100644 --- a/spec/requests/api/graphql/query_spec.rb +++ b/spec/requests/api/graphql/query_spec.rb @@ -8,6 +8,7 @@ RSpec.describe 'Query' do let_it_be(:project) { create(:project) } let_it_be(:issue) { create(:issue, project: project) } let_it_be(:developer) { create(:user) } + let(:current_user) { developer } describe '.designManagement' do @@ -15,6 +16,7 @@ RSpec.describe 'Query' do let_it_be(:version) { create(:design_version, issue: issue) } let_it_be(:design) { version.designs.first } + let(:query_result) { graphql_data.dig(*path) } let(:query) { graphql_query_for(:design_management, nil, dm_fields) } diff --git a/spec/requests/api/graphql/user/starred_projects_query_spec.rb b/spec/requests/api/graphql/user/starred_projects_query_spec.rb index 6cb02068f2a..a8c087d1fbf 100644 --- a/spec/requests/api/graphql/user/starred_projects_query_spec.rb +++ b/spec/requests/api/graphql/user/starred_projects_query_spec.rb @@ -60,6 +60,7 @@ RSpec.describe 'Getting starredProjects of the user' do context 'the current user is a member of a private project the user starred' do let_it_be(:other_user) { create(:user) } + let(:current_user) { other_user } before do diff --git a/spec/requests/api/graphql/user_query_spec.rb b/spec/requests/api/graphql/user_query_spec.rb index 60520906e87..59b805bb25b 100644 --- a/spec/requests/api/graphql/user_query_spec.rb +++ b/spec/requests/api/graphql/user_query_spec.rb @@ -402,6 +402,7 @@ RSpec.describe 'getting user information' do context 'we request the groupMemberships' do let_it_be(:membership_a) { create(:group_member, user: user) } + let(:group_memberships) { graphql_data_at(:user, :group_memberships, :nodes) } let(:user_fields) { 'groupMemberships { nodes { id } }' } @@ -424,6 +425,7 @@ RSpec.describe 'getting user information' do context 'we request the projectMemberships' do let_it_be(:membership_a) { create(:project_member, user: user) } + let(:project_memberships) { graphql_data_at(:user, :project_memberships, :nodes) } let(:user_fields) { 'projectMemberships { nodes { id } }' } diff --git a/spec/requests/api/graphql_spec.rb b/spec/requests/api/graphql_spec.rb index a336d74b135..650d525b604 100644 --- a/spec/requests/api/graphql_spec.rb +++ b/spec/requests/api/graphql_spec.rb @@ -175,6 +175,7 @@ RSpec.describe 'GraphQL' do describe 'resolver complexity' do let_it_be(:project) { create(:project, :public) } + let(:query) do graphql_query_for( 'project', @@ -210,6 +211,7 @@ RSpec.describe 'GraphQL' do describe 'complexity limits' do let_it_be(:project) { create(:project, :public) } + let!(:user) { create(:user) } let(:query_fields) do diff --git a/spec/requests/api/group_import_spec.rb b/spec/requests/api/group_import_spec.rb index f632e49bf3a..efad6334518 100644 --- a/spec/requests/api/group_import_spec.rb +++ b/spec/requests/api/group_import_spec.rb @@ -9,6 +9,7 @@ RSpec.describe API::GroupImport do let_it_be(:user) { create(:user) } let_it_be(:group) { create(:group) } + let(:path) { '/groups/import' } let(:file) { File.join('spec', 'fixtures', 'group_export.tar.gz') } let(:export_path) { "#{Dir.tmpdir}/group_export_spec" } diff --git a/spec/requests/api/group_milestones_spec.rb b/spec/requests/api/group_milestones_spec.rb index e3e0164e5a7..2312d35c815 100644 --- a/spec/requests/api/group_milestones_spec.rb +++ b/spec/requests/api/group_milestones_spec.rb @@ -9,6 +9,7 @@ RSpec.describe API::GroupMilestones do let_it_be(:group_member) { create(:group_member, group: group, user: user) } let_it_be(:closed_milestone) { create(:closed_milestone, group: group, title: 'version1', description: 'closed milestone') } let_it_be(:milestone) { create(:milestone, group: group, title: 'version2', description: 'open milestone') } + let(:route) { "/groups/#{group.id}/milestones" } it_behaves_like 'group and project milestones', "/groups/:id/milestones" diff --git a/spec/requests/api/group_packages_spec.rb b/spec/requests/api/group_packages_spec.rb index 792aa2c1f20..a2b0b35c76a 100644 --- a/spec/requests/api/group_packages_spec.rb +++ b/spec/requests/api/group_packages_spec.rb @@ -6,6 +6,7 @@ RSpec.describe API::GroupPackages do let_it_be(:group) { create(:group, :public) } let_it_be(:project) { create(:project, :public, namespace: group, name: 'project A') } let_it_be(:user) { create(:user) } + let(:params) { {} } subject { get api(url), params: params } @@ -17,6 +18,7 @@ RSpec.describe API::GroupPackages do context 'with sorting' do let_it_be(:package1) { create(:npm_package, project: project, version: '3.1.0', name: "@#{project.root_namespace.path}/foo1") } let_it_be(:package2) { create(:nuget_package, project: project, version: '2.0.4') } + let(:package3) { create(:maven_package, project: project, version: '1.1.1', name: 'zzz') } before do diff --git a/spec/requests/api/groups_spec.rb b/spec/requests/api/groups_spec.rb index 8d2ae8cc16d..ad7a2e3b1fb 100644 --- a/spec/requests/api/groups_spec.rb +++ b/spec/requests/api/groups_spec.rb @@ -1432,6 +1432,7 @@ RSpec.describe API::Groups do let_it_be(:sub_child_group1) { create(:group, parent: child_group1) } let_it_be(:child_group2) { create(:group, :private, parent: group2) } let_it_be(:sub_child_group2) { create(:group, :private, parent: child_group2) } + let(:response_groups) { json_response.map { |group| group['name'] } } context 'when unauthenticated' do diff --git a/spec/requests/api/helpers_spec.rb b/spec/requests/api/helpers_spec.rb index ce0018d6d0d..8961f3177b6 100644 --- a/spec/requests/api/helpers_spec.rb +++ b/spec/requests/api/helpers_spec.rb @@ -10,6 +10,7 @@ RSpec.describe API::Helpers do include TermsHelper let_it_be(:user, reload: true) { create(:user) } + let(:admin) { create(:admin) } let(:key) { create(:key, user: user) } diff --git a/spec/requests/api/import_bitbucket_server_spec.rb b/spec/requests/api/import_bitbucket_server_spec.rb index dac139064da..2225f737f36 100644 --- a/spec/requests/api/import_bitbucket_server_spec.rb +++ b/spec/requests/api/import_bitbucket_server_spec.rb @@ -14,6 +14,7 @@ RSpec.describe API::ImportBitbucketServer do describe "POST /import/bitbucket_server" do context 'with no optional parameters' do let_it_be(:project) { create(:project) } + let(:client) { double(BitbucketServer::Client) } before do @@ -48,6 +49,7 @@ RSpec.describe API::ImportBitbucketServer do context 'with a new project name' do let_it_be(:project) { create(:project, name: 'new-name') } + let(:client) { instance_double(BitbucketServer::Client) } before do @@ -83,6 +85,7 @@ RSpec.describe API::ImportBitbucketServer do context 'with an invalid URL' do let_it_be(:project) { create(:project, name: 'new-name') } + let(:client) { instance_double(BitbucketServer::Client) } before do diff --git a/spec/requests/api/internal/base_spec.rb b/spec/requests/api/internal/base_spec.rb index 5f1454f6c5d..49756df61c6 100644 --- a/spec/requests/api/internal/base_spec.rb +++ b/spec/requests/api/internal/base_spec.rb @@ -9,6 +9,7 @@ RSpec.describe API::Internal::Base do let_it_be(:project, reload: true) { create(:project, :repository, :wiki_repo) } let_it_be(:personal_snippet) { create(:personal_snippet, :repository, author: user) } let_it_be(:project_snippet) { create(:project_snippet, :repository, author: user, project: project) } + let(:key) { create(:key, user: user) } let(:secret_token) { Gitlab::Shell.secret_token } let(:gl_repository) { "project-#{project.id}" } diff --git a/spec/requests/api/lint_spec.rb b/spec/requests/api/lint_spec.rb index 57aa0f36192..7fe516d3daa 100644 --- a/spec/requests/api/lint_spec.rb +++ b/spec/requests/api/lint_spec.rb @@ -19,6 +19,7 @@ RSpec.describe API::Lint do context 'when authenticated' do let_it_be(:api_user) { create(:user) } + it 'returns authorized' do post api('/ci/lint', api_user), params: { content: 'content' } @@ -43,6 +44,7 @@ RSpec.describe API::Lint do context 'when authenticated' do let_it_be(:api_user) { create(:user) } + it 'returns authentication success' do post api('/ci/lint', api_user), params: { content: 'content' } diff --git a/spec/requests/api/markdown_spec.rb b/spec/requests/api/markdown_spec.rb index 35d91963ac9..faf671d350f 100644 --- a/spec/requests/api/markdown_spec.rb +++ b/spec/requests/api/markdown_spec.rb @@ -52,6 +52,7 @@ RSpec.describe API::Markdown do context "when arguments are valid" do let_it_be(:project) { create(:project) } let_it_be(:issue) { create(:issue, project: project) } + let(:issue_url) { "http://#{Gitlab.config.gitlab.host}/#{issue.project.namespace.path}/#{issue.project.path}/-/issues/#{issue.iid}" } let(:text) { ":tada: Hello world! :100: #{issue.to_reference}" } diff --git a/spec/requests/api/merge_requests_spec.rb b/spec/requests/api/merge_requests_spec.rb index 691d1133724..a2137ec6ed5 100644 --- a/spec/requests/api/merge_requests_spec.rb +++ b/spec/requests/api/merge_requests_spec.rb @@ -2007,6 +2007,7 @@ RSpec.describe API::MergeRequests do context 'forked projects', :sidekiq_might_not_need_inline do let_it_be(:user2) { create(:user) } + let(:project) { create(:project, :public, :repository) } let!(:forked_project) { fork_project(project, user2, repository: true) } let!(:unrelated_project) { create(:project, namespace: create(:user).namespace, creator_id: user2.id) } @@ -2887,6 +2888,7 @@ RSpec.describe API::MergeRequests do context "forked projects" do let_it_be(:user2) { create(:user) } + let(:project) { create(:project, :public, :repository) } let!(:forked_project) { fork_project(project, user2, repository: true) } let(:merge_request) do diff --git a/spec/requests/api/metrics/dashboard/annotations_spec.rb b/spec/requests/api/metrics/dashboard/annotations_spec.rb index 07de2925ee2..79a38702354 100644 --- a/spec/requests/api/metrics/dashboard/annotations_spec.rb +++ b/spec/requests/api/metrics/dashboard/annotations_spec.rb @@ -6,6 +6,7 @@ RSpec.describe API::Metrics::Dashboard::Annotations do let_it_be(:user) { create(:user) } let_it_be(:project) { create(:project, :private, :repository, namespace: user.namespace) } let_it_be(:environment) { create(:environment, project: project) } + let(:dashboard) { 'config/prometheus/common_metrics.yml' } let(:starting_at) { Time.now.iso8601 } let(:ending_at) { 1.hour.from_now.iso8601 } diff --git a/spec/requests/api/metrics/user_starred_dashboards_spec.rb b/spec/requests/api/metrics/user_starred_dashboards_spec.rb index 533dff05f27..7f019e1226a 100644 --- a/spec/requests/api/metrics/user_starred_dashboards_spec.rb +++ b/spec/requests/api/metrics/user_starred_dashboards_spec.rb @@ -7,6 +7,7 @@ RSpec.describe API::Metrics::UserStarredDashboards do let_it_be(:dashboard_yml) { fixture_file('lib/gitlab/metrics/dashboard/sample_dashboard.yml') } let_it_be(:dashboard) { '.gitlab/dashboards/find&seek.yml' } let_it_be(:project) { create(:project, :private, :repository, :custom_repo, namespace: user.namespace, files: { dashboard => dashboard_yml }) } + let(:url) { "/projects/#{project.id}/metrics/user_starred_dashboards" } let(:params) do { diff --git a/spec/requests/api/nuget_project_packages_spec.rb b/spec/requests/api/nuget_project_packages_spec.rb index a9e695dacbb..f608f296295 100644 --- a/spec/requests/api/nuget_project_packages_spec.rb +++ b/spec/requests/api/nuget_project_packages_spec.rb @@ -162,6 +162,7 @@ RSpec.describe API::NugetProjectPackages do include_context 'workhorse headers' let_it_be(:file_name) { 'package.nupkg' } + let(:url) { "/projects/#{target.id}/packages/nuget" } let(:headers) { {} } let(:params) { { package: temp_file(file_name) } } @@ -197,6 +198,7 @@ RSpec.describe API::NugetProjectPackages do include_context 'workhorse headers' let_it_be(:file_name) { 'package.snupkg' } + let(:url) { "/projects/#{target.id}/packages/nuget/symbolpackage" } let(:headers) { {} } let(:params) { { package: temp_file(file_name) } } diff --git a/spec/requests/api/project_clusters_spec.rb b/spec/requests/api/project_clusters_spec.rb index f784f677c25..253b61e5865 100644 --- a/spec/requests/api/project_clusters_spec.rb +++ b/spec/requests/api/project_clusters_spec.rb @@ -335,6 +335,7 @@ RSpec.describe API::ProjectClusters do let(:namespace) { 'new-namespace' } let(:platform_kubernetes_attributes) { { namespace: namespace } } let_it_be(:management_project) { create(:project, namespace: project.namespace) } + let(:management_project_id) { management_project.id } let(:update_params) do diff --git a/spec/requests/api/project_container_repositories_spec.rb b/spec/requests/api/project_container_repositories_spec.rb index 695d2c3fe2c..1170a9ba6cb 100644 --- a/spec/requests/api/project_container_repositories_spec.rb +++ b/spec/requests/api/project_container_repositories_spec.rb @@ -11,6 +11,7 @@ RSpec.describe API::ProjectContainerRepositories do let_it_be(:developer) { create(:user) } let_it_be(:reporter) { create(:user) } let_it_be(:guest) { create(:user) } + let(:root_repository) { create(:container_repository, :root, project: project) } let(:test_repository) { create(:container_repository, project: project) } let(:root_repository2) { create(:container_repository, :root, project: project2) } diff --git a/spec/requests/api/project_milestones_spec.rb b/spec/requests/api/project_milestones_spec.rb index 71535e66353..606279ec20a 100644 --- a/spec/requests/api/project_milestones_spec.rb +++ b/spec/requests/api/project_milestones_spec.rb @@ -21,6 +21,7 @@ RSpec.describe API::ProjectMilestones do let_it_be(:group) { create(:group, :private, parent: ancestor_group) } let_it_be(:ancestor_group_milestone) { create(:milestone, group: ancestor_group) } let_it_be(:group_milestone) { create(:milestone, group: group) } + let(:params) { { include_parent_milestones: true } } shared_examples 'listing all milestones' do diff --git a/spec/requests/api/pypi_packages_spec.rb b/spec/requests/api/pypi_packages_spec.rb index 86925e6a0ba..e66326db2a2 100644 --- a/spec/requests/api/pypi_packages_spec.rb +++ b/spec/requests/api/pypi_packages_spec.rb @@ -14,6 +14,7 @@ RSpec.describe API::PypiPackages do let_it_be(:deploy_token) { create(:deploy_token, read_package_registry: true, write_package_registry: true) } let_it_be(:project_deploy_token) { create(:project_deploy_token, deploy_token: deploy_token, project: project) } let_it_be(:job) { create(:ci_build, :running, user: user, project: project) } + let(:headers) { {} } context 'simple API endpoint' do @@ -117,6 +118,7 @@ RSpec.describe API::PypiPackages do include_context 'workhorse headers' let_it_be(:file_name) { 'package.whl' } + let(:url) { "/projects/#{project.id}/packages/pypi" } let(:headers) { {} } let(:requires_python) { '>=3.7' } diff --git a/spec/requests/api/rubygem_packages_spec.rb b/spec/requests/api/rubygem_packages_spec.rb index 7d863b55bbe..9b104520b52 100644 --- a/spec/requests/api/rubygem_packages_spec.rb +++ b/spec/requests/api/rubygem_packages_spec.rb @@ -14,6 +14,7 @@ RSpec.describe API::RubygemPackages do let_it_be(:deploy_token) { create(:deploy_token, read_package_registry: true, write_package_registry: true) } let_it_be(:project_deploy_token) { create(:project_deploy_token, deploy_token: deploy_token, project: project) } let_it_be(:headers) { {} } + let(:snowplow_gitlab_standard_context) { { project: project, namespace: project.namespace, user: user } } let(:tokens) do @@ -244,6 +245,7 @@ RSpec.describe API::RubygemPackages do let(:url) { "/projects/#{project.id}/packages/rubygems/api/v1/gems" } let_it_be(:file_name) { 'package.gem' } + let(:headers) { {} } let(:params) { { file: temp_file(file_name) } } let(:file_key) { :file } diff --git a/spec/requests/api/unleash_spec.rb b/spec/requests/api/unleash_spec.rb index 9989f8d28bd..0718710f15c 100644 --- a/spec/requests/api/unleash_spec.rb +++ b/spec/requests/api/unleash_spec.rb @@ -6,6 +6,7 @@ RSpec.describe API::Unleash do include FeatureFlagHelpers let_it_be(:project, refind: true) { create(:project) } + let(:project_id) { project.id } let(:params) { } let(:headers) { } diff --git a/spec/requests/api/users_spec.rb b/spec/requests/api/users_spec.rb index a9231b65c8f..a1bf023c852 100644 --- a/spec/requests/api/users_spec.rb +++ b/spec/requests/api/users_spec.rb @@ -8,6 +8,7 @@ RSpec.describe API::Users do let_it_be(:key) { create(:key, user: user) } let_it_be(:gpg_key) { create(:gpg_key, user: user) } let_it_be(:email) { create(:email, user: user) } + let(:omniauth_user) { create(:omniauth_user) } let(:ldap_blocked_user) { create(:omniauth_user, provider: 'ldapmain', state: 'ldap_blocked') } let(:private_user) { create(:user, private_profile: true) } @@ -2967,6 +2968,7 @@ RSpec.describe API::Users do let_it_be(:user) { create(:user) } let_it_be(:project) { create(:project) } let_it_be(:group) { create(:group) } + let(:requesting_user) { create(:user) } before_all do diff --git a/spec/requests/import/gitlab_groups_controller_spec.rb b/spec/requests/import/gitlab_groups_controller_spec.rb index c65caf2ebf0..1f6487986a3 100644 --- a/spec/requests/import/gitlab_groups_controller_spec.rb +++ b/spec/requests/import/gitlab_groups_controller_spec.rb @@ -8,6 +8,7 @@ RSpec.describe Import::GitlabGroupsController do include_context 'workhorse headers' let_it_be(:user) { create(:user) } + let(:import_path) { "#{Dir.tmpdir}/gitlab_groups_controller_spec" } before do diff --git a/spec/requests/jwt_controller_spec.rb b/spec/requests/jwt_controller_spec.rb index 5b5658da97e..55577a5dc65 100644 --- a/spec/requests/jwt_controller_spec.rb +++ b/spec/requests/jwt_controller_spec.rb @@ -227,6 +227,7 @@ RSpec.describe JwtController do let_it_be(:group_deploy_token) { create(:deploy_token, :group, groups: [group]) } let_it_be(:project_deploy_token) { create(:deploy_token, :project, projects: [project]) } let_it_be(:service_name) { 'dependency_proxy' } + let(:headers) { { authorization: credentials(credential_user, credential_password) } } let(:params) { { account: credential_user, client_id: 'docker', offline_token: true, service: service_name } } diff --git a/spec/requests/lfs_http_spec.rb b/spec/requests/lfs_http_spec.rb index fda8b2ecec6..975026c724e 100644 --- a/spec/requests/lfs_http_spec.rb +++ b/spec/requests/lfs_http_spec.rb @@ -105,6 +105,7 @@ RSpec.describe 'Git LFS API and storage' do context 'when deploy key is authorized' do let_it_be(:key) { create(:deploy_key) } + let(:authorization) { authorize_deploy_key } before do @@ -344,6 +345,7 @@ RSpec.describe 'Git LFS API and storage' do context 'when user password is expired' do let_it_be(:user) { create(:user, password_expires_at: 1.minute.ago)} + let(:role) { :reporter} it_behaves_like 'LFS http 401 response' @@ -351,6 +353,7 @@ RSpec.describe 'Git LFS API and storage' do context 'when user is blocked' do let_it_be(:user) { create(:user, :blocked)} + let(:role) { :reporter} it_behaves_like 'LFS http 401 response' @@ -405,6 +408,7 @@ RSpec.describe 'Git LFS API and storage' do context 'administrator', :enable_admin_mode do let_it_be(:user) { create(:admin) } + let(:build) { create(:ci_build, :running, pipeline: pipeline, user: user) } it_behaves_like 'can download LFS only from own projects', renew_authorization: true @@ -458,6 +462,7 @@ RSpec.describe 'Git LFS API and storage' do describe 'upload' do let_it_be(:project) { create(:project, :public) } + let(:body) { upload_body(sample_object) } shared_examples 'pushes new LFS objects' do |renew_authorization:| @@ -984,6 +989,7 @@ RSpec.describe 'Git LFS API and storage' do describe 'to a forked project' do let_it_be(:upstream_project) { create(:project, :public) } let_it_be(:project_owner) { create(:user) } + let(:project) { fork_project(upstream_project, project_owner) } describe 'when user is authenticated' do diff --git a/spec/requests/product_analytics/collector_app_spec.rb b/spec/requests/product_analytics/collector_app_spec.rb index b87610841e7..0d55d167a6f 100644 --- a/spec/requests/product_analytics/collector_app_spec.rb +++ b/spec/requests/product_analytics/collector_app_spec.rb @@ -4,6 +4,7 @@ require 'spec_helper' RSpec.describe 'ProductAnalytics::CollectorApp' do let_it_be(:project) { create(:project) } + let(:params) { {} } let(:raw_event) { Gitlab::Json.parse(fixture_file('product_analytics/event.json')) } diff --git a/spec/requests/rack_attack_global_spec.rb b/spec/requests/rack_attack_global_spec.rb index f24f815e9c6..f7b1b4726f6 100644 --- a/spec/requests/rack_attack_global_spec.rb +++ b/spec/requests/rack_attack_global_spec.rb @@ -221,6 +221,7 @@ RSpec.describe 'Rack Attack global throttles', :use_clean_rails_memory_store_cac let_it_be(:token) { create(:personal_access_token, user: user) } let_it_be(:other_user) { create(:user) } let_it_be(:other_user_token) { create(:personal_access_token, user: other_user) } + let(:throttle_setting_prefix) { 'throttle_authenticated_api' } let(:api_partial_url) { '/todos' } diff --git a/spec/services/admin/propagate_service_template_spec.rb b/spec/services/admin/propagate_service_template_spec.rb index 1bcf9af78ce..c8ca3173f99 100644 --- a/spec/services/admin/propagate_service_template_spec.rb +++ b/spec/services/admin/propagate_service_template_spec.rb @@ -5,6 +5,7 @@ require 'spec_helper' RSpec.describe Admin::PropagateServiceTemplate do describe '.propagate' do let_it_be(:project) { create(:project) } + let!(:service_template) do Integrations::Pushover.create!( template: true, diff --git a/spec/services/alert_management/create_alert_issue_service_spec.rb b/spec/services/alert_management/create_alert_issue_service_spec.rb index 695e90ebd92..55f8e47717c 100644 --- a/spec/services/alert_management/create_alert_issue_service_spec.rb +++ b/spec/services/alert_management/create_alert_issue_service_spec.rb @@ -15,6 +15,7 @@ RSpec.describe AlertManagement::CreateAlertIssueService do let_it_be(:generic_alert, reload: true) { create(:alert_management_alert, :triggered, project: project, payload: payload) } let_it_be(:prometheus_alert, reload: true) { create(:alert_management_alert, :triggered, :prometheus, project: project, payload: payload) } + let(:alert) { generic_alert } let(:alert_presenter) { alert.present } let(:created_issue) { Issue.last! } diff --git a/spec/services/audit_event_service_spec.rb b/spec/services/audit_event_service_spec.rb index 997f506c269..2654ea1ac22 100644 --- a/spec/services/audit_event_service_spec.rb +++ b/spec/services/audit_event_service_spec.rb @@ -6,6 +6,7 @@ RSpec.describe AuditEventService do let_it_be(:project) { create(:project) } let_it_be(:user) { create(:user, :with_sign_ins) } let_it_be(:project_member) { create(:project_member, user: user) } + let(:service) { described_class.new(user, project, { action: :destroy }) } let(:logger) { instance_double(Gitlab::AuditJsonLogger) } diff --git a/spec/services/auth/dependency_proxy_authentication_service_spec.rb b/spec/services/auth/dependency_proxy_authentication_service_spec.rb index 1fd1677c7da..35e6d59b456 100644 --- a/spec/services/auth/dependency_proxy_authentication_service_spec.rb +++ b/spec/services/auth/dependency_proxy_authentication_service_spec.rb @@ -4,6 +4,7 @@ require 'spec_helper' RSpec.describe Auth::DependencyProxyAuthenticationService do let_it_be(:user) { create(:user) } + let(:service) { Auth::DependencyProxyAuthenticationService.new(nil, user) } before do diff --git a/spec/services/auto_merge_service_spec.rb b/spec/services/auto_merge_service_spec.rb index 3f7a26aa00e..335c608c206 100644 --- a/spec/services/auto_merge_service_spec.rb +++ b/spec/services/auto_merge_service_spec.rb @@ -5,6 +5,7 @@ require 'spec_helper' RSpec.describe AutoMergeService do let_it_be(:project) { create(:project, :repository) } let_it_be(:user) { create(:user) } + let(:service) { described_class.new(project, user) } before_all do diff --git a/spec/services/bulk_create_integration_service_spec.rb b/spec/services/bulk_create_integration_service_spec.rb index ebfd988f26e..4b0029e27cb 100644 --- a/spec/services/bulk_create_integration_service_spec.rb +++ b/spec/services/bulk_create_integration_service_spec.rb @@ -11,6 +11,7 @@ RSpec.describe BulkCreateIntegrationService do let_it_be(:excluded_group) { create(:group) } let_it_be(:excluded_project) { create(:project, group: excluded_group) } + let(:instance_integration) { create(:jira_integration, :instance) } let(:template_integration) { create(:jira_integration, :template) } let(:excluded_attributes) { %w[id project_id group_id inherit_from_id instance template created_at updated_at] } diff --git a/spec/services/clusters/applications/prometheus_health_check_service_spec.rb b/spec/services/clusters/applications/prometheus_health_check_service_spec.rb index ee47d00f700..e6c7b147ab7 100644 --- a/spec/services/clusters/applications/prometheus_health_check_service_spec.rb +++ b/spec/services/clusters/applications/prometheus_health_check_service_spec.rb @@ -42,6 +42,7 @@ RSpec.describe Clusters::Applications::PrometheusHealthCheckService, '#execute' context 'when cluster is project_type' do let_it_be(:project) { create(:project) } let_it_be(:integration) { create(:alert_management_http_integration, project: project) } + let(:applications_prometheus_healthy) { true } let(:prometheus) { create(:clusters_applications_prometheus, status: prometheus_status_value, healthy: applications_prometheus_healthy) } let(:cluster) { create(:cluster, :project, application_prometheus: prometheus, projects: [project]) } diff --git a/spec/services/container_expiration_policy_service_spec.rb b/spec/services/container_expiration_policy_service_spec.rb index 4294e6b3f06..41dd890dd35 100644 --- a/spec/services/container_expiration_policy_service_spec.rb +++ b/spec/services/container_expiration_policy_service_spec.rb @@ -5,6 +5,7 @@ require 'spec_helper' RSpec.describe ContainerExpirationPolicyService do let_it_be(:user) { create(:user) } let_it_be(:container_expiration_policy) { create(:container_expiration_policy, :runnable) } + let(:project) { container_expiration_policy.project } let(:container_repository) { create(:container_repository, project: project) } diff --git a/spec/services/dependency_proxy/find_or_create_manifest_service_spec.rb b/spec/services/dependency_proxy/find_or_create_manifest_service_spec.rb index 40a2f954786..1c8ae860d10 100644 --- a/spec/services/dependency_proxy/find_or_create_manifest_service_spec.rb +++ b/spec/services/dependency_proxy/find_or_create_manifest_service_spec.rb @@ -7,6 +7,7 @@ RSpec.describe DependencyProxy::FindOrCreateManifestService do let_it_be(:image) { 'alpine' } let_it_be(:tag) { 'latest' } let_it_be(:dependency_proxy_manifest) { create(:dependency_proxy_manifest, file_name: "#{image}:#{tag}.json") } + let(:manifest) { dependency_proxy_manifest.file.read } let(:group) { dependency_proxy_manifest.group } let(:token) { Digest::SHA256.hexdigest('123') } diff --git a/spec/services/discussions/resolve_service_spec.rb b/spec/services/discussions/resolve_service_spec.rb index 24de1d90526..9cc27973bcb 100644 --- a/spec/services/discussions/resolve_service_spec.rb +++ b/spec/services/discussions/resolve_service_spec.rb @@ -7,6 +7,7 @@ RSpec.describe Discussions::ResolveService do let_it_be(:project) { create(:project, :repository) } let_it_be(:user) { create(:user, developer_projects: [project]) } let_it_be(:merge_request) { create(:merge_request, :merge_when_pipeline_succeeds, source_project: project) } + let(:discussion) { create(:diff_note_on_merge_request, noteable: merge_request, project: project).to_discussion } let(:service) { described_class.new(project, user, one_or_more_discussions: discussion) } @@ -100,6 +101,7 @@ RSpec.describe Discussions::ResolveService do context 'when discussion is not for a merge request' do let_it_be(:design) { create(:design, :with_file, issue: create(:issue, project: project)) } + let(:discussion) { create(:diff_note_on_design, noteable: design, project: project).to_discussion } it 'does not execute the notification service' do diff --git a/spec/services/discussions/unresolve_service_spec.rb b/spec/services/discussions/unresolve_service_spec.rb index 6298a00a474..0009239232c 100644 --- a/spec/services/discussions/unresolve_service_spec.rb +++ b/spec/services/discussions/unresolve_service_spec.rb @@ -7,6 +7,7 @@ RSpec.describe Discussions::UnresolveService do let_it_be(:project) { create(:project, :repository) } let_it_be(:user) { create(:user, developer_projects: [project]) } let_it_be(:merge_request) { create(:merge_request, :merge_when_pipeline_succeeds, source_project: project) } + let(:discussion) { create(:diff_note_on_merge_request, noteable: merge_request, project: project).to_discussion } let(:service) { described_class.new(discussion, user) } diff --git a/spec/services/git/branch_push_service_spec.rb b/spec/services/git/branch_push_service_spec.rb index d52e3a0b6fa..53f5dd8b647 100644 --- a/spec/services/git/branch_push_service_spec.rb +++ b/spec/services/git/branch_push_service_spec.rb @@ -7,6 +7,7 @@ RSpec.describe Git::BranchPushService, services: true do let_it_be(:user) { create(:user) } let_it_be(:project, reload: true) { create(:project, :repository) } + let(:blankrev) { Gitlab::Git::BLANK_SHA } let(:oldrev) { sample_commit.parent_id } let(:newrev) { sample_commit.id } @@ -707,6 +708,7 @@ RSpec.describe Git::BranchPushService, services: true do context 'Jira Connect hooks' do let_it_be(:project) { create(:project, :repository) } + let(:branch_to_sync) { nil } let(:commits_to_sync) { [] } let(:params) do diff --git a/spec/services/import/bitbucket_server_service_spec.rb b/spec/services/import/bitbucket_server_service_spec.rb index c548e87b040..56d93625b91 100644 --- a/spec/services/import/bitbucket_server_service_spec.rb +++ b/spec/services/import/bitbucket_server_service_spec.rb @@ -4,6 +4,7 @@ require 'spec_helper' RSpec.describe Import::BitbucketServerService do let_it_be(:user) { create(:user) } + let(:base_uri) { "https://test:7990" } let(:token) { "asdasd12345" } let(:secret) { "sekrettt" } diff --git a/spec/services/incident_management/incidents/create_service_spec.rb b/spec/services/incident_management/incidents/create_service_spec.rb index 4601bd807d0..0f32a4b5425 100644 --- a/spec/services/incident_management/incidents/create_service_spec.rb +++ b/spec/services/incident_management/incidents/create_service_spec.rb @@ -5,6 +5,7 @@ require 'spec_helper' RSpec.describe IncidentManagement::Incidents::CreateService do let_it_be(:project) { create(:project) } let_it_be(:user) { User.alert_bot } + let(:description) { 'Incident description' } describe '#execute' do diff --git a/spec/services/incident_management/pager_duty/create_incident_issue_service_spec.rb b/spec/services/incident_management/pager_duty/create_incident_issue_service_spec.rb index 73ad0532e07..fb536df5d17 100644 --- a/spec/services/incident_management/pager_duty/create_incident_issue_service_spec.rb +++ b/spec/services/incident_management/pager_duty/create_incident_issue_service_spec.rb @@ -5,6 +5,7 @@ require 'spec_helper' RSpec.describe IncidentManagement::PagerDuty::CreateIncidentIssueService do let_it_be(:project, reload: true) { create(:project) } let_it_be(:user) { User.alert_bot } + let(:webhook_payload) { Gitlab::Json.parse(fixture_file('pager_duty/webhook_incident_trigger.json')) } let(:parsed_payload) { ::PagerDuty::WebhookPayloadParser.call(webhook_payload) } let(:incident_payload) { parsed_payload.first['incident'] } diff --git a/spec/services/incident_management/pager_duty/process_webhook_service_spec.rb b/spec/services/incident_management/pager_duty/process_webhook_service_spec.rb index 0caffb16f42..8b6eb21c25d 100644 --- a/spec/services/incident_management/pager_duty/process_webhook_service_spec.rb +++ b/spec/services/incident_management/pager_duty/process_webhook_service_spec.rb @@ -95,6 +95,7 @@ RSpec.describe IncidentManagement::PagerDuty::ProcessWebhookService do context 'when both tokens are nil' do let_it_be(:incident_management_setting) { create(:project_incident_management_setting, project: project, pagerduty_active: false) } + let(:token) { nil } before do diff --git a/spec/services/integrations/test/project_service_spec.rb b/spec/services/integrations/test/project_service_spec.rb index 2e09dea11f1..32f9f632d7a 100644 --- a/spec/services/integrations/test/project_service_spec.rb +++ b/spec/services/integrations/test/project_service_spec.rb @@ -132,6 +132,7 @@ RSpec.describe Integrations::Test::ProjectService do context 'deployment' do let_it_be(:project) { create(:project, :test_repo) } + let(:deployment) { build(:deployment) } let(:event) { 'deployment' } @@ -169,6 +170,7 @@ RSpec.describe Integrations::Test::ProjectService do context 'wiki_page' do let_it_be(:project) { create(:project, :wiki_repo) } + let(:event) { 'wiki_page' } it 'returns error message if wiki disabled' do diff --git a/spec/services/issuable/bulk_update_service_spec.rb b/spec/services/issuable/bulk_update_service_spec.rb index dfdfb57111c..55e0e799c19 100644 --- a/spec/services/issuable/bulk_update_service_spec.rb +++ b/spec/services/issuable/bulk_update_service_spec.rb @@ -314,6 +314,7 @@ RSpec.describe Issuable::BulkUpdateService do context 'with issuables at a group level' do let_it_be(:group) { create(:group) } + let(:parent) { group } before do diff --git a/spec/services/jira_connect/sync_service_spec.rb b/spec/services/jira_connect/sync_service_spec.rb index edd0bad70f5..c20aecaaef0 100644 --- a/spec/services/jira_connect/sync_service_spec.rb +++ b/spec/services/jira_connect/sync_service_spec.rb @@ -7,6 +7,7 @@ RSpec.describe JiraConnect::SyncService do describe '#execute' do let_it_be(:project) { create(:project, :repository) } + let(:client) { Atlassian::JiraConnect::Client } let(:info) { { a: 'Some', b: 'Info' } } diff --git a/spec/services/jira_import/start_import_service_spec.rb b/spec/services/jira_import/start_import_service_spec.rb index 36d639cd724..e04e3314158 100644 --- a/spec/services/jira_import/start_import_service_spec.rb +++ b/spec/services/jira_import/start_import_service_spec.rb @@ -7,6 +7,7 @@ RSpec.describe JiraImport::StartImportService do let_it_be(:user) { create(:user) } let_it_be(:project, reload: true) { create(:project) } + let(:key) { 'KEY' } let(:mapping) do [ diff --git a/spec/services/markdown_content_rewriter_service_spec.rb b/spec/services/markdown_content_rewriter_service_spec.rb index 47332bec319..37c8a210ba5 100644 --- a/spec/services/markdown_content_rewriter_service_spec.rb +++ b/spec/services/markdown_content_rewriter_service_spec.rb @@ -6,6 +6,7 @@ RSpec.describe MarkdownContentRewriterService do let_it_be(:user) { create(:user) } let_it_be(:source_parent) { create(:project, :public) } let_it_be(:target_parent) { create(:project, :public) } + let(:content) { 'My content' } describe '#initialize' do @@ -34,6 +35,7 @@ RSpec.describe MarkdownContentRewriterService do # to prove they run correctly. context 'when content contains a reference' do let_it_be(:issue) { create(:issue, project: source_parent) } + let(:content) { "See ##{issue.iid}" } it 'rewrites content' do diff --git a/spec/services/members/create_service_spec.rb b/spec/services/members/create_service_spec.rb index ffe63a8a94b..62bccde1963 100644 --- a/spec/services/members/create_service_spec.rb +++ b/spec/services/members/create_service_spec.rb @@ -8,6 +8,7 @@ RSpec.describe Members::CreateService, :aggregate_failures, :clean_gitlab_redis_ let_it_be(:member) { create(:user) } let_it_be(:user_ids) { member.id.to_s } let_it_be(:access_level) { Gitlab::Access::GUEST } + let(:additional_params) { { invite_source: '_invite_source_' } } let(:params) { { user_ids: user_ids, access_level: access_level }.merge(additional_params) } diff --git a/spec/services/members/invite_service_spec.rb b/spec/services/members/invite_service_spec.rb index c530e3d0c53..dd82facaf14 100644 --- a/spec/services/members/invite_service_spec.rb +++ b/spec/services/members/invite_service_spec.rb @@ -7,6 +7,7 @@ RSpec.describe Members::InviteService, :aggregate_failures, :clean_gitlab_redis_ let_it_be(:user) { project.owner } let_it_be(:project_user) { create(:user) } let_it_be(:namespace) { project.namespace } + let(:params) { {} } let(:base_params) { { access_level: Gitlab::Access::GUEST, source: project, invite_source: '_invite_source_' } } diff --git a/spec/services/metrics/dashboard/annotations/create_service_spec.rb b/spec/services/metrics/dashboard/annotations/create_service_spec.rb index c3fe7238047..8f5484fcabe 100644 --- a/spec/services/metrics/dashboard/annotations/create_service_spec.rb +++ b/spec/services/metrics/dashboard/annotations/create_service_spec.rb @@ -4,6 +4,7 @@ require 'spec_helper' RSpec.describe Metrics::Dashboard::Annotations::CreateService do let_it_be(:user) { create(:user) } + let(:description) { 'test annotation' } let(:dashboard_path) { 'config/prometheus/common_metrics.yml' } let(:starting_at) { 15.minutes.ago } diff --git a/spec/services/metrics/dashboard/gitlab_alert_embed_service_spec.rb b/spec/services/metrics/dashboard/gitlab_alert_embed_service_spec.rb index d5928b1b5af..2905e4599f3 100644 --- a/spec/services/metrics/dashboard/gitlab_alert_embed_service_spec.rb +++ b/spec/services/metrics/dashboard/gitlab_alert_embed_service_spec.rb @@ -8,6 +8,7 @@ RSpec.describe Metrics::Dashboard::GitlabAlertEmbedService do let_it_be(:alert) { create(:prometheus_alert) } let_it_be(:project) { alert.project } let_it_be(:user) { create(:user) } + let(:alert_id) { alert.id } before_all do diff --git a/spec/services/metrics/users_starred_dashboards/create_service_spec.rb b/spec/services/metrics/users_starred_dashboards/create_service_spec.rb index 910b556b8dd..1435e39e458 100644 --- a/spec/services/metrics/users_starred_dashboards/create_service_spec.rb +++ b/spec/services/metrics/users_starred_dashboards/create_service_spec.rb @@ -4,6 +4,7 @@ require 'spec_helper' RSpec.describe Metrics::UsersStarredDashboards::CreateService do let_it_be(:user) { create(:user) } + let(:dashboard_path) { 'config/prometheus/common_metrics.yml' } let(:service_instance) { described_class.new(user, project, dashboard_path) } let(:project) { create(:project) } diff --git a/spec/services/notes/copy_service_spec.rb b/spec/services/notes/copy_service_spec.rb index d9b6bafd7ff..dd11fa15ea8 100644 --- a/spec/services/notes/copy_service_spec.rb +++ b/spec/services/notes/copy_service_spec.rb @@ -16,6 +16,7 @@ RSpec.describe Notes::CopyService do let_it_be(:group) { create(:group) } let_it_be(:from_project) { create(:project, :public, group: group) } let_it_be(:to_project) { create(:project, :public, group: group) } + let(:from_noteable) { create(:issue, project: from_project) } let(:to_noteable) { create(:issue, project: to_project) } diff --git a/spec/services/notes/create_service_spec.rb b/spec/services/notes/create_service_spec.rb index 5b4d6188b66..6621ad1f294 100644 --- a/spec/services/notes/create_service_spec.rb +++ b/spec/services/notes/create_service_spec.rb @@ -6,6 +6,7 @@ RSpec.describe Notes::CreateService do let_it_be(:project) { create(:project, :repository) } let_it_be(:issue) { create(:issue, project: project) } let_it_be(:user) { create(:user) } + let(:opts) do { note: 'Awesome comment', noteable_type: 'Issue', noteable_id: issue.id, confidential: true } end @@ -295,6 +296,7 @@ RSpec.describe Notes::CreateService do context 'for merge requests' do let_it_be(:merge_request) { create(:merge_request, source_project: project, labels: [bug_label]) } + let(:issuable) { merge_request } let(:note_params) { opts.merge(noteable_type: 'MergeRequest', noteable_id: merge_request.id) } let(:merge_request_quick_actions) do diff --git a/spec/services/notes/destroy_service_spec.rb b/spec/services/notes/destroy_service_spec.rb index eebbdcc33b8..55acdabef82 100644 --- a/spec/services/notes/destroy_service_spec.rb +++ b/spec/services/notes/destroy_service_spec.rb @@ -5,6 +5,7 @@ require 'spec_helper' RSpec.describe Notes::DestroyService do let_it_be(:project) { create(:project, :public) } let_it_be(:issue) { create(:issue, project: project) } + let(:user) { issue.author } describe '#execute' do diff --git a/spec/services/notes/quick_actions_service_spec.rb b/spec/services/notes/quick_actions_service_spec.rb index cb7d0163cac..0a56f01ebba 100644 --- a/spec/services/notes/quick_actions_service_spec.rb +++ b/spec/services/notes/quick_actions_service_spec.rb @@ -43,6 +43,7 @@ RSpec.describe Notes::QuickActionsService do context '/relate' do let_it_be(:issue) { create(:issue, project: project) } let_it_be(:other_issue) { create(:issue, project: project) } + let(:note_text) { "/relate #{other_issue.to_reference}" } let(:note) { create(:note_on_issue, noteable: issue, project: project, note: note_text) } diff --git a/spec/services/notes/update_service_spec.rb b/spec/services/notes/update_service_spec.rb index 000f3d26efa..71ac1641ca5 100644 --- a/spec/services/notes/update_service_spec.rb +++ b/spec/services/notes/update_service_spec.rb @@ -273,6 +273,7 @@ RSpec.describe Notes::UpdateService do context 'for a personal snippet' do let_it_be(:snippet) { create(:personal_snippet, :public) } + let(:note) { create(:note, project: nil, noteable: snippet, author: user, note: "Note on a snippet with reference #{issue.to_reference}" ) } it 'does not create todos' do diff --git a/spec/services/notification_service_spec.rb b/spec/services/notification_service_spec.rb index 63ef007350d..6b1291042dd 100644 --- a/spec/services/notification_service_spec.rb +++ b/spec/services/notification_service_spec.rb @@ -361,6 +361,7 @@ RSpec.describe NotificationService, :mailer do let_it_be_with_reload(:issue) { create(:issue, project: project, assignees: [assignee]) } let_it_be(:mentioned_issue) { create(:issue, assignees: issue.assignees) } let_it_be_with_reload(:author) { create(:user) } + let(:note) { create(:note_on_issue, author: author, noteable: issue, project_id: issue.project_id, note: '@mention referenced, @unsubscribed_mentioned and @outsider also') } subject { notification.new_note(note) } @@ -641,6 +642,7 @@ RSpec.describe NotificationService, :mailer do let_it_be(:issue) { create(:issue, project: project, assignees: [assignee]) } let_it_be(:mentioned_issue) { create(:issue, assignees: issue.assignees) } let_it_be(:author) { create(:user) } + let(:note) { create(:note_on_issue, author: author, noteable: issue, project_id: issue.project_id, note: '@all mentioned') } before_all do diff --git a/spec/services/packages/composer/create_package_service_spec.rb b/spec/services/packages/composer/create_package_service_spec.rb index 526c7b4929b..553d58fdd86 100644 --- a/spec/services/packages/composer/create_package_service_spec.rb +++ b/spec/services/packages/composer/create_package_service_spec.rb @@ -8,6 +8,7 @@ RSpec.describe Packages::Composer::CreatePackageService do let_it_be(:json) { { name: package_name }.to_json } let_it_be(:project) { create(:project, :custom_repo, files: { 'composer.json' => json } ) } let_it_be(:user) { create(:user) } + let(:params) do { branch: branch, diff --git a/spec/services/packages/conan/search_service_spec.rb b/spec/services/packages/conan/search_service_spec.rb index 39d284ee088..55dcdfe646d 100644 --- a/spec/services/packages/conan/search_service_spec.rb +++ b/spec/services/packages/conan/search_service_spec.rb @@ -5,6 +5,7 @@ require 'spec_helper' RSpec.describe Packages::Conan::SearchService do let_it_be(:user) { create(:user) } let_it_be(:project) { create(:project, :public) } + let!(:conan_package) { create(:conan_package, project: project) } let!(:conan_package2) { create(:conan_package, project: project) } diff --git a/spec/services/packages/create_package_file_service_spec.rb b/spec/services/packages/create_package_file_service_spec.rb index e4b4b15ebf9..2ff00ea8568 100644 --- a/spec/services/packages/create_package_file_service_spec.rb +++ b/spec/services/packages/create_package_file_service_spec.rb @@ -4,6 +4,7 @@ require 'spec_helper' RSpec.describe Packages::CreatePackageFileService do let_it_be(:package) { create(:maven_package) } let_it_be(:user) { create(:user) } + let(:service) { described_class.new(package, params) } describe '#execute' do diff --git a/spec/services/packages/debian/find_or_create_package_service_spec.rb b/spec/services/packages/debian/find_or_create_package_service_spec.rb index 3582b1f1dc3..f06f86b0146 100644 --- a/spec/services/packages/debian/find_or_create_package_service_spec.rb +++ b/spec/services/packages/debian/find_or_create_package_service_spec.rb @@ -6,6 +6,7 @@ RSpec.describe Packages::Debian::FindOrCreatePackageService do let_it_be(:distribution) { create(:debian_project_distribution) } let_it_be(:project) { distribution.project } let_it_be(:user) { create(:user) } + let(:params) { { name: 'foo', version: '1.0+debian', distribution_name: distribution.codename } } subject(:service) { described_class.new(project, user, params) } diff --git a/spec/services/packages/maven/find_or_create_package_service_spec.rb b/spec/services/packages/maven/find_or_create_package_service_spec.rb index 803371af4bf..d8b48af0121 100644 --- a/spec/services/packages/maven/find_or_create_package_service_spec.rb +++ b/spec/services/packages/maven/find_or_create_package_service_spec.rb @@ -91,6 +91,7 @@ RSpec.describe Packages::Maven::FindOrCreatePackageService do context 'with a build' do let_it_be(:pipeline) { create(:ci_pipeline, user: user) } + let(:build) { double('build', pipeline: pipeline) } let(:params) { { path: param_path, file_name: file_name, build: build } } @@ -103,6 +104,7 @@ RSpec.describe Packages::Maven::FindOrCreatePackageService do let_it_be_with_refind(:package_settings) { create(:namespace_package_setting, :group, maven_duplicates_allowed: false) } let_it_be_with_refind(:group) { package_settings.namespace } let_it_be_with_refind(:project) { create(:project, group: group) } + let!(:existing_package) { create(:maven_package, name: path, version: version, project: project) } it { expect { subject }.not_to change { project.package_files.count } } diff --git a/spec/services/packages/nuget/search_service_spec.rb b/spec/services/packages/nuget/search_service_spec.rb index 1838065c5be..66c91487a8f 100644 --- a/spec/services/packages/nuget/search_service_spec.rb +++ b/spec/services/packages/nuget/search_service_spec.rb @@ -13,6 +13,7 @@ RSpec.describe Packages::Nuget::SearchService do let_it_be(:package_d) { create(:nuget_package, project: project, name: 'FooBarD') } let_it_be(:other_package_a) { create(:nuget_package, name: 'DummyPackageA') } let_it_be(:other_package_a) { create(:nuget_package, name: 'DummyPackageB') } + let(:search_term) { 'ummy' } let(:per_page) { 5 } let(:padding) { 0 } diff --git a/spec/services/packages/rubygems/dependency_resolver_service_spec.rb b/spec/services/packages/rubygems/dependency_resolver_service_spec.rb index 78abfc96ed5..f23ed0e5fbc 100644 --- a/spec/services/packages/rubygems/dependency_resolver_service_spec.rb +++ b/spec/services/packages/rubygems/dependency_resolver_service_spec.rb @@ -5,6 +5,7 @@ RSpec.describe Packages::Rubygems::DependencyResolverService do let_it_be(:project) { create(:project, :private) } let_it_be(:package) { create(:package, project: project) } let_it_be(:user) { create(:user) } + let(:gem_name) { package.name } let(:service) { described_class.new(project, user, gem_name: gem_name) } diff --git a/spec/services/pod_logs/base_service_spec.rb b/spec/services/pod_logs/base_service_spec.rb index 6f7731fda3a..d2f6300ab65 100644 --- a/spec/services/pod_logs/base_service_spec.rb +++ b/spec/services/pod_logs/base_service_spec.rb @@ -6,6 +6,7 @@ RSpec.describe ::PodLogs::BaseService do include KubernetesHelpers let_it_be(:cluster) { create(:cluster, :provided_by_gcp, environment_scope: '*') } + let(:namespace) { 'autodevops-deploy-9-production' } let(:pod_name) { 'pod-1' } diff --git a/spec/services/pod_logs/elasticsearch_service_spec.rb b/spec/services/pod_logs/elasticsearch_service_spec.rb index 598b162aee4..1111d9b9307 100644 --- a/spec/services/pod_logs/elasticsearch_service_spec.rb +++ b/spec/services/pod_logs/elasticsearch_service_spec.rb @@ -4,6 +4,7 @@ require 'spec_helper' RSpec.describe ::PodLogs::ElasticsearchService do let_it_be(:cluster) { create(:cluster, :provided_by_gcp, environment_scope: '*') } + let(:namespace) { 'autodevops-deploy-9-production' } let(:pod_name) { 'pod-1' } diff --git a/spec/services/pod_logs/kubernetes_service_spec.rb b/spec/services/pod_logs/kubernetes_service_spec.rb index 3e31ff15c1b..c06a87830ca 100644 --- a/spec/services/pod_logs/kubernetes_service_spec.rb +++ b/spec/services/pod_logs/kubernetes_service_spec.rb @@ -6,6 +6,7 @@ RSpec.describe ::PodLogs::KubernetesService do include KubernetesHelpers let_it_be(:cluster) { create(:cluster, :provided_by_gcp, environment_scope: '*') } + let(:namespace) { 'autodevops-deploy-9-production' } let(:pod_name) { 'pod-1' } diff --git a/spec/services/projects/create_service_spec.rb b/spec/services/projects/create_service_spec.rb index 5dc0c46a98f..e99ac8bb3d9 100644 --- a/spec/services/projects/create_service_spec.rb +++ b/spec/services/projects/create_service_spec.rb @@ -190,6 +190,7 @@ RSpec.describe Projects::CreateService, '#execute' do let_it_be(:group) { create(:group) } let_it_be(:shared_group) { create(:group) } let_it_be(:shared_group_user) { create(:user) } + let(:opts) do { name: 'GitLab', @@ -221,6 +222,7 @@ RSpec.describe Projects::CreateService, '#execute' do let_it_be(:subgroup_for_projects) { create(:group, :private, parent: group) } let_it_be(:subgroup_for_access) { create(:group, :private, parent: group) } let_it_be(:group_maintainer) { create(:user) } + let(:group_access_level) { Gitlab::Access::REPORTER } let(:subgroup_access_level) { Gitlab::Access::DEVELOPER } let(:share_max_access_level) { Gitlab::Access::MAINTAINER } diff --git a/spec/services/projects/destroy_rollback_service_spec.rb b/spec/services/projects/destroy_rollback_service_spec.rb index f63939337b8..3eaacc8c1e7 100644 --- a/spec/services/projects/destroy_rollback_service_spec.rb +++ b/spec/services/projects/destroy_rollback_service_spec.rb @@ -5,6 +5,7 @@ require 'spec_helper' RSpec.describe Projects::DestroyRollbackService do let_it_be(:user) { create(:user) } let_it_be(:project) { create(:project, :repository, namespace: user.namespace) } + let(:repository) { project.repository } let(:repository_storage) { project.repository_storage } diff --git a/spec/services/projects/destroy_service_spec.rb b/spec/services/projects/destroy_service_spec.rb index c6b2b1e2b21..4a76347ea45 100644 --- a/spec/services/projects/destroy_service_spec.rb +++ b/spec/services/projects/destroy_service_spec.rb @@ -6,6 +6,7 @@ RSpec.describe Projects::DestroyService, :aggregate_failures do include ProjectForksHelper let_it_be(:user) { create(:user) } + let!(:project) { create(:project, :repository, namespace: user.namespace) } let(:path) { project.repository.disk_path } let(:remove_path) { removal_path(path) } diff --git a/spec/services/projects/gitlab_projects_import_service_spec.rb b/spec/services/projects/gitlab_projects_import_service_spec.rb index 09d093a9916..d32e720a49f 100644 --- a/spec/services/projects/gitlab_projects_import_service_spec.rb +++ b/spec/services/projects/gitlab_projects_import_service_spec.rb @@ -4,6 +4,7 @@ require 'spec_helper' RSpec.describe Projects::GitlabProjectsImportService do let_it_be(:namespace) { create(:namespace) } + let(:path) { 'test-path' } let(:file) { fixture_file_upload('spec/fixtures/project_export.tar.gz') } let(:overwrite) { false } diff --git a/spec/services/projects/group_links/create_service_spec.rb b/spec/services/projects/group_links/create_service_spec.rb index 9bc780fe177..65b0037d667 100644 --- a/spec/services/projects/group_links/create_service_spec.rb +++ b/spec/services/projects/group_links/create_service_spec.rb @@ -6,6 +6,7 @@ RSpec.describe Projects::GroupLinks::CreateService, '#execute' do let_it_be(:user) { create :user } let_it_be(:group) { create :group } let_it_be(:project) { create :project } + let(:group_access) { Gitlab::Access::DEVELOPER } let(:opts) do { diff --git a/spec/services/projects/group_links/destroy_service_spec.rb b/spec/services/projects/group_links/destroy_service_spec.rb index d60e9a01e54..d65afb68bfe 100644 --- a/spec/services/projects/group_links/destroy_service_spec.rb +++ b/spec/services/projects/group_links/destroy_service_spec.rb @@ -6,6 +6,7 @@ RSpec.describe Projects::GroupLinks::DestroyService, '#execute' do let_it_be(:user) { create :user } let_it_be(:project) { create(:project, :private) } let_it_be(:group) { create(:group) } + let!(:group_link) { create(:project_group_link, project: project, group: group) } subject { described_class.new(project, user) } diff --git a/spec/services/projects/group_links/update_service_spec.rb b/spec/services/projects/group_links/update_service_spec.rb index 467aef3bc7e..4a38fb0c7d9 100644 --- a/spec/services/projects/group_links/update_service_spec.rb +++ b/spec/services/projects/group_links/update_service_spec.rb @@ -6,6 +6,7 @@ RSpec.describe Projects::GroupLinks::UpdateService, '#execute' do let_it_be(:user) { create :user } let_it_be(:group) { create :group } let_it_be(:project) { create :project } + let!(:link) { create(:project_group_link, project: project, group: group) } let(:expiry_date) { 1.month.from_now.to_date } diff --git a/spec/services/projects/transfer_service_spec.rb b/spec/services/projects/transfer_service_spec.rb index 8d4a70dbe89..b71677a5e8f 100644 --- a/spec/services/projects/transfer_service_spec.rb +++ b/spec/services/projects/transfer_service_spec.rb @@ -8,6 +8,7 @@ RSpec.describe Projects::TransferService do let_it_be(:user) { create(:user) } let_it_be(:group) { create(:group) } let_it_be(:group_integration) { create(:integrations_slack, group: group, project: nil, webhook: 'http://group.slack.com') } + let(:project) { create(:project, :repository, :legacy_storage, namespace: user.namespace) } subject(:execute_transfer) { described_class.new(project, user).execute(group).tap { project.reload } } diff --git a/spec/services/projects/update_pages_service_spec.rb b/spec/services/projects/update_pages_service_spec.rb index b11607bc213..5898504b463 100644 --- a/spec/services/projects/update_pages_service_spec.rb +++ b/spec/services/projects/update_pages_service_spec.rb @@ -5,6 +5,7 @@ require "spec_helper" RSpec.describe Projects::UpdatePagesService do let_it_be(:project, refind: true) { create(:project, :repository) } let_it_be(:pipeline) { create(:ci_pipeline, project: project, sha: project.commit('HEAD').sha) } + let(:build) { create(:ci_build, pipeline: pipeline, ref: 'HEAD') } let(:invalid_file) { fixture_file_upload('spec/fixtures/dk.png') } diff --git a/spec/services/prometheus/create_default_alerts_service_spec.rb b/spec/services/prometheus/create_default_alerts_service_spec.rb index e149161d881..0880799b589 100644 --- a/spec/services/prometheus/create_default_alerts_service_spec.rb +++ b/spec/services/prometheus/create_default_alerts_service_spec.rb @@ -4,6 +4,7 @@ require 'spec_helper' RSpec.describe Prometheus::CreateDefaultAlertsService do let_it_be(:project) { create(:project, :repository) } + let(:instance) { described_class.new(project: project) } let(:expected_alerts) { described_class::DEFAULT_ALERTS } diff --git a/spec/services/quick_actions/interpret_service_spec.rb b/spec/services/quick_actions/interpret_service_spec.rb index 4af76bc65ab..d7f5c39e457 100644 --- a/spec/services/quick_actions/interpret_service_spec.rb +++ b/spec/services/quick_actions/interpret_service_spec.rb @@ -15,6 +15,7 @@ RSpec.describe QuickActions::InterpretService do let_it_be(:inprogress) { create(:label, project: project, title: 'In Progress') } let_it_be(:helmchart) { create(:label, project: project, title: 'Helm Chart Registry') } let_it_be(:bug) { create(:label, project: project, title: 'Bug') } + let(:service) { described_class.new(project, developer) } before_all do diff --git a/spec/services/releases/create_evidence_service_spec.rb b/spec/services/releases/create_evidence_service_spec.rb index 818d20f0468..0ac15a7291d 100644 --- a/spec/services/releases/create_evidence_service_spec.rb +++ b/spec/services/releases/create_evidence_service_spec.rb @@ -4,6 +4,7 @@ require 'spec_helper' RSpec.describe Releases::CreateEvidenceService do let_it_be(:project) { create(:project) } + let(:release) { create(:release, project: project) } let(:service) { described_class.new(release) } diff --git a/spec/services/repositories/destroy_rollback_service_spec.rb b/spec/services/repositories/destroy_rollback_service_spec.rb index 9cc41a4c7f8..717e52f0e40 100644 --- a/spec/services/repositories/destroy_rollback_service_spec.rb +++ b/spec/services/repositories/destroy_rollback_service_spec.rb @@ -4,6 +4,7 @@ require 'spec_helper' RSpec.describe Repositories::DestroyRollbackService do let_it_be(:user) { create(:user) } + let!(:project) { create(:project, :repository, namespace: user.namespace) } let(:repository) { project.repository } let(:path) { repository.disk_path } diff --git a/spec/services/repositories/destroy_service_spec.rb b/spec/services/repositories/destroy_service_spec.rb index 81bda2130a6..240f837e973 100644 --- a/spec/services/repositories/destroy_service_spec.rb +++ b/spec/services/repositories/destroy_service_spec.rb @@ -4,6 +4,7 @@ require 'spec_helper' RSpec.describe Repositories::DestroyService do let_it_be(:user) { create(:user) } + let!(:project) { create(:project, :repository, namespace: user.namespace) } let(:repository) { project.repository } let(:path) { repository.disk_path } diff --git a/spec/services/repositories/shell_destroy_service_spec.rb b/spec/services/repositories/shell_destroy_service_spec.rb index 9020ef7b209..65168a1784a 100644 --- a/spec/services/repositories/shell_destroy_service_spec.rb +++ b/spec/services/repositories/shell_destroy_service_spec.rb @@ -4,6 +4,7 @@ require 'spec_helper' RSpec.describe Repositories::ShellDestroyService do let_it_be(:user) { create(:user) } + let!(:project) { create(:project, :repository, namespace: user.namespace) } let(:path) { project.repository.disk_path } let(:remove_path) { "#{path}+#{project.id}#{described_class::DELETED_FLAG}" } diff --git a/spec/services/resource_access_tokens/create_service_spec.rb b/spec/services/resource_access_tokens/create_service_spec.rb index 517ed086713..bd7c44c6e03 100644 --- a/spec/services/resource_access_tokens/create_service_spec.rb +++ b/spec/services/resource_access_tokens/create_service_spec.rb @@ -176,6 +176,7 @@ RSpec.describe ResourceAccessTokens::CreateService do context "when access provisioning fails" do let_it_be(:bot_user) { create(:user, :project_bot) } + let(:unpersisted_member) { build(:project_member, source: resource, user: bot_user) } before do diff --git a/spec/services/resource_access_tokens/revoke_service_spec.rb b/spec/services/resource_access_tokens/revoke_service_spec.rb index 99adb4bb7a0..4f4e2ab0c99 100644 --- a/spec/services/resource_access_tokens/revoke_service_spec.rb +++ b/spec/services/resource_access_tokens/revoke_service_spec.rb @@ -6,6 +6,7 @@ RSpec.describe ResourceAccessTokens::RevokeService do subject { described_class.new(user, resource, access_token).execute } let_it_be(:user) { create(:user) } + let(:access_token) { create(:personal_access_token, user: resource_bot) } describe '#execute', :sidekiq_inline do @@ -80,6 +81,7 @@ RSpec.describe ResourceAccessTokens::RevokeService do context 'when resource is a project' do let_it_be(:resource) { create(:project, :private) } + let(:resource_bot) { create(:user, :project_bot) } before do diff --git a/spec/services/resource_events/change_labels_service_spec.rb b/spec/services/resource_events/change_labels_service_spec.rb index 8eac6ae0b49..012168ef719 100644 --- a/spec/services/resource_events/change_labels_service_spec.rb +++ b/spec/services/resource_events/change_labels_service_spec.rb @@ -5,6 +5,7 @@ require 'spec_helper' RSpec.describe ResourceEvents::ChangeLabelsService do let_it_be(:project) { create(:project) } let_it_be(:author) { create(:user) } + let(:resource) { create(:issue, project: project) } describe '.change_labels' do diff --git a/spec/services/resource_events/merge_into_notes_service_spec.rb b/spec/services/resource_events/merge_into_notes_service_spec.rb index 6209294f4ce..abe00e72f20 100644 --- a/spec/services/resource_events/merge_into_notes_service_spec.rb +++ b/spec/services/resource_events/merge_into_notes_service_spec.rb @@ -21,6 +21,7 @@ RSpec.describe ResourceEvents::MergeIntoNotesService do let_it_be(:resource) { create(:issue, project: project) } let_it_be(:label) { create(:label, project: project) } let_it_be(:label2) { create(:label, project: project) } + let(:time) { Time.current } describe '#execute' do diff --git a/spec/services/snippets/bulk_destroy_service_spec.rb b/spec/services/snippets/bulk_destroy_service_spec.rb index 8a6250a8b45..2f399d10188 100644 --- a/spec/services/snippets/bulk_destroy_service_spec.rb +++ b/spec/services/snippets/bulk_destroy_service_spec.rb @@ -4,6 +4,7 @@ require 'spec_helper' RSpec.describe Snippets::BulkDestroyService do let_it_be(:project) { create(:project) } + let(:user) { create(:user) } let!(:personal_snippet) { create(:personal_snippet, :repository, author: user) } let!(:project_snippet) { create(:project_snippet, :repository, project: project, author: user) } diff --git a/spec/services/snippets/create_service_spec.rb b/spec/services/snippets/create_service_spec.rb index 0b73808433f..0eb73c8edd2 100644 --- a/spec/services/snippets/create_service_spec.rb +++ b/spec/services/snippets/create_service_spec.rb @@ -6,6 +6,7 @@ RSpec.describe Snippets::CreateService do describe '#execute' do let_it_be(:user) { create(:user) } let_it_be(:admin) { create(:user, :admin) } + let(:action) { :create } let(:opts) { base_opts.merge(extra_opts) } let(:base_opts) do diff --git a/spec/services/snippets/update_service_spec.rb b/spec/services/snippets/update_service_spec.rb index 7fac500f224..f61d33e2436 100644 --- a/spec/services/snippets/update_service_spec.rb +++ b/spec/services/snippets/update_service_spec.rb @@ -6,6 +6,7 @@ RSpec.describe Snippets::UpdateService do describe '#execute', :aggregate_failures do let_it_be(:user) { create(:user) } let_it_be(:admin) { create :user, admin: true } + let(:action) { :update } let(:visibility_level) { Gitlab::VisibilityLevel::PRIVATE } let(:base_opts) do @@ -729,6 +730,7 @@ RSpec.describe Snippets::UpdateService do context 'when Project Snippet' do let_it_be(:project) { create(:project) } + let!(:snippet) { create(:project_snippet, :repository, author: user, project: project) } before do diff --git a/spec/services/spam/ham_service_spec.rb b/spec/services/spam/ham_service_spec.rb index c947de6cf92..0101a8e7704 100644 --- a/spec/services/spam/ham_service_spec.rb +++ b/spec/services/spam/ham_service_spec.rb @@ -4,6 +4,7 @@ require 'spec_helper' RSpec.describe Spam::HamService do let_it_be(:user) { create(:user) } + let!(:spam_log) { create(:spam_log, user: user, submitted_as_ham: false) } let(:fake_akismet_service) { double(:akismet_service) } diff --git a/spec/services/spam/spam_verdict_service_spec.rb b/spec/services/spam/spam_verdict_service_spec.rb index 9ff2e0ddf55..659c21b7d4f 100644 --- a/spec/services/spam/spam_verdict_service_spec.rb +++ b/spec/services/spam/spam_verdict_service_spec.rb @@ -17,6 +17,7 @@ RSpec.describe Spam::SpamVerdictService do let(:check_for_spam) { true } let_it_be(:user) { create(:user) } let_it_be(:issue) { create(:issue, author: user) } + let(:service) do described_class.new(user: user, target: issue, options: {}) end diff --git a/spec/services/system_note_service_spec.rb b/spec/services/system_note_service_spec.rb index 395fada574e..e9bd40b058b 100644 --- a/spec/services/system_note_service_spec.rb +++ b/spec/services/system_note_service_spec.rb @@ -11,6 +11,7 @@ RSpec.describe SystemNoteService do let_it_be(:group) { create(:group) } let_it_be(:project) { create(:project, :repository, group: group) } let_it_be(:author) { create(:user) } + let(:noteable) { create(:issue, project: project) } let(:issue) { noteable } diff --git a/spec/services/system_notes/issuables_service_spec.rb b/spec/services/system_notes/issuables_service_spec.rb index d2d9eba2bc6..1ea3c241d27 100644 --- a/spec/services/system_notes/issuables_service_spec.rb +++ b/spec/services/system_notes/issuables_service_spec.rb @@ -8,6 +8,7 @@ RSpec.describe ::SystemNotes::IssuablesService do let_it_be(:group) { create(:group) } let_it_be(:project) { create(:project, :repository, group: group) } let_it_be(:author) { create(:user) } + let(:noteable) { create(:issue, project: project) } let(:issue) { noteable } diff --git a/spec/services/test_hooks/project_service_spec.rb b/spec/services/test_hooks/project_service_spec.rb index a87e612e378..cd6284b4a87 100644 --- a/spec/services/test_hooks/project_service_spec.rb +++ b/spec/services/test_hooks/project_service_spec.rb @@ -9,6 +9,7 @@ RSpec.describe TestHooks::ProjectService do describe '#execute' do let_it_be(:project) { create(:project, :repository) } + let(:hook) { create(:project_hook, project: project) } let(:trigger) { 'not_implemented_events' } let(:service) { described_class.new(hook, current_user, trigger) } @@ -163,6 +164,7 @@ RSpec.describe TestHooks::ProjectService do context 'wiki_page_events' do let_it_be(:project) { create(:project, :wiki_repo) } + let(:trigger) { 'wiki_page_events' } let(:trigger_key) { :wiki_page_hooks } diff --git a/spec/services/test_hooks/system_service_spec.rb b/spec/services/test_hooks/system_service_spec.rb index e500a1057ab..a13ae471b4b 100644 --- a/spec/services/test_hooks/system_service_spec.rb +++ b/spec/services/test_hooks/system_service_spec.rb @@ -7,6 +7,7 @@ RSpec.describe TestHooks::SystemService do describe '#execute' do let_it_be(:project) { create(:project, :repository) } + let(:hook) { create(:system_hook) } let(:service) { described_class.new(hook, project.owner, trigger) } let(:success_result) { { status: :success, http_status: 200, message: 'ok' } } diff --git a/spec/services/users/approve_service_spec.rb b/spec/services/users/approve_service_spec.rb index 9999e674c7d..078dde546c9 100644 --- a/spec/services/users/approve_service_spec.rb +++ b/spec/services/users/approve_service_spec.rb @@ -4,6 +4,7 @@ require 'spec_helper' RSpec.describe Users::ApproveService do let_it_be(:current_user) { create(:admin) } + let(:user) { create(:user, :blocked_pending_approval) } subject(:execute) { described_class.new(current_user).execute(user) } diff --git a/spec/services/users/reject_service_spec.rb b/spec/services/users/reject_service_spec.rb index b9aaff5cde5..b0094a7c47e 100644 --- a/spec/services/users/reject_service_spec.rb +++ b/spec/services/users/reject_service_spec.rb @@ -4,6 +4,7 @@ require 'spec_helper' RSpec.describe Users::RejectService do let_it_be(:current_user) { create(:admin) } + let(:user) { create(:user, :blocked_pending_approval) } subject(:execute) { described_class.new(current_user).execute(user) } diff --git a/spec/services/users/validate_otp_service_spec.rb b/spec/services/users/validate_otp_service_spec.rb index 42f0c10488c..46b80b2149f 100644 --- a/spec/services/users/validate_otp_service_spec.rb +++ b/spec/services/users/validate_otp_service_spec.rb @@ -4,6 +4,7 @@ require 'spec_helper' RSpec.describe Users::ValidateOtpService do let_it_be(:user) { create(:user) } + let(:otp_code) { 42 } subject(:validate) { described_class.new(user).execute(otp_code) } diff --git a/spec/services/wiki_pages/event_create_service_spec.rb b/spec/services/wiki_pages/event_create_service_spec.rb index 974f2591763..6bc6a678189 100644 --- a/spec/services/wiki_pages/event_create_service_spec.rb +++ b/spec/services/wiki_pages/event_create_service_spec.rb @@ -10,6 +10,7 @@ RSpec.describe WikiPages::EventCreateService do describe '#execute' do let_it_be(:page) { create(:wiki_page, project: project) } + let(:slug) { generate(:sluggified_title) } let(:action) { :created } let(:fingerprint) { page.sha } diff --git a/spec/support/shared_examples/graphql/design_fields_shared_examples.rb b/spec/support/shared_examples/graphql/design_fields_shared_examples.rb index 9c2eb3e5a5c..efbcfaf0e91 100644 --- a/spec/support/shared_examples/graphql/design_fields_shared_examples.rb +++ b/spec/support/shared_examples/graphql/design_fields_shared_examples.rb @@ -27,6 +27,7 @@ RSpec.shared_examples 'a GraphQL type with design fields' do describe '#image' do let_it_be(:current_user) { create(:user) } + let(:schema) { GitlabSchema } let(:query) { GraphQL::Query.new(schema) } let(:context) { query.context } diff --git a/spec/support/shared_examples/quick_actions/issuable/issuable_quick_actions_shared_examples.rb b/spec/support/shared_examples/quick_actions/issuable/issuable_quick_actions_shared_examples.rb index 3cdba315d1f..4d142199c95 100644 --- a/spec/support/shared_examples/quick_actions/issuable/issuable_quick_actions_shared_examples.rb +++ b/spec/support/shared_examples/quick_actions/issuable/issuable_quick_actions_shared_examples.rb @@ -233,6 +233,7 @@ RSpec.shared_examples 'issuable quick actions' do context 'when user can update issuable' do let_it_be(:developer) { create(:user) } + let(:note_author) { developer } before do @@ -260,6 +261,7 @@ RSpec.shared_examples 'issuable quick actions' do context 'when user cannot update issuable' do let_it_be(:non_member) { create(:user) } + let(:note_author) { non_member } it 'applies commands that user can execute' do diff --git a/spec/support/shared_examples/services/container_registry_auth_service_shared_examples.rb b/spec/support/shared_examples/services/container_registry_auth_service_shared_examples.rb index ba176b616c3..d8794ef2693 100644 --- a/spec/support/shared_examples/services/container_registry_auth_service_shared_examples.rb +++ b/spec/support/shared_examples/services/container_registry_auth_service_shared_examples.rb @@ -159,6 +159,7 @@ RSpec.shared_examples 'a container registry auth service' do describe '#full_access_token' do let_it_be(:project) { create(:project) } + let(:token) { described_class.full_access_token(project.full_path) } subject { { token: token } } @@ -172,6 +173,7 @@ RSpec.shared_examples 'a container registry auth service' do describe '#pull_access_token' do let_it_be(:project) { create(:project) } + let(:token) { described_class.pull_access_token(project.full_path) } subject { { token: token } } @@ -432,6 +434,7 @@ RSpec.shared_examples 'a container registry auth service' do context 'for external user' do context 'disallow anyone to pull or push images' do let_it_be(:current_user) { create(:user, external: true) } + let(:current_params) do { scopes: ["repository:#{project.full_path}:pull,push"] } end @@ -442,6 +445,7 @@ RSpec.shared_examples 'a container registry auth service' do context 'disallow anyone to delete images' do let_it_be(:current_user) { create(:user, external: true) } + let(:current_params) do { scopes: ["repository:#{project.full_path}:*"] } end @@ -452,6 +456,7 @@ RSpec.shared_examples 'a container registry auth service' do context 'disallow anyone to delete images since registry 2.7' do let_it_be(:current_user) { create(:user, external: true) } + let(:current_params) do { scopes: ["repository:#{project.full_path}:delete"] } end diff --git a/spec/support/shared_examples/services/packages_shared_examples.rb b/spec/support/shared_examples/services/packages_shared_examples.rb index 72878e925dc..6bc4f171d9c 100644 --- a/spec/support/shared_examples/services/packages_shared_examples.rb +++ b/spec/support/shared_examples/services/packages_shared_examples.rb @@ -43,6 +43,7 @@ end RSpec.shared_examples 'assigns status to package' do context 'with status param' do let_it_be(:status) { 'hidden' } + let(:params) { super().merge(status: status) } it 'assigns the status to the package' do diff --git a/spec/tasks/gitlab/db_rake_spec.rb b/spec/tasks/gitlab/db_rake_spec.rb index f948f2627d0..8688424dad4 100644 --- a/spec/tasks/gitlab/db_rake_spec.rb +++ b/spec/tasks/gitlab/db_rake_spec.rb @@ -126,6 +126,7 @@ RSpec.describe 'gitlab:db namespace rake task', :silence_stdout do let_it_be(:test_task_name) { 'gitlab:db:_test_multiple_structure_cleans' } let_it_be(:structure_file) { 'db/structure.sql' } let_it_be(:input) { 'this is structure data' } + let(:output) { StringIO.new } before do diff --git a/spec/tasks/gitlab/packages/composer_rake_spec.rb b/spec/tasks/gitlab/packages/composer_rake_spec.rb index 78013714de5..f4f43bf77d8 100644 --- a/spec/tasks/gitlab/packages/composer_rake_spec.rb +++ b/spec/tasks/gitlab/packages/composer_rake_spec.rb @@ -10,6 +10,7 @@ RSpec.describe 'gitlab:packages:build_composer_cache namespace rake task', :sile let_it_be(:group) { create(:group) } let_it_be(:project) { create(:project, :custom_repo, files: { 'composer.json' => json.to_json }, group: group) } let_it_be(:project2) { create(:project, :custom_repo, files: { 'composer.json' => json2.to_json }, group: group) } + let!(:package) { create(:composer_package, :with_metadatum, project: project, name: package_name, version: '1.0.0', json: json) } let!(:package2) { create(:composer_package, :with_metadatum, project: project, name: package_name, version: '2.0.0', json: json) } let!(:package3) { create(:composer_package, :with_metadatum, project: project2, name: package_name2, version: '3.0.0', json: json2) } diff --git a/spec/tasks/gitlab/snippets_rake_spec.rb b/spec/tasks/gitlab/snippets_rake_spec.rb index d40b784b3a0..c55bded1d5a 100644 --- a/spec/tasks/gitlab/snippets_rake_spec.rb +++ b/spec/tasks/gitlab/snippets_rake_spec.rb @@ -5,6 +5,7 @@ require 'rake_helper' RSpec.describe 'gitlab:snippets namespace rake task', :silence_stdout do let_it_be(:user) { create(:user)} let_it_be(:migrated) { create(:personal_snippet, :repository, author: user) } + let(:non_migrated) { create_list(:personal_snippet, 3, author: user) } let(:non_migrated_ids) { non_migrated.pluck(:id) } diff --git a/spec/uploaders/content_type_whitelist_spec.rb b/spec/uploaders/content_type_whitelist_spec.rb index cf7463369ab..0cafc7a3ae2 100644 --- a/spec/uploaders/content_type_whitelist_spec.rb +++ b/spec/uploaders/content_type_whitelist_spec.rb @@ -4,6 +4,7 @@ require 'spec_helper' RSpec.describe ContentTypeWhitelist do let_it_be(:model) { build_stubbed(:user) } + let!(:uploader) do stub_const('DummyUploader', Class.new(CarrierWave::Uploader::Base)) diff --git a/spec/uploaders/dependency_proxy/file_uploader_spec.rb b/spec/uploaders/dependency_proxy/file_uploader_spec.rb index 6e94a661d6d..eb12e7dffa5 100644 --- a/spec/uploaders/dependency_proxy/file_uploader_spec.rb +++ b/spec/uploaders/dependency_proxy/file_uploader_spec.rb @@ -5,6 +5,7 @@ RSpec.describe DependencyProxy::FileUploader do describe 'DependencyProxy::Blob uploader' do let_it_be(:blob) { create(:dependency_proxy_blob) } let_it_be(:path) { Gitlab.config.dependency_proxy.storage_path } + let(:uploader) { described_class.new(blob, :file) } subject { uploader } @@ -30,6 +31,7 @@ RSpec.describe DependencyProxy::FileUploader do let_it_be(:manifest) { create(:dependency_proxy_manifest) } let_it_be(:initial_content_type) { 'application/json' } let_it_be(:fixture_file) { fixture_file_upload('spec/fixtures/dependency_proxy/manifest', initial_content_type) } + let(:uploader) { described_class.new(manifest, :file) } subject { uploader } diff --git a/spec/views/admin/application_settings/_eks.html.haml_spec.rb b/spec/views/admin/application_settings/_eks.html.haml_spec.rb index 2f45eaadc9f..e407970c7a4 100644 --- a/spec/views/admin/application_settings/_eks.html.haml_spec.rb +++ b/spec/views/admin/application_settings/_eks.html.haml_spec.rb @@ -4,6 +4,7 @@ require 'spec_helper' RSpec.describe 'admin/application_settings/_eks' do let_it_be(:admin) { create(:admin) } + let(:page) { Capybara::Node::Simple.new(rendered) } before do diff --git a/spec/views/admin/application_settings/_package_registry.html.haml_spec.rb b/spec/views/admin/application_settings/_package_registry.html.haml_spec.rb index e0aa2fc8d56..72e32643a49 100644 --- a/spec/views/admin/application_settings/_package_registry.html.haml_spec.rb +++ b/spec/views/admin/application_settings/_package_registry.html.haml_spec.rb @@ -6,6 +6,7 @@ RSpec.describe 'admin/application_settings/_package_registry' do let_it_be(:admin) { create(:admin) } let_it_be(:default_plan_limits) { create(:plan_limits, :default_plan, :with_package_file_sizes) } let_it_be(:application_setting) { build(:application_setting) } + let(:page) { Capybara::Node::Simple.new(rendered) } before do diff --git a/spec/views/projects/pipelines/show.html.haml_spec.rb b/spec/views/projects/pipelines/show.html.haml_spec.rb index 5b5c05527de..fcae587f8c8 100644 --- a/spec/views/projects/pipelines/show.html.haml_spec.rb +++ b/spec/views/projects/pipelines/show.html.haml_spec.rb @@ -6,6 +6,7 @@ RSpec.describe 'projects/pipelines/show' do include Devise::Test::ControllerHelpers let_it_be(:project) { create(:project, :repository) } let_it_be(:user) { create(:user) } + let(:pipeline) { create(:ci_pipeline, project: project) } let(:presented_pipeline) { pipeline.present(current_user: user) } diff --git a/spec/views/search/_results.html.haml_spec.rb b/spec/views/search/_results.html.haml_spec.rb index 11f2a4082e7..024e4cef9fd 100644 --- a/spec/views/search/_results.html.haml_spec.rb +++ b/spec/views/search/_results.html.haml_spec.rb @@ -32,6 +32,7 @@ RSpec.describe 'search/_results' do let_it_be(:project) { create(:project) } let_it_be(:issue) { create(:issue, project: project, title: '*') } let_it_be(:note) { create(:discussion_note_on_issue, noteable: issue, project: issue.project, note: '```"helloworld"```') } + let(:scope) { 'notes' } let(:search_objects) { Note.page(1).per(2) } let(:term) { 'helloworld' } diff --git a/spec/views/shared/_label_row.html.haml_spec.rb b/spec/views/shared/_label_row.html.haml_spec.rb index e9a0bfdcd4e..6fe74b6633b 100644 --- a/spec/views/shared/_label_row.html.haml_spec.rb +++ b/spec/views/shared/_label_row.html.haml_spec.rb @@ -3,6 +3,7 @@ require 'spec_helper' RSpec.describe 'shared/_label_row.html.haml' do let_it_be(:group) { create(:group) } + let(:label) { build_stubbed(:group_label, group: group).present(issuable_subject: group) } before do @@ -11,6 +12,7 @@ RSpec.describe 'shared/_label_row.html.haml' do context 'with a project context' do let_it_be(:project) { create(:project, group: group) } + let(:label) { build_stubbed(:label, project: project).present(issuable_subject: project) } before do @@ -42,6 +44,7 @@ RSpec.describe 'shared/_label_row.html.haml' do context 'with a subgroup context' do let_it_be(:subgroup) { create(:group, parent: group) } + let(:label) { build_stubbed(:group_label, group: subgroup).present(issuable_subject: subgroup) } before do diff --git a/spec/views/shared/milestones/_top.html.haml_spec.rb b/spec/views/shared/milestones/_top.html.haml_spec.rb index 1aa971709f1..aa989d3e441 100644 --- a/spec/views/shared/milestones/_top.html.haml_spec.rb +++ b/spec/views/shared/milestones/_top.html.haml_spec.rb @@ -4,6 +4,7 @@ require 'spec_helper' RSpec.describe 'shared/milestones/_top.html.haml' do let_it_be(:group) { create(:group) } + let(:project) { create(:project, group: group) } let(:milestone) { create(:milestone, project: project) } |