diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-08-11 06:11:00 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-08-11 06:11:00 +0300 |
commit | bdca0979165cb662173d959c358fce0c539c7544 (patch) | |
tree | 5a2a58ea3738592da1d84a2ed53410deea752a51 /spec | |
parent | 1a3d7fe0b65d92e322bfe33aebe6b64419203f4f (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec')
300 files changed, 599 insertions, 0 deletions
diff --git a/spec/config/object_store_settings_spec.rb b/spec/config/object_store_settings_spec.rb index 4a800261625..36938c74afa 100644 --- a/spec/config/object_store_settings_spec.rb +++ b/spec/config/object_store_settings_spec.rb @@ -18,6 +18,7 @@ RSpec.describe ObjectStoreSettings do 'region' => 'us-east-1' } end + let(:config) do { 'lfs' => { 'enabled' => true }, diff --git a/spec/controllers/boards/issues_controller_spec.rb b/spec/controllers/boards/issues_controller_spec.rb index 601b8d427e0..a7f3ab0089f 100644 --- a/spec/controllers/boards/issues_controller_spec.rb +++ b/spec/controllers/boards/issues_controller_spec.rb @@ -265,6 +265,7 @@ RSpec.describe Boards::IssuesController do hash[:ids] = [issue2.id] end end + let(:requesting_user) { user } let(:expected_status) { 200 } let(:expected_issue_count) { 2 } @@ -280,6 +281,7 @@ RSpec.describe Boards::IssuesController do hash[:ids] = [issue2.id] end end + let(:requesting_user) { user } let(:expected_status) { 403 } let(:expected_issue_count) { 1 } @@ -296,6 +298,7 @@ RSpec.describe Boards::IssuesController do hash[:move_before_id] = nil end end + let(:requesting_user) { user } let(:expected_status) { 200 } let(:expected_issue_count) { 4 } @@ -317,6 +320,7 @@ RSpec.describe Boards::IssuesController do hash[:move_before_id] = nil end end + let(:requesting_user) { user } let(:expected_status) { 200 } let(:expected_issue_count) { 3 } @@ -332,6 +336,7 @@ RSpec.describe Boards::IssuesController do hash[:move_before_id] = nil end end + let(:requesting_user) { user } let(:expected_status) { 200 } let(:expected_issue_count) { 4 } @@ -350,6 +355,7 @@ RSpec.describe Boards::IssuesController do hash[:move_after_id] = issue4.id end end + let(:requesting_user) { user } let(:expected_status) { 200 } let(:expected_issue_count) { 5 } @@ -365,6 +371,7 @@ RSpec.describe Boards::IssuesController do hash[:ids] = (0..51).to_a end end + let(:requesting_user) { user } let(:expected_status) { 422 } let(:expected_issue_count) { 1 } @@ -380,6 +387,7 @@ RSpec.describe Boards::IssuesController do hash[:ids] = 'foobar' end end + let(:requesting_user) { user } let(:expected_status) { 400 } let(:expected_issue_count) { 1 } diff --git a/spec/controllers/groups/milestones_controller_spec.rb b/spec/controllers/groups/milestones_controller_spec.rb index e47bb75af22..5c7b88a218a 100644 --- a/spec/controllers/groups/milestones_controller_spec.rb +++ b/spec/controllers/groups/milestones_controller_spec.rb @@ -86,6 +86,7 @@ RSpec.describe Groups::MilestonesController do let!(:public_project_with_private_issues_and_mrs) do create(:project, :public, :issues_private, :merge_requests_private, group: public_group) end + let!(:private_milestone) { create(:milestone, project: public_project_with_private_issues_and_mrs, title: 'project milestone') } context 'when anonymous user' do diff --git a/spec/controllers/groups/settings/repository_controller_spec.rb b/spec/controllers/groups/settings/repository_controller_spec.rb index d2c170521ba..14bbdc05282 100644 --- a/spec/controllers/groups/settings/repository_controller_spec.rb +++ b/spec/controllers/groups/settings/repository_controller_spec.rb @@ -36,6 +36,7 @@ RSpec.describe Groups::Settings::RepositoryController do deploy_token_type: DeployToken.deploy_token_types[:group_type] } end + let(:request_params) do { group_id: group.to_param, diff --git a/spec/controllers/import/gitlab_controller_spec.rb b/spec/controllers/import/gitlab_controller_spec.rb index 42c4348dac2..826625ba9c3 100644 --- a/spec/controllers/import/gitlab_controller_spec.rb +++ b/spec/controllers/import/gitlab_controller_spec.rb @@ -53,6 +53,7 @@ RSpec.describe Import::GitlabController do let(:gitlab_user) do { username: gitlab_username }.with_indifferent_access end + let(:gitlab_repo) do { path: 'vim', diff --git a/spec/controllers/projects/forks_controller_spec.rb b/spec/controllers/projects/forks_controller_spec.rb index 72c40fc5772..e8b30294cdd 100644 --- a/spec/controllers/projects/forks_controller_spec.rb +++ b/spec/controllers/projects/forks_controller_spec.rb @@ -245,6 +245,7 @@ RSpec.describe Projects::ForksController do continue: continue_params } end + let(:continue_params) do { to: '/-/ide/project/path', diff --git a/spec/controllers/projects/logs_controller_spec.rb b/spec/controllers/projects/logs_controller_spec.rb index 013155b4649..d5c602df41d 100644 --- a/spec/controllers/projects/logs_controller_spec.rb +++ b/spec/controllers/projects/logs_controller_spec.rb @@ -59,6 +59,7 @@ RSpec.describe Projects::LogsController do container_name: container } end + let(:service_result_json) { Gitlab::Json.parse(service_result.to_json) } let_it_be(:cluster) { create(:cluster, :provided_by_gcp, environment_scope: '*', projects: [project]) } diff --git a/spec/controllers/projects/notes_controller_spec.rb b/spec/controllers/projects/notes_controller_spec.rb index 9728fad417e..570d65dba4f 100644 --- a/spec/controllers/projects/notes_controller_spec.rb +++ b/spec/controllers/projects/notes_controller_spec.rb @@ -302,6 +302,7 @@ RSpec.describe Projects::NotesController do target_id: merge_request.id }.merge(extra_request_params) end + let(:extra_request_params) { {} } let(:project_visibility) { Gitlab::VisibilityLevel::PUBLIC } diff --git a/spec/controllers/projects/protected_branches_controller_spec.rb b/spec/controllers/projects/protected_branches_controller_spec.rb index 09eb1a45c73..a0cb5c1473a 100644 --- a/spec/controllers/projects/protected_branches_controller_spec.rb +++ b/spec/controllers/projects/protected_branches_controller_spec.rb @@ -27,6 +27,7 @@ RSpec.describe Projects::ProtectedBranchesController do { merge_access_levels_attributes: maintainer_access_level, push_access_levels_attributes: maintainer_access_level } end + let(:create_params) { attributes_for(:protected_branch).merge(access_level_params) } before do diff --git a/spec/controllers/projects/serverless/functions_controller_spec.rb b/spec/controllers/projects/serverless/functions_controller_spec.rb index 3071d0b7f54..7f558ad9231 100644 --- a/spec/controllers/projects/serverless/functions_controller_spec.rb +++ b/spec/controllers/projects/serverless/functions_controller_spec.rb @@ -18,6 +18,7 @@ RSpec.describe Projects::Serverless::FunctionsController do let(:knative_stub_options) do { namespace: namespace.namespace, name: function_name, description: function_description } end + let(:knative) { create(:clusters_applications_knative, :installed, cluster: cluster) } let(:namespace) do diff --git a/spec/controllers/projects/settings/repository_controller_spec.rb b/spec/controllers/projects/settings/repository_controller_spec.rb index 13c5f1d8331..d93f23ae142 100644 --- a/spec/controllers/projects/settings/repository_controller_spec.rb +++ b/spec/controllers/projects/settings/repository_controller_spec.rb @@ -56,6 +56,7 @@ RSpec.describe Projects::Settings::RepositoryController do deploy_token_type: DeployToken.deploy_token_types[:project_type] } end + let(:request_params) do { namespace_id: project.namespace.to_param, diff --git a/spec/controllers/projects/variables_controller_spec.rb b/spec/controllers/projects/variables_controller_spec.rb index 8bb4c2dae4b..768d2ec00bd 100644 --- a/spec/controllers/projects/variables_controller_spec.rb +++ b/spec/controllers/projects/variables_controller_spec.rb @@ -47,6 +47,7 @@ RSpec.describe Projects::VariablesController do protected: variable.protected?.to_s, environment_scope: variable.environment_scope } end + let(:new_variable_attributes) do { key: 'new_key', secret_value: 'dummy_value', diff --git a/spec/controllers/repositories/git_http_controller_spec.rb b/spec/controllers/repositories/git_http_controller_spec.rb index c938df8cf4e..851c1b7e519 100644 --- a/spec/controllers/repositories/git_http_controller_spec.rb +++ b/spec/controllers/repositories/git_http_controller_spec.rb @@ -17,6 +17,7 @@ RSpec.describe Repositories::GitHttpController do repository_id: repository_id } end + let(:params) { container_params } describe 'HEAD #info_refs' do diff --git a/spec/controllers/sent_notifications_controller_spec.rb b/spec/controllers/sent_notifications_controller_spec.rb index 0c4a77d5926..02aaa5b16f1 100644 --- a/spec/controllers/sent_notifications_controller_spec.rb +++ b/spec/controllers/sent_notifications_controller_spec.rb @@ -216,6 +216,7 @@ RSpec.describe SentNotificationsController do merge_request.subscriptions.create(user: user, project: project, subscribed: true) end end + let(:sent_notification) { create(:sent_notification, project: project, noteable: merge_request, recipient: user) } before do diff --git a/spec/features/admin/admin_mode/login_spec.rb b/spec/features/admin/admin_mode/login_spec.rb index 4b26ceb55e2..12046518aac 100644 --- a/spec/features/admin/admin_mode/login_spec.rb +++ b/spec/features/admin/admin_mode/login_spec.rb @@ -196,6 +196,7 @@ RSpec.describe 'Admin Mode Login', :clean_gitlab_redis_shared_state, :do_not_moc 'base' => 'dc=example,dc=com' } end + let(:user) { create(:omniauth_user, :admin, :two_factor, extern_uid: uid, provider: provider) } before do diff --git a/spec/features/atom/users_spec.rb b/spec/features/atom/users_spec.rb index c79b812df46..ab874408e55 100644 --- a/spec/features/atom/users_spec.rb +++ b/spec/features/atom/users_spec.rb @@ -30,6 +30,7 @@ RSpec.describe "User Feed" do author: user, description: "Houston, we have a bug!\n\n***\n\nI guess.") end + let(:note) do create(:note, noteable: issue, @@ -37,6 +38,7 @@ RSpec.describe "User Feed" do note: 'Bug confirmed :+1:', project: project) end + let(:merge_request) do create(:merge_request, title: 'Fix bug', @@ -45,6 +47,7 @@ RSpec.describe "User Feed" do target_project: project, description: "Here is the fix: ![an image](image.png)") end + let(:push_event) { create(:push_event, project: project, author: user) } let!(:push_event_payload) { create(:push_event_payload, event: push_event) } diff --git a/spec/features/markdown/metrics_spec.rb b/spec/features/markdown/metrics_spec.rb index 68a0345d51d..1ac56186a80 100644 --- a/spec/features/markdown/metrics_spec.rb +++ b/spec/features/markdown/metrics_spec.rb @@ -83,6 +83,7 @@ RSpec.describe 'Metrics rendering', :js, :kubeclient, :use_clean_rails_memory_st y_label: 'Total Cores' } end + let(:metrics_url_2) { urls.metrics_project_environment_url(project, environment, **chart_params_2) } let(:description) { "See [metrics dashboard](#{metrics_url}) for info. \n See [metrics dashboard](#{metrics_url_2}) for info." } let(:issue) { create(:issue, project: project, description: description) } diff --git a/spec/features/merge_request/user_comments_on_diff_spec.rb b/spec/features/merge_request/user_comments_on_diff_spec.rb index 30bf82e3665..3a199951b56 100644 --- a/spec/features/merge_request/user_comments_on_diff_spec.rb +++ b/spec/features/merge_request/user_comments_on_diff_spec.rb @@ -10,6 +10,7 @@ RSpec.describe 'User comments on a diff', :js do let(:merge_request) do create(:merge_request_with_diffs, source_project: project, target_project: project, source_branch: 'merge-test') end + let(:user) { create(:user) } before do diff --git a/spec/features/merge_request/user_customizes_merge_commit_message_spec.rb b/spec/features/merge_request/user_customizes_merge_commit_message_spec.rb index 23df7635aa1..1d3d76d3486 100644 --- a/spec/features/merge_request/user_customizes_merge_commit_message_spec.rb +++ b/spec/features/merge_request/user_customizes_merge_commit_message_spec.rb @@ -15,6 +15,7 @@ RSpec.describe 'Merge request < User customizes merge commit message', :js do description: "Description\n\nclosing #{issue_1.to_reference}, #{issue_2.to_reference}" ) end + let(:textbox) { page.find(:css, '#merge-message-edit', visible: false) } let(:default_message) do [ @@ -24,6 +25,7 @@ RSpec.describe 'Merge request < User customizes merge commit message', :js do "See merge request #{merge_request.to_reference(full: true)}" ].join("\n\n") end + let(:message_with_description) do [ "Merge branch 'feature' into 'master'", diff --git a/spec/features/merge_request/user_merges_immediately_spec.rb b/spec/features/merge_request/user_merges_immediately_spec.rb index 47dc09ae79f..0fb081ec507 100644 --- a/spec/features/merge_request/user_merges_immediately_spec.rb +++ b/spec/features/merge_request/user_merges_immediately_spec.rb @@ -12,6 +12,7 @@ RSpec.describe 'Merge requests > User merges immediately', :js do head_pipeline: pipeline, source_branch: pipeline.ref) end + let(:pipeline) do create(:ci_pipeline, project: project, ref: 'master', diff --git a/spec/features/merge_request/user_merges_when_pipeline_succeeds_spec.rb b/spec/features/merge_request/user_merges_when_pipeline_succeeds_spec.rb index e61ae4ea795..3dc49fb4dea 100644 --- a/spec/features/merge_request/user_merges_when_pipeline_succeeds_spec.rb +++ b/spec/features/merge_request/user_merges_when_pipeline_succeeds_spec.rb @@ -11,6 +11,7 @@ RSpec.describe 'Merge request > User merges when pipeline succeeds', :js do title: 'Bug NS-04', merge_params: { force_remove_source_branch: '1' }) end + let(:pipeline) do create(:ci_pipeline, project: project, sha: merge_request.diff_head_sha, @@ -115,6 +116,7 @@ RSpec.describe 'Merge request > User merges when pipeline succeeds', :js do merge_user: user, title: 'MepMep') end + let!(:build) do create(:ci_build, pipeline: pipeline) end diff --git a/spec/features/merge_request/user_posts_notes_spec.rb b/spec/features/merge_request/user_posts_notes_spec.rb index 3c70819319d..e2d218ed752 100644 --- a/spec/features/merge_request/user_posts_notes_spec.rb +++ b/spec/features/merge_request/user_posts_notes_spec.rb @@ -10,6 +10,7 @@ RSpec.describe 'Merge request > User posts notes', :js do let(:merge_request) do create(:merge_request, source_project: project, target_project: project) end + let!(:note) do create(:note_on_merge_request, :with_attachment, noteable: merge_request, project: project) diff --git a/spec/features/merge_request/user_resolves_wip_mr_spec.rb b/spec/features/merge_request/user_resolves_wip_mr_spec.rb index 6b15dc7ae3c..a9d4c4df507 100644 --- a/spec/features/merge_request/user_resolves_wip_mr_spec.rb +++ b/spec/features/merge_request/user_resolves_wip_mr_spec.rb @@ -11,6 +11,7 @@ RSpec.describe 'Merge request > User resolves Work in Progress', :js do title: 'WIP: Bug NS-04', merge_params: { force_remove_source_branch: '1' }) end + let(:pipeline) do create(:ci_pipeline, project: project, sha: merge_request.diff_head_sha, diff --git a/spec/features/merge_request/user_sees_avatar_on_diff_notes_spec.rb b/spec/features/merge_request/user_sees_avatar_on_diff_notes_spec.rb index 415e6b29d5a..7fad805866b 100644 --- a/spec/features/merge_request/user_sees_avatar_on_diff_notes_spec.rb +++ b/spec/features/merge_request/user_sees_avatar_on_diff_notes_spec.rb @@ -16,6 +16,7 @@ RSpec.describe 'Merge request > User sees avatars on diff notes', :js do diff_refs: merge_request.diff_refs ) end + let!(:note) { create(:diff_note_on_merge_request, project: project, noteable: merge_request, position: position) } before do diff --git a/spec/features/merge_request/user_sees_closing_issues_message_spec.rb b/spec/features/merge_request/user_sees_closing_issues_message_spec.rb index baef547a480..d6cdc15005b 100644 --- a/spec/features/merge_request/user_sees_closing_issues_message_spec.rb +++ b/spec/features/merge_request/user_sees_closing_issues_message_spec.rb @@ -16,6 +16,7 @@ RSpec.describe 'Merge request > User sees closing issues message', :js do title: merge_request_title ) end + let(:merge_request_description) { 'Merge Request Description' } let(:merge_request_title) { 'Merge Request Title' } diff --git a/spec/features/merge_request/user_sees_discussions_spec.rb b/spec/features/merge_request/user_sees_discussions_spec.rb index 74d1b8b628c..289c861739f 100644 --- a/spec/features/merge_request/user_sees_discussions_spec.rb +++ b/spec/features/merge_request/user_sees_discussions_spec.rb @@ -24,6 +24,7 @@ RSpec.describe 'Merge request > User sees threads', :js do diff_refs: outdated_diff_refs ) end + let(:outdated_diff_refs) { project.commit("874797c3a73b60d2187ed6e2fcabd289ff75171e").diff_refs } before do diff --git a/spec/features/merge_request/user_sees_merge_request_pipelines_spec.rb b/spec/features/merge_request/user_sees_merge_request_pipelines_spec.rb index e2aa10d80dd..fb7fa92dbb5 100644 --- a/spec/features/merge_request/user_sees_merge_request_pipelines_spec.rb +++ b/spec/features/merge_request/user_sees_merge_request_pipelines_spec.rb @@ -53,6 +53,7 @@ RSpec.describe 'Merge request > User sees pipelines triggered by merge request', Ci::CreatePipelineService.new(project, user, ref: 'feature') .execute(:merge_request_event, merge_request: merge_request) end + let(:enable_mr_tabs_position_flag) { false } before do diff --git a/spec/features/merge_request/user_sees_pipelines_from_forked_project_spec.rb b/spec/features/merge_request/user_sees_pipelines_from_forked_project_spec.rb index 56092da5136..a9fefc89d6c 100644 --- a/spec/features/merge_request/user_sees_pipelines_from_forked_project_spec.rb +++ b/spec/features/merge_request/user_sees_pipelines_from_forked_project_spec.rb @@ -13,6 +13,7 @@ RSpec.describe 'Merge request > User sees pipelines from forked project', :js do target_project: target_project, description: 'Test merge request') end + let(:pipeline) do create(:ci_pipeline, project: forked_project, diff --git a/spec/features/merge_request/user_sees_versions_spec.rb b/spec/features/merge_request/user_sees_versions_spec.rb index a89ae5c7464..60e054ddbee 100644 --- a/spec/features/merge_request/user_sees_versions_spec.rb +++ b/spec/features/merge_request/user_sees_versions_spec.rb @@ -8,6 +8,7 @@ RSpec.describe 'Merge request > User sees versions', :js do mr.merge_request_diff.destroy! end end + let(:project) { merge_request.source_project } let(:user) { project.creator } let!(:merge_request_diff1) { merge_request.merge_request_diffs.create!(head_commit_sha: '6f6d7e7ed97bb5f0054f2b1df789b39ca89b6ff9') } diff --git a/spec/features/merge_request/user_suggests_changes_on_diff_spec.rb b/spec/features/merge_request/user_suggests_changes_on_diff_spec.rb index 0506d190487..39495832547 100644 --- a/spec/features/merge_request/user_suggests_changes_on_diff_spec.rb +++ b/spec/features/merge_request/user_suggests_changes_on_diff_spec.rb @@ -22,6 +22,7 @@ RSpec.describe 'User comments on a diff', :js do let(:merge_request) do create(:merge_request_with_diffs, source_project: project, target_project: project, source_branch: 'merge-test') end + let(:user) { create(:user) } before do diff --git a/spec/features/merge_request/user_tries_to_access_private_project_info_through_new_mr_spec.rb b/spec/features/merge_request/user_tries_to_access_private_project_info_through_new_mr_spec.rb index b864cb55785..96a1cd81c93 100644 --- a/spec/features/merge_request/user_tries_to_access_private_project_info_through_new_mr_spec.rb +++ b/spec/features/merge_request/user_tries_to_access_private_project_info_through_new_mr_spec.rb @@ -10,6 +10,7 @@ RSpec.describe 'Merge Request > User tries to access private project information name: 'nothing to see here', repository_access_level: ProjectFeature::PRIVATE) end + let(:owned_project) do create(:project, :public, :repository, namespace: current_user.namespace, diff --git a/spec/features/merge_request/user_views_diffs_file_by_file_spec.rb b/spec/features/merge_request/user_views_diffs_file_by_file_spec.rb index c254a142349..abb313cb529 100644 --- a/spec/features/merge_request/user_views_diffs_file_by_file_spec.rb +++ b/spec/features/merge_request/user_views_diffs_file_by_file_spec.rb @@ -6,6 +6,7 @@ RSpec.describe 'User views diffs file-by-file', :js do let(:merge_request) do create(:merge_request_with_diffs, source_project: project, target_project: project, source_branch: 'merge-test') end + let(:project) { create(:project, :repository) } let(:user) { create(:user, view_diffs_file_by_file: true) } diff --git a/spec/features/merge_request/user_views_diffs_spec.rb b/spec/features/merge_request/user_views_diffs_spec.rb index 14d10fc1c9f..537c0473fa4 100644 --- a/spec/features/merge_request/user_views_diffs_spec.rb +++ b/spec/features/merge_request/user_views_diffs_spec.rb @@ -6,6 +6,7 @@ RSpec.describe 'User views diffs', :js do let(:merge_request) do create(:merge_request_with_diffs, source_project: project, target_project: project, source_branch: 'merge-test') end + let(:project) { create(:project, :public, :repository) } let(:view) { 'inline' } diff --git a/spec/features/merge_requests/user_views_diffs_commit_spec.rb b/spec/features/merge_requests/user_views_diffs_commit_spec.rb index 590397df73f..fcaabf9b0e7 100644 --- a/spec/features/merge_requests/user_views_diffs_commit_spec.rb +++ b/spec/features/merge_requests/user_views_diffs_commit_spec.rb @@ -6,6 +6,7 @@ RSpec.describe 'User views diff by commit', :js do let(:merge_request) do create(:merge_request_with_diffs, source_project: project, target_project: project, source_branch: 'merge-test') end + let(:project) { create(:project, :public, :repository) } before do diff --git a/spec/features/profiles/chat_names_spec.rb b/spec/features/profiles/chat_names_spec.rb index 80b36aa37b8..ca888018cad 100644 --- a/spec/features/profiles/chat_names_spec.rb +++ b/spec/features/profiles/chat_names_spec.rb @@ -14,6 +14,7 @@ RSpec.describe 'Profile > Chat' do let(:params) do { team_id: 'T00', team_domain: 'my_chat_team', user_id: 'U01', user_name: 'my_chat_user' } end + let!(:authorize_url) { ChatNames::AuthorizeUserService.new(service, params).execute } let(:authorize_path) { URI.parse(authorize_url).request_uri } diff --git a/spec/features/projects/classification_label_on_project_pages_spec.rb b/spec/features/projects/classification_label_on_project_pages_spec.rb index 0f07ca7635b..9522e5ce2cf 100644 --- a/spec/features/projects/classification_label_on_project_pages_spec.rb +++ b/spec/features/projects/classification_label_on_project_pages_spec.rb @@ -6,6 +6,7 @@ RSpec.describe 'Classification label on project pages' do let(:project) do create(:project, external_authorization_classification_label: 'authorized label') end + let(:user) { create(:user) } before do diff --git a/spec/features/projects/commit/mini_pipeline_graph_spec.rb b/spec/features/projects/commit/mini_pipeline_graph_spec.rb index 9349f36282d..cf9b86f16bb 100644 --- a/spec/features/projects/commit/mini_pipeline_graph_spec.rb +++ b/spec/features/projects/commit/mini_pipeline_graph_spec.rb @@ -12,6 +12,7 @@ RSpec.describe 'Mini Pipeline Graph in Commit View', :js do ref: project.default_branch, sha: project.commit.sha) end + let(:build) { create(:ci_build, pipeline: pipeline) } it 'display icon with status' do diff --git a/spec/features/projects/files/user_browses_files_spec.rb b/spec/features/projects/files/user_browses_files_spec.rb index e5259bd88be..a6126fbcb33 100644 --- a/spec/features/projects/files/user_browses_files_spec.rb +++ b/spec/features/projects/files/user_browses_files_spec.rb @@ -9,6 +9,7 @@ RSpec.describe "User browses files" do "You're not allowed to make changes to this project directly. "\ "A fork of this project has been created that you can make changes in, so you can submit a merge request." end + let(:project) { create(:project, :repository, name: "Shop") } let(:project2) { create(:project, :repository, name: "Another Project", path: "another-project") } let(:tree_path_root_ref) { project_tree_path(project, project.repository.root_ref) } diff --git a/spec/features/projects/files/user_creates_directory_spec.rb b/spec/features/projects/files/user_creates_directory_spec.rb index 47c5d667f4f..f2074c78dba 100644 --- a/spec/features/projects/files/user_creates_directory_spec.rb +++ b/spec/features/projects/files/user_creates_directory_spec.rb @@ -7,6 +7,7 @@ RSpec.describe 'Projects > Files > User creates a directory', :js do "You're not allowed to make changes to this project directly. "\ "A fork of this project has been created that you can make changes in, so you can submit a merge request." end + let(:project) { create(:project, :repository) } let(:project2) { create(:project, :repository, name: 'Another Project', path: 'another-project') } let(:project2_tree_path_root_ref) { project_tree_path(project2, project2.repository.root_ref) } diff --git a/spec/features/projects/files/user_creates_files_spec.rb b/spec/features/projects/files/user_creates_files_spec.rb index 5abc048c135..39bc139656b 100644 --- a/spec/features/projects/files/user_creates_files_spec.rb +++ b/spec/features/projects/files/user_creates_files_spec.rb @@ -7,6 +7,7 @@ RSpec.describe 'Projects > Files > User creates files', :js do "You're not allowed to make changes to this project directly. "\ "A fork of this project has been created that you can make changes in, so you can submit a merge request." end + let(:project) { create(:project, :repository, name: 'Shop') } let(:project2) { create(:project, :repository, name: 'Another Project', path: 'another-project') } let(:project_tree_path_root_ref) { project_tree_path(project, project.repository.root_ref) } diff --git a/spec/features/projects/files/user_deletes_files_spec.rb b/spec/features/projects/files/user_deletes_files_spec.rb index 4df23b852ff..b6e300e9e59 100644 --- a/spec/features/projects/files/user_deletes_files_spec.rb +++ b/spec/features/projects/files/user_deletes_files_spec.rb @@ -7,6 +7,7 @@ RSpec.describe 'Projects > Files > User deletes files', :js do "You're not allowed to make changes to this project directly. "\ "A fork of this project has been created that you can make changes in, so you can submit a merge request." end + let(:project) { create(:project, :repository, name: 'Shop') } let(:project2) { create(:project, :repository, name: 'Another Project', path: 'another-project') } let(:project_tree_path_root_ref) { project_tree_path(project, project.repository.root_ref) } diff --git a/spec/features/projects/files/user_replaces_files_spec.rb b/spec/features/projects/files/user_replaces_files_spec.rb index b11cf732c95..c9b472260bd 100644 --- a/spec/features/projects/files/user_replaces_files_spec.rb +++ b/spec/features/projects/files/user_replaces_files_spec.rb @@ -9,6 +9,7 @@ RSpec.describe 'Projects > Files > User replaces files', :js do "You're not allowed to make changes to this project directly. "\ "A fork of this project has been created that you can make changes in, so you can submit a merge request." end + let(:project) { create(:project, :repository, name: 'Shop') } let(:project2) { create(:project, :repository, name: 'Another Project', path: 'another-project') } let(:project_tree_path_root_ref) { project_tree_path(project, project.repository.root_ref) } diff --git a/spec/features/projects/import_export/export_file_spec.rb b/spec/features/projects/import_export/export_file_spec.rb index 86aeb2bc80c..7f8ded4fa43 100644 --- a/spec/features/projects/import_export/export_file_spec.rb +++ b/spec/features/projects/import_export/export_file_spec.rb @@ -19,6 +19,7 @@ RSpec.describe 'Import/Export - project export integration test', :js do key: [Project, Ci::Variable, :yaml_variables] } end + let(:safe_hashes) { { yaml_variables: %w[key value public] } } let(:project) { setup_project } diff --git a/spec/features/projects/issues/viewing_issues_with_external_authorization_enabled_spec.rb b/spec/features/projects/issues/viewing_issues_with_external_authorization_enabled_spec.rb index 6feefff9207..b423543dc33 100644 --- a/spec/features/projects/issues/viewing_issues_with_external_authorization_enabled_spec.rb +++ b/spec/features/projects/issues/viewing_issues_with_external_authorization_enabled_spec.rb @@ -11,33 +11,39 @@ RSpec.describe 'viewing an issue with cross project references' do create(:project, :public, external_authorization_classification_label: 'other_label') end + let(:other_issue) do create(:issue, :closed, title: 'I am in another project', project: other_project) end + let(:other_confidential_issue) do create(:issue, :confidential, :closed, title: 'I am in another project and confidential', project: other_project) end + let(:other_merge_request) do create(:merge_request, :closed, title: 'I am a merge request in another project', source_project: other_project) end + let(:description_referencing_other_issue) do "Referencing: #{other_issue.to_reference(project)}, "\ "a confidential issue #{confidential_issue.to_reference}, "\ "a cross project confidential issue #{other_confidential_issue.to_reference(project)}, and "\ "a cross project merge request #{other_merge_request.to_reference(project)}" end + let(:project) { create(:project) } let(:issue) do create(:issue, project: project, description: description_referencing_other_issue ) end + let(:confidential_issue) do create(:issue, :confidential, :closed, title: "I am in the same project and confidential", diff --git a/spec/features/projects/pipelines/pipeline_spec.rb b/spec/features/projects/pipelines/pipeline_spec.rb index 70cc64e9308..974e702cd7c 100644 --- a/spec/features/projects/pipelines/pipeline_spec.rb +++ b/spec/features/projects/pipelines/pipeline_spec.rb @@ -137,6 +137,7 @@ RSpec.describe 'Pipeline', :js do source_project: project, source_branch: pipeline.ref) end + let!(:merge_request2) do create(:merge_request, source_project: project, diff --git a/spec/features/projects/wiki/user_views_wiki_pages_spec.rb b/spec/features/projects/wiki/user_views_wiki_pages_spec.rb index fea913b8212..4f29ae0cc8a 100644 --- a/spec/features/projects/wiki/user_views_wiki_pages_spec.rb +++ b/spec/features/projects/wiki/user_views_wiki_pages_spec.rb @@ -11,9 +11,11 @@ RSpec.describe 'User views wiki pages' do let!(:wiki_page1) do create(:wiki_page, wiki: project.wiki, title: '3 home', content: '3') end + let!(:wiki_page2) do create(:wiki_page, wiki: project.wiki, title: '1 home', content: '1') end + let!(:wiki_page3) do create(:wiki_page, wiki: project.wiki, title: '2 home', content: '2') end diff --git a/spec/finders/fork_targets_finder_spec.rb b/spec/finders/fork_targets_finder_spec.rb index 3c66f4e5757..7208f46cfff 100644 --- a/spec/finders/fork_targets_finder_spec.rb +++ b/spec/finders/fork_targets_finder_spec.rb @@ -10,15 +10,19 @@ RSpec.describe ForkTargetsFinder do let!(:maintained_group) do create(:group).tap { |g| g.add_maintainer(user) } end + let!(:owned_group) do create(:group).tap { |g| g.add_owner(user) } end + let!(:developer_group) do create(:group).tap { |g| g.add_developer(user) } end + let!(:reporter_group) do create(:group).tap { |g| g.add_reporter(user) } end + let!(:guest_group) do create(:group).tap { |g| g.add_guest(user) } end diff --git a/spec/frontend/fixtures/merge_requests.rb b/spec/frontend/fixtures/merge_requests.rb index 7801eb27ce8..6f281b26e6d 100644 --- a/spec/frontend/fixtures/merge_requests.rb +++ b/spec/frontend/fixtures/merge_requests.rb @@ -38,6 +38,7 @@ RSpec.describe Projects::MergeRequestsController, '(JavaScript fixtures)', type: sha: merge_request.diff_head_sha ) end + let(:path) { "files/ruby/popen.rb" } let(:position) do build(:text_diff_position, :added, diff --git a/spec/graphql/features/authorization_spec.rb b/spec/graphql/features/authorization_spec.rb index 6e5a8b9f4be..e40c44925e2 100644 --- a/spec/graphql/features/authorization_spec.rb +++ b/spec/graphql/features/authorization_spec.rb @@ -257,6 +257,7 @@ RSpec.describe 'Gitlab::Graphql::Authorization' do type.field :id, GraphQL::ID_TYPE, null: false end end + let(:project_type) do |type| type_factory do |type| type.graphql_name 'FakeProjectType' @@ -264,11 +265,13 @@ RSpec.describe 'Gitlab::Graphql::Authorization' do resolve: -> (_, _, _) { Issue.where(project: [visible_project, other_project]).order(id: :asc) } end end + let(:query_type) do query_factory do |query| query.field :test_project, project_type, null: false, resolve: -> (_, _, _) { visible_project } end end + let(:query_string) do <<~QRY { testProject { testIssues(first: 3) { edges { node { id } } } } } diff --git a/spec/graphql/mutations/issues/update_spec.rb b/spec/graphql/mutations/issues/update_spec.rb index 203816334e6..15c15afd9b7 100644 --- a/spec/graphql/mutations/issues/update_spec.rb +++ b/spec/graphql/mutations/issues/update_spec.rb @@ -19,6 +19,7 @@ RSpec.describe Mutations::Issues::Update do milestone_id: milestone.id } end + let(:mutation) { described_class.new(object: nil, context: { current_user: user }, field: nil) } let(:mutated_issue) { subject[:issue] } diff --git a/spec/graphql/resolvers/commit_pipelines_resolver_spec.rb b/spec/graphql/resolvers/commit_pipelines_resolver_spec.rb index 20a0cb842a4..a408981c08e 100644 --- a/spec/graphql/resolvers/commit_pipelines_resolver_spec.rb +++ b/spec/graphql/resolvers/commit_pipelines_resolver_spec.rb @@ -18,6 +18,7 @@ RSpec.describe Resolvers::CommitPipelinesResolver do status: 'success' ) end + let!(:pipeline2) do create( :ci_pipeline, @@ -27,6 +28,7 @@ RSpec.describe Resolvers::CommitPipelinesResolver do status: 'failed' ) end + let!(:pipeline3) do create( :ci_pipeline, diff --git a/spec/graphql/types/design_management/design_at_version_type_spec.rb b/spec/graphql/types/design_management/design_at_version_type_spec.rb index 5a6292c924a..4d61ecf62cc 100644 --- a/spec/graphql/types/design_management/design_at_version_type_spec.rb +++ b/spec/graphql/types/design_management/design_at_version_type_spec.rb @@ -10,6 +10,7 @@ RSpec.describe GitlabSchema.types['DesignAtVersion'] do version = design.versions.first GitlabSchema.id_from_object(create(:design_at_version, design: design, version: version)) end + let_it_be(:object_id_b) { GitlabSchema.id_from_object(create(:design_at_version)) } let(:object_type) { ::Types::DesignManagement::DesignAtVersionType } end diff --git a/spec/graphql/types/snippet_type_spec.rb b/spec/graphql/types/snippet_type_spec.rb index 0341ca2c733..86af69f1294 100644 --- a/spec/graphql/types/snippet_type_spec.rb +++ b/spec/graphql/types/snippet_type_spec.rb @@ -33,6 +33,7 @@ RSpec.describe GitlabSchema.types['Snippet'] do } ) end + let(:response) { subject.dig('data', 'snippets', 'nodes')[0] } subject { GitlabSchema.execute(query, context: { current_user: current_user }).as_json } @@ -97,6 +98,7 @@ RSpec.describe GitlabSchema.types['Snippet'] do } ) end + let(:response) { subject.dig('data', 'snippets', 'nodes')[0] } subject { GitlabSchema.execute(query, context: { current_user: user }).as_json } diff --git a/spec/helpers/blame_helper_spec.rb b/spec/helpers/blame_helper_spec.rb index 6371c2b63ce..d305c4c595e 100644 --- a/spec/helpers/blame_helper_spec.rb +++ b/spec/helpers/blame_helper_spec.rb @@ -11,6 +11,7 @@ RSpec.describe BlameHelper do Time.zone.local(2013, 2, 24, 0, 0, 0), Time.zone.local(2010, 9, 22, 0, 0, 0)] end + let(:blame_groups) do [ { commit: double(committed_date: dates[0]) }, @@ -57,6 +58,7 @@ RSpec.describe BlameHelper do project = double(created_at: now) helper.age_map_duration(today_blame_groups, project) end + let(:today_blame_groups) { [{ commit: double(committed_date: now) }] } let(:now) { Time.zone.now } diff --git a/spec/helpers/groups_helper_spec.rb b/spec/helpers/groups_helper_spec.rb index a739c16f3b1..0790dc1b674 100644 --- a/spec/helpers/groups_helper_spec.rb +++ b/spec/helpers/groups_helper_spec.rb @@ -114,12 +114,14 @@ RSpec.describe GroupsHelper do ancestor_locked_and_has_been_overridden: /This setting is applied on .+ and has been overridden on this subgroup/ } end + let(:possible_linked_ancestors) do { root_group: root_group, subgroup: subgroup } end + let(:users) do { root_owner: root_owner, diff --git a/spec/helpers/namespaces_helper_spec.rb b/spec/helpers/namespaces_helper_spec.rb index 1313a5c9352..1636ba6ef42 100644 --- a/spec/helpers/namespaces_helper_spec.rb +++ b/spec/helpers/namespaces_helper_spec.rb @@ -10,6 +10,7 @@ RSpec.describe NamespacesHelper do :private, project_creation_level: admin_project_creation_level) end + let!(:user) { create(:user) } let!(:user_project_creation_level) { nil } let!(:user_group) do @@ -17,18 +18,21 @@ RSpec.describe NamespacesHelper do :private, project_creation_level: user_project_creation_level) end + let!(:subgroup1) do create(:group, :private, parent: admin_group, project_creation_level: nil) end + let!(:subgroup2) do create(:group, :private, parent: admin_group, project_creation_level: ::Gitlab::Access::DEVELOPER_MAINTAINER_PROJECT_ACCESS) end + let!(:subgroup3) do create(:group, :private, diff --git a/spec/lib/api/entities/nuget/dependency_group_spec.rb b/spec/lib/api/entities/nuget/dependency_group_spec.rb index 5a649be846b..5e6de45adf2 100644 --- a/spec/lib/api/entities/nuget/dependency_group_spec.rb +++ b/spec/lib/api/entities/nuget/dependency_group_spec.rb @@ -34,6 +34,7 @@ RSpec.describe API::Entities::Nuget::DependencyGroup do ] } end + let(:entity) { described_class.new(dependency_group) } subject { entity.as_json } diff --git a/spec/lib/api/entities/nuget/dependency_spec.rb b/spec/lib/api/entities/nuget/dependency_spec.rb index 13897cc91f0..fb87b21bd1e 100644 --- a/spec/lib/api/entities/nuget/dependency_spec.rb +++ b/spec/lib/api/entities/nuget/dependency_spec.rb @@ -20,6 +20,7 @@ RSpec.describe API::Entities::Nuget::Dependency do 'range': '2.0.0' } end + let(:entity) { described_class.new(dependency) } subject { entity.as_json } diff --git a/spec/lib/api/entities/nuget/metadatum_spec.rb b/spec/lib/api/entities/nuget/metadatum_spec.rb index fe94ea3a69a..210ff0abdd3 100644 --- a/spec/lib/api/entities/nuget/metadatum_spec.rb +++ b/spec/lib/api/entities/nuget/metadatum_spec.rb @@ -10,6 +10,7 @@ RSpec.describe API::Entities::Nuget::Metadatum do icon_url: 'http://sandbox.com/icon' } end + let(:expected) do { 'projectUrl': 'http://sandbox.com/project', @@ -17,6 +18,7 @@ RSpec.describe API::Entities::Nuget::Metadatum do 'iconUrl': 'http://sandbox.com/icon' } end + let(:entity) { described_class.new(metadatum) } subject { entity.as_json } diff --git a/spec/lib/api/entities/nuget/search_result_spec.rb b/spec/lib/api/entities/nuget/search_result_spec.rb index 2a760c70224..a24cd44be9e 100644 --- a/spec/lib/api/entities/nuget/search_result_spec.rb +++ b/spec/lib/api/entities/nuget/search_result_spec.rb @@ -27,6 +27,7 @@ RSpec.describe API::Entities::Nuget::SearchResult do } } end + let(:expected) do { '@type': 'Package', diff --git a/spec/lib/banzai/filter/absolute_link_filter_spec.rb b/spec/lib/banzai/filter/absolute_link_filter_spec.rb index 2cb70850dca..0c159e8bac8 100644 --- a/spec/lib/banzai/filter/absolute_link_filter_spec.rb +++ b/spec/lib/banzai/filter/absolute_link_filter_spec.rb @@ -12,6 +12,7 @@ RSpec.describe Banzai::Filter::AbsoluteLinkFilter do let(:only_path_context) do { only_path: false } end + let(:fake_url) { 'http://www.example.com' } before do diff --git a/spec/lib/banzai/filter/merge_request_reference_filter_spec.rb b/spec/lib/banzai/filter/merge_request_reference_filter_spec.rb index f24fcf98b1f..df78a3321ba 100644 --- a/spec/lib/banzai/filter/merge_request_reference_filter_spec.rb +++ b/spec/lib/banzai/filter/merge_request_reference_filter_spec.rb @@ -220,6 +220,7 @@ RSpec.describe Banzai::Filter::MergeRequestReferenceFilter do let(:reference) do urls.project_merge_request_url(mr.project, mr) + "/diffs?commit_id=#{mr.diff_head_sha}" end + let(:commit) { mr.commits.find { |commit| commit.sha == mr.diff_head_sha } } it 'links to a valid reference' do diff --git a/spec/lib/banzai/issuable_extractor_spec.rb b/spec/lib/banzai/issuable_extractor_spec.rb index c4ee7160e12..8fec9691d7f 100644 --- a/spec/lib/banzai/issuable_extractor_spec.rb +++ b/spec/lib/banzai/issuable_extractor_spec.rb @@ -13,6 +13,7 @@ RSpec.describe Banzai::IssuableExtractor do "<a href='' data-issue='#{issue.id}' data-reference-type='issue' class='gfm'>text</a>" ) end + let(:merge_request_link) do html_to_node( "<a href='' data-merge-request='#{merge_request.id}' data-reference-type='merge_request' class='gfm'>text</a>" diff --git a/spec/lib/banzai/object_renderer_spec.rb b/spec/lib/banzai/object_renderer_spec.rb index f8d7acd3148..e64ab5dfce3 100644 --- a/spec/lib/banzai/object_renderer_spec.rb +++ b/spec/lib/banzai/object_renderer_spec.rb @@ -73,6 +73,7 @@ RSpec.describe Banzai::ObjectRenderer do end end end + let(:cacheless_thing) do cacheless_class.new.tap do |thing| thing.title = "Merge branch 'branch-merged' into 'master'" diff --git a/spec/lib/banzai/pipeline/full_pipeline_spec.rb b/spec/lib/banzai/pipeline/full_pipeline_spec.rb index 0127ac11c81..9391ca386cf 100644 --- a/spec/lib/banzai/pipeline/full_pipeline_spec.rb +++ b/spec/lib/banzai/pipeline/full_pipeline_spec.rb @@ -109,6 +109,7 @@ RSpec.describe Banzai::Pipeline::FullPipeline do # Header MARKDOWN end + let(:invalid_markdown) do <<-MARKDOWN.strip_heredoc test [[_TOC_]] diff --git a/spec/lib/container_registry/client_spec.rb b/spec/lib/container_registry/client_spec.rb index de92ca5eeec..aa947329c33 100644 --- a/spec/lib/container_registry/client_spec.rb +++ b/spec/lib/container_registry/client_spec.rb @@ -14,6 +14,7 @@ RSpec.describe ContainerRegistry::Client do 'User-Agent' => "GitLab/#{Gitlab::VERSION}" } end + let(:headers_with_accept_types) do { 'Accept' => 'application/vnd.docker.distribution.manifest.v2+json, application/vnd.oci.image.manifest.v1+json', diff --git a/spec/lib/gitlab/alert_management/alert_params_spec.rb b/spec/lib/gitlab/alert_management/alert_params_spec.rb index 393838ab042..1fe27365c83 100644 --- a/spec/lib/gitlab/alert_management/alert_params_spec.rb +++ b/spec/lib/gitlab/alert_management/alert_params_spec.rb @@ -18,6 +18,7 @@ RSpec.describe Gitlab::AlertManagement::AlertParams do 'some' => { 'extra' => { 'payload' => 'here' } } } end + let(:payload) { default_payload } subject { described_class.from_generic_alert(project: project, payload: payload) } @@ -75,6 +76,7 @@ RSpec.describe Gitlab::AlertManagement::AlertParams do 'fingerprint' => 'b6ac4d42057c43c1' } end + let(:parsed_alert) { Gitlab::Alerting::Alert.new(project: project, payload: payload) } subject { described_class.from_prometheus_alert(project: project, parsed_alert: parsed_alert) } diff --git a/spec/lib/gitlab/application_rate_limiter_spec.rb b/spec/lib/gitlab/application_rate_limiter_spec.rb index 14a7e25a2e8..2525b1ce41e 100644 --- a/spec/lib/gitlab/application_rate_limiter_spec.rb +++ b/spec/lib/gitlab/application_rate_limiter_spec.rb @@ -14,6 +14,7 @@ RSpec.describe Gitlab::ApplicationRateLimiter, :clean_gitlab_redis_cache do } } end + let(:key) { rate_limits.keys[0] } subject { described_class } diff --git a/spec/lib/gitlab/asciidoc/include_processor_spec.rb b/spec/lib/gitlab/asciidoc/include_processor_spec.rb index 067dcefb525..5c225575965 100644 --- a/spec/lib/gitlab/asciidoc/include_processor_spec.rb +++ b/spec/lib/gitlab/asciidoc/include_processor_spec.rb @@ -13,6 +13,7 @@ RSpec.describe Gitlab::Asciidoc::IncludeProcessor do ref: ref } end + let(:ref) { project.repository.root_ref } let(:max_includes) { 10 } diff --git a/spec/lib/gitlab/asciidoc_spec.rb b/spec/lib/gitlab/asciidoc_spec.rb index b28d4e8d5a5..1b669e691e7 100644 --- a/spec/lib/gitlab/asciidoc_spec.rb +++ b/spec/lib/gitlab/asciidoc_spec.rb @@ -473,6 +473,7 @@ module Gitlab requested_path: requested_path } end + let(:commit) { project.commit(ref) } let(:project) { create(:project, :repository) } let(:ref) { 'asciidoc' } diff --git a/spec/lib/gitlab/auth/auth_finders_spec.rb b/spec/lib/gitlab/auth/auth_finders_spec.rb index d98f8a4507d..a73ac0b34af 100644 --- a/spec/lib/gitlab/auth/auth_finders_spec.rb +++ b/spec/lib/gitlab/auth/auth_finders_spec.rb @@ -12,6 +12,7 @@ RSpec.describe Gitlab::Auth::AuthFinders do 'rack.input' => '' } end + let(:request) { ActionDispatch::Request.new(env) } def set_param(key, value) diff --git a/spec/lib/gitlab/auth/ldap/user_spec.rb b/spec/lib/gitlab/auth/ldap/user_spec.rb index 7ca2878e583..ccaed94b5c8 100644 --- a/spec/lib/gitlab/auth/ldap/user_spec.rb +++ b/spec/lib/gitlab/auth/ldap/user_spec.rb @@ -14,9 +14,11 @@ RSpec.describe Gitlab::Auth::Ldap::User do nickname: 'john' } end + let(:auth_hash) do OmniAuth::AuthHash.new(uid: 'uid=John Smith,ou=People,dc=example,dc=com', provider: 'ldapmain', info: info) end + let(:ldap_user_upper_case) { described_class.new(auth_hash_upper_case) } let(:info_upper_case) do { @@ -25,6 +27,7 @@ RSpec.describe Gitlab::Auth::Ldap::User do nickname: 'john' } end + let(:auth_hash_upper_case) do OmniAuth::AuthHash.new(uid: 'uid=John Smith,ou=People,dc=example,dc=com', provider: 'ldapmain', info: info_upper_case) end diff --git a/spec/lib/gitlab/auth/o_auth/auth_hash_spec.rb b/spec/lib/gitlab/auth/o_auth/auth_hash_spec.rb index 7a60acca95b..67ffdee0c4a 100644 --- a/spec/lib/gitlab/auth/o_auth/auth_hash_spec.rb +++ b/spec/lib/gitlab/auth/o_auth/auth_hash_spec.rb @@ -17,6 +17,7 @@ RSpec.describe Gitlab::Auth::OAuth::AuthHash do let(:uid_raw) do +"CN=Onur K\xC3\xBC\xC3\xA7\xC3\xBCk,OU=Test,DC=example,DC=net" end + let(:email_raw) { +"onur.k\xC3\xBC\xC3\xA7\xC3\xBCk_ABC-123@example.net" } let(:nickname_raw) { +"ok\xC3\xBC\xC3\xA7\xC3\xBCk" } let(:first_name_raw) { +'Onur' } diff --git a/spec/lib/gitlab/auth/o_auth/user_spec.rb b/spec/lib/gitlab/auth/o_auth/user_spec.rb index ad04fddc675..cc9e3b957e3 100644 --- a/spec/lib/gitlab/auth/o_auth/user_spec.rb +++ b/spec/lib/gitlab/auth/o_auth/user_spec.rb @@ -22,6 +22,7 @@ RSpec.describe Gitlab::Auth::OAuth::User do } } end + let(:ldap_user) { Gitlab::Auth::Ldap::Person.new(Net::LDAP::Entry.new, 'ldapmain') } describe '#persisted?' do diff --git a/spec/lib/gitlab/auth/request_authenticator_spec.rb b/spec/lib/gitlab/auth/request_authenticator_spec.rb index 32d64519e2c..ef83321cc0e 100644 --- a/spec/lib/gitlab/auth/request_authenticator_spec.rb +++ b/spec/lib/gitlab/auth/request_authenticator_spec.rb @@ -9,6 +9,7 @@ RSpec.describe Gitlab::Auth::RequestAuthenticator do 'REQUEST_METHOD' => 'GET' } end + let(:request) { ActionDispatch::Request.new(env) } subject { described_class.new(request) } diff --git a/spec/lib/gitlab/auth/saml/user_spec.rb b/spec/lib/gitlab/auth/saml/user_spec.rb index 7f8346f0486..fd48492f18d 100644 --- a/spec/lib/gitlab/auth/saml/user_spec.rb +++ b/spec/lib/gitlab/auth/saml/user_spec.rb @@ -19,6 +19,7 @@ RSpec.describe Gitlab::Auth::Saml::User do email: 'john@mail.com' } end + let(:ldap_user) { Gitlab::Auth::Ldap::Person.new(Net::LDAP::Entry.new, 'ldapmain') } describe '#save' do @@ -194,6 +195,7 @@ RSpec.describe Gitlab::Auth::Saml::User do } } end + let(:auth_hash) { OmniAuth::AuthHash.new(auth_hash_base_attributes) } let(:uid_types) { %w(uid dn email) } diff --git a/spec/lib/gitlab/auth_spec.rb b/spec/lib/gitlab/auth_spec.rb index a73c6317f31..83bba3cec04 100644 --- a/spec/lib/gitlab/auth_spec.rb +++ b/spec/lib/gitlab/auth_spec.rb @@ -631,6 +631,7 @@ RSpec.describe Gitlab::Auth, :use_clean_rails_memory_store_caching do password: password, password_confirmation: password) end + let(:username) { 'John' } # username isn't lowercase, test this let(:password) { 'my-secret' } diff --git a/spec/lib/gitlab/background_migration/backfill_snippet_repositories_spec.rb b/spec/lib/gitlab/background_migration/backfill_snippet_repositories_spec.rb index ec2fd3cc4e0..fad33265030 100644 --- a/spec/lib/gitlab/background_migration/backfill_snippet_repositories_spec.rb +++ b/spec/lib/gitlab/background_migration/backfill_snippet_repositories_spec.rb @@ -264,6 +264,7 @@ RSpec.describe Gitlab::BackgroundMigration::BackfillSnippetRepositories, :migrat user_type: user_type, confirmed_at: 1.day.ago) end + let!(:invalid_snippet) { snippets.create(id: 4, type: 'PersonalSnippet', author_id: user.id, file_name: '.', content: content) } let!(:snippet) { snippets.create(id: 5, type: 'PersonalSnippet', author_id: other_user.id, file_name: file_name, content: content) } let(:ids) { [4, 5] } diff --git a/spec/lib/gitlab/background_migration/legacy_upload_mover_spec.rb b/spec/lib/gitlab/background_migration/legacy_upload_mover_spec.rb index bf793e7c537..1637589d272 100644 --- a/spec/lib/gitlab/background_migration/legacy_upload_mover_spec.rb +++ b/spec/lib/gitlab/background_migration/legacy_upload_mover_spec.rb @@ -264,6 +264,7 @@ RSpec.describe Gitlab::BackgroundMigration::LegacyUploadMover do let(:remote_file) do { key: "#{legacy_upload.path}" } end + let(:connection) { ::Fog::Storage.new(FileUploader.object_store_credentials) } let(:bucket) { connection.directories.create(key: 'uploads') } diff --git a/spec/lib/gitlab/background_migration/migrate_issue_trackers_sensitive_data_spec.rb b/spec/lib/gitlab/background_migration/migrate_issue_trackers_sensitive_data_spec.rb index d53f79c61c1..d829fd5daf5 100644 --- a/spec/lib/gitlab/background_migration/migrate_issue_trackers_sensitive_data_spec.rb +++ b/spec/lib/gitlab/background_migration/migrate_issue_trackers_sensitive_data_spec.rb @@ -286,9 +286,11 @@ RSpec.describe Gitlab::BackgroundMigration::MigrateIssueTrackersSensitiveData, s let!(:jira_service_invalid) do services.create(id: 19, title: 'invalid - title', description: 'invalid - description', type: 'JiraService', properties: 'invalid data', category: 'issue_tracker') end + let!(:jira_service_valid) do services.create(id: 20, type: 'JiraService', properties: jira_properties.to_json, category: 'issue_tracker') end + let!(:bugzilla_service_valid) do services.create(id: 11, type: 'BugzillaService', title: nil, properties: tracker_properties.to_json, category: 'issue_tracker') end diff --git a/spec/lib/gitlab/background_migration_spec.rb b/spec/lib/gitlab/background_migration_spec.rb index b110fa484ff..052a01a8dd8 100644 --- a/spec/lib/gitlab/background_migration_spec.rb +++ b/spec/lib/gitlab/background_migration_spec.rb @@ -130,6 +130,7 @@ RSpec.describe Gitlab::BackgroundMigration do let(:retry_queue) do [double(args: ['Object', [3]], queue: described_class.queue, delete: true)] end + let(:dead_queue) do [double(args: ['Object', [4]], queue: described_class.queue, delete: true)] end diff --git a/spec/lib/gitlab/bitbucket_import/importer_spec.rb b/spec/lib/gitlab/bitbucket_import/importer_spec.rb index 08b7bafddf0..d4483bf1754 100644 --- a/spec/lib/gitlab/bitbucket_import/importer_spec.rb +++ b/spec/lib/gitlab/bitbucket_import/importer_spec.rb @@ -87,6 +87,7 @@ RSpec.describe Gitlab::BitbucketImport::Importer do values: sample_issues_statuses } end + let(:counter) { double('counter', increment: true) } subject { described_class.new(project) } @@ -109,6 +110,7 @@ RSpec.describe Gitlab::BitbucketImport::Importer do created_at: Time.now, updated_at: Time.now) end + let(:author_line) { "*Created by: someuser*\n\n" } before do diff --git a/spec/lib/gitlab/ci/ansi2html_spec.rb b/spec/lib/gitlab/ci/ansi2html_spec.rb index f29a39e4e66..bf1f2bae7da 100644 --- a/spec/lib/gitlab/ci/ansi2html_spec.rb +++ b/spec/lib/gitlab/ci/ansi2html_spec.rb @@ -213,6 +213,7 @@ RSpec.describe Gitlab::Ci::Ansi2html do " data-timestamp=\"#{section_start_time.to_i}\" data-section=\"#{class_name(section_name)}\"" \ ' role="button"></div>' end + let(:section_end_html) do "<div class=\"section-end\" data-section=\"#{class_name(section_name)}\"></div>" end diff --git a/spec/lib/gitlab/ci/config/entry/service_spec.rb b/spec/lib/gitlab/ci/config/entry/service_spec.rb index 9fbc14c19b9..ec137ef2ae4 100644 --- a/spec/lib/gitlab/ci/config/entry/service_spec.rb +++ b/spec/lib/gitlab/ci/config/entry/service_spec.rb @@ -95,6 +95,7 @@ RSpec.describe Gitlab::Ci::Config::Entry::Service do let(:config) do { name: 'postgresql:9.5', alias: 'db', command: %w(cmd run), entrypoint: %w(/bin/sh run), ports: ports } end + let(:entry) { described_class.new(config, { with_image_ports: image_ports }) } let(:image_ports) { false } diff --git a/spec/lib/gitlab/ci/config/external/file/local_spec.rb b/spec/lib/gitlab/ci/config/external/file/local_spec.rb index 993a07568de..fdd29afe2d6 100644 --- a/spec/lib/gitlab/ci/config/external/file/local_spec.rb +++ b/spec/lib/gitlab/ci/config/external/file/local_spec.rb @@ -92,6 +92,7 @@ RSpec.describe Gitlab::Ci::Config::External::File::Local do - bundle install --jobs $(nproc) "${FLAGS[@]}" HEREDOC end + let(:location) { '/lib/gitlab/ci/templates/existent-file.yml' } before do diff --git a/spec/lib/gitlab/ci/config/external/processor_spec.rb b/spec/lib/gitlab/ci/config/external/processor_spec.rb index b2cf36b2597..9786e050399 100644 --- a/spec/lib/gitlab/ci/config/external/processor_spec.rb +++ b/spec/lib/gitlab/ci/config/external/processor_spec.rb @@ -128,6 +128,7 @@ RSpec.describe Gitlab::Ci::Config::External::Processor do remote_file ] end + let(:values) do { include: external_files, diff --git a/spec/lib/gitlab/ci/pipeline/chain/validate/repository_spec.rb b/spec/lib/gitlab/ci/pipeline/chain/validate/repository_spec.rb index 1dc2e0a1822..7eefb4d7876 100644 --- a/spec/lib/gitlab/ci/pipeline/chain/validate/repository_spec.rb +++ b/spec/lib/gitlab/ci/pipeline/chain/validate/repository_spec.rb @@ -68,6 +68,7 @@ RSpec.describe Gitlab::Ci::Pipeline::Chain::Validate::Repository do proj.repository.add_tag(user, 'master', 'master') end end + let(:command) do Gitlab::Ci::Pipeline::Chain::Command.new( project: project, current_user: user, origin_ref: 'master') diff --git a/spec/lib/gitlab/ci/reports/accessibility_reports_comparer_spec.rb b/spec/lib/gitlab/ci/reports/accessibility_reports_comparer_spec.rb index 240ede790e0..650ae41320b 100644 --- a/spec/lib/gitlab/ci/reports/accessibility_reports_comparer_spec.rb +++ b/spec/lib/gitlab/ci/reports/accessibility_reports_comparer_spec.rb @@ -21,6 +21,7 @@ RSpec.describe Gitlab::Ci::Reports::AccessibilityReportsComparer do } ] end + let(:different_error) do [ { diff --git a/spec/lib/gitlab/ci/yaml_processor_spec.rb b/spec/lib/gitlab/ci/yaml_processor_spec.rb index 80ec67e8cd5..1c81cc83cd1 100644 --- a/spec/lib/gitlab/ci/yaml_processor_spec.rb +++ b/spec/lib/gitlab/ci/yaml_processor_spec.rb @@ -942,6 +942,7 @@ module Gitlab let(:variables) do { 'VAR1' => 'value1', 'VAR2' => 'value2' } end + let(:config) do { variables: variables, @@ -962,9 +963,11 @@ module Gitlab let(:global_variables) do { 'VAR1' => 'global1', 'VAR3' => 'global3', 'VAR4' => 'global4' } end + let(:job_variables) do { 'VAR1' => 'value1', 'VAR2' => 'value2' } end + let(:config) do { before_script: ['pwd'], @@ -2073,6 +2076,7 @@ module Gitlab { job: "build2" } ] end + let(:dependencies) { %w(build3) } it { expect { subject }.to raise_error(Gitlab::Ci::YamlProcessor::ValidationError, 'jobs:test1 dependencies the build3 should be part of needs') } diff --git a/spec/lib/gitlab/cleanup/remote_uploads_spec.rb b/spec/lib/gitlab/cleanup/remote_uploads_spec.rb index 1752608f844..c59b7f004dd 100644 --- a/spec/lib/gitlab/cleanup/remote_uploads_spec.rb +++ b/spec/lib/gitlab/cleanup/remote_uploads_spec.rb @@ -11,6 +11,7 @@ RSpec.describe Gitlab::Cleanup::RemoteUploads do create(:upload, path: 'dir/file2', store: ObjectStorage::Store::LOCAL) ] end + let(:remote_files) do [ double(key: 'dir/file1'), diff --git a/spec/lib/gitlab/cross_project_access/class_methods_spec.rb b/spec/lib/gitlab/cross_project_access/class_methods_spec.rb index cc2c431fc07..afc45c86362 100644 --- a/spec/lib/gitlab/cross_project_access/class_methods_spec.rb +++ b/spec/lib/gitlab/cross_project_access/class_methods_spec.rb @@ -8,6 +8,7 @@ RSpec.describe Gitlab::CrossProjectAccess::ClassMethods do extend Gitlab::CrossProjectAccess::ClassMethods end end + let(:dummy_proc) { lambda { false } } describe '#requires_cross_project_access' do diff --git a/spec/lib/gitlab/danger/commit_linter_spec.rb b/spec/lib/gitlab/danger/commit_linter_spec.rb index 06bec6f793d..c31522c538d 100644 --- a/spec/lib/gitlab/danger/commit_linter_spec.rb +++ b/spec/lib/gitlab/danger/commit_linter_spec.rb @@ -16,6 +16,7 @@ RSpec.describe Gitlab::Danger::CommitLinter do let(:commit_class) do Struct.new(:message, :sha, :diff_parent) end + let(:commit_message) { 'A commit message' } let(:commit_sha) { 'abcd1234' } let(:commit) { commit_class.new(commit_message, commit_sha, diff_parent) } diff --git a/spec/lib/gitlab/danger/roulette_spec.rb b/spec/lib/gitlab/danger/roulette_spec.rb index 9517b0a8f63..b471e17e2e7 100644 --- a/spec/lib/gitlab/danger/roulette_spec.rb +++ b/spec/lib/gitlab/danger/roulette_spec.rb @@ -22,6 +22,7 @@ RSpec.describe Gitlab::Danger::Roulette do 'tz_offset_hours' => backend_tz_offset_hours ) end + let(:frontend_reviewer) do Gitlab::Danger::Teammate.new( 'username' => 'frontend-reviewer', @@ -32,6 +33,7 @@ RSpec.describe Gitlab::Danger::Roulette do 'tz_offset_hours' => 2.0 ) end + let(:frontend_maintainer) do Gitlab::Danger::Teammate.new( 'username' => 'frontend-maintainer', @@ -42,6 +44,7 @@ RSpec.describe Gitlab::Danger::Roulette do 'tz_offset_hours' => 2.0 ) end + let(:software_engineer_in_test) do Gitlab::Danger::Teammate.new( 'username' => 'software-engineer-in-test', @@ -52,6 +55,7 @@ RSpec.describe Gitlab::Danger::Roulette do 'tz_offset_hours' => 2.0 ) end + let(:engineering_productivity_reviewer) do Gitlab::Danger::Teammate.new( 'username' => 'eng-prod-reviewer', @@ -296,18 +300,21 @@ RSpec.describe Gitlab::Danger::Roulette do 'tz_offset_hours' => person_tz_offset_hours ) end + let(:person2) do Gitlab::Danger::Teammate.new( 'username' => 'user2', 'available' => true, 'tz_offset_hours' => person_tz_offset_hours) end + let(:author) do Gitlab::Danger::Teammate.new( 'username' => 'johndoe', 'available' => true, 'tz_offset_hours' => 0.0) end + let(:unavailable) do Gitlab::Danger::Teammate.new( 'username' => 'janedoe', diff --git a/spec/lib/gitlab/danger/teammate_spec.rb b/spec/lib/gitlab/danger/teammate_spec.rb index 82bed5073db..12819614fab 100644 --- a/spec/lib/gitlab/danger/teammate_spec.rb +++ b/spec/lib/gitlab/danger/teammate_spec.rb @@ -20,6 +20,7 @@ RSpec.describe Gitlab::Danger::Teammate do 'tz_offset_hours' => tz_offset_hours } end + let(:capabilities) { ['reviewer backend'] } let(:projects) { { project => capabilities } } let(:role) { 'Engineer, Manage' } diff --git a/spec/lib/gitlab/database/count/tablesample_count_strategy_spec.rb b/spec/lib/gitlab/database/count/tablesample_count_strategy_spec.rb index e488bf5ee4c..c2028f8c238 100644 --- a/spec/lib/gitlab/database/count/tablesample_count_strategy_spec.rb +++ b/spec/lib/gitlab/database/count/tablesample_count_strategy_spec.rb @@ -23,6 +23,7 @@ RSpec.describe Gitlab::Database::Count::TablesampleCountStrategy do Namespace => threshold + 1 } end + let(:threshold) { Gitlab::Database::Count::TablesampleCountStrategy::EXACT_COUNT_THRESHOLD } before do diff --git a/spec/lib/gitlab/database/custom_structure_spec.rb b/spec/lib/gitlab/database/custom_structure_spec.rb index beda9df3684..b3bdca0acdd 100644 --- a/spec/lib/gitlab/database/custom_structure_spec.rb +++ b/spec/lib/gitlab/database/custom_structure_spec.rb @@ -32,6 +32,7 @@ RSpec.describe Gitlab::Database::CustomStructure do Gitlab::Database::PartitioningMigrationHelpers::PartitionedForeignKey.create( cascade_delete: true, from_table: 'issues', from_column: 'project_id', to_table: 'projects', to_column: 'id') end + let!(:second_fk) do Gitlab::Database::PartitioningMigrationHelpers::PartitionedForeignKey.create( cascade_delete: false, from_table: 'issues', from_column: 'moved_to_id', to_table: 'issues', to_column: 'id') diff --git a/spec/lib/gitlab/database/partitioning_migration_helpers/foreign_key_helpers_spec.rb b/spec/lib/gitlab/database/partitioning_migration_helpers/foreign_key_helpers_spec.rb index efa9c83b2d2..7d88c17c9b3 100644 --- a/spec/lib/gitlab/database/partitioning_migration_helpers/foreign_key_helpers_spec.rb +++ b/spec/lib/gitlab/database/partitioning_migration_helpers/foreign_key_helpers_spec.rb @@ -8,6 +8,7 @@ RSpec.describe Gitlab::Database::PartitioningMigrationHelpers::ForeignKeyHelpers let(:model) do ActiveRecord::Migration.new.extend(described_class) end + let_it_be(:connection) { ActiveRecord::Base.connection } let(:referenced_table) { :issues } let(:function_name) { '_test_partitioned_foreign_keys_function' } diff --git a/spec/lib/gitlab/database/partitioning_migration_helpers/table_management_helpers_spec.rb b/spec/lib/gitlab/database/partitioning_migration_helpers/table_management_helpers_spec.rb index 995b598e7b3..86f79b213ae 100644 --- a/spec/lib/gitlab/database/partitioning_migration_helpers/table_management_helpers_spec.rb +++ b/spec/lib/gitlab/database/partitioning_migration_helpers/table_management_helpers_spec.rb @@ -321,6 +321,7 @@ RSpec.describe Gitlab::Database::PartitioningMigrationHelpers::TableManagementHe let(:expected_tables) do %w[000000 201912 202001 202002].map { |suffix| "#{Gitlab::Database::DYNAMIC_PARTITIONS_SCHEMA}.#{partitioned_table}_#{suffix}" }.unshift(partitioned_table) end + let(:migration_class) { 'Gitlab::Database::PartitioningMigrationHelpers::BackfillPartitionedTable' } context 'when the table is not allowed' do diff --git a/spec/lib/gitlab/database/postgresql_adapter/force_disconnectable_mixin_spec.rb b/spec/lib/gitlab/database/postgresql_adapter/force_disconnectable_mixin_spec.rb index 8b3a0ceb804..ea8c9e2cfd7 100644 --- a/spec/lib/gitlab/database/postgresql_adapter/force_disconnectable_mixin_spec.rb +++ b/spec/lib/gitlab/database/postgresql_adapter/force_disconnectable_mixin_spec.rb @@ -13,6 +13,7 @@ RSpec.describe Gitlab::Database::PostgresqlAdapter::ForceDisconnectableMixin do end end end + let(:config) { Rails.application.config_for(:database).merge(pool: 1) } let(:pool) { model.establish_connection(config) } diff --git a/spec/lib/gitlab/diff/file_collection/commit_spec.rb b/spec/lib/gitlab/diff/file_collection/commit_spec.rb index 6c109e96a53..7773604a638 100644 --- a/spec/lib/gitlab/diff/file_collection/commit_spec.rb +++ b/spec/lib/gitlab/diff/file_collection/commit_spec.rb @@ -9,6 +9,7 @@ RSpec.describe Gitlab::Diff::FileCollection::Commit do let(:collection_default_args) do { diff_options: {} } end + let(:diffable) { project.commit } let(:stub_path) { 'bar/branch-test.txt' } end diff --git a/spec/lib/gitlab/diff/file_collection/compare_spec.rb b/spec/lib/gitlab/diff/file_collection/compare_spec.rb index 168d58e584e..dda4513a3a1 100644 --- a/spec/lib/gitlab/diff/file_collection/compare_spec.rb +++ b/spec/lib/gitlab/diff/file_collection/compare_spec.rb @@ -23,6 +23,7 @@ RSpec.describe Gitlab::Diff::FileCollection::Compare do diff_refs: diffable.diff_refs } end + let(:diffable) { Compare.new(raw_compare, project) } let(:stub_path) { '.gitignore' } end diff --git a/spec/lib/gitlab/diff/file_collection/merge_request_diff_spec.rb b/spec/lib/gitlab/diff/file_collection/merge_request_diff_spec.rb index a5e714c90fc..429e552278d 100644 --- a/spec/lib/gitlab/diff/file_collection/merge_request_diff_spec.rb +++ b/spec/lib/gitlab/diff/file_collection/merge_request_diff_spec.rb @@ -42,6 +42,7 @@ RSpec.describe Gitlab::Diff::FileCollection::MergeRequestDiff do let(:collection_default_args) do { diff_options: {} } end + let(:diffable) { merge_request.merge_request_diff } let(:stub_path) { '.gitignore' } end diff --git a/spec/lib/gitlab/diff/file_spec.rb b/spec/lib/gitlab/diff/file_spec.rb index 94abfcf079a..78be89c449b 100644 --- a/spec/lib/gitlab/diff/file_spec.rb +++ b/spec/lib/gitlab/diff/file_spec.rb @@ -800,6 +800,7 @@ RSpec.describe Gitlab::Diff::File do let(:project) do create(:project, :custom_repo, files: {}) end + let(:branch_name) { 'master' } context 'when empty file is created' do @@ -842,6 +843,7 @@ RSpec.describe Gitlab::Diff::File do let(:project) do create(:project, :custom_repo, files: {}) end + let(:branch_name) { 'master' } context 'when empty file is created' do diff --git a/spec/lib/gitlab/diff/position_collection_spec.rb b/spec/lib/gitlab/diff/position_collection_spec.rb index b1478c774f1..d2bb82983c0 100644 --- a/spec/lib/gitlab/diff/position_collection_spec.rb +++ b/spec/lib/gitlab/diff/position_collection_spec.rb @@ -8,9 +8,11 @@ RSpec.describe Gitlab::Diff::PositionCollection do let(:text_position) do build(:text_diff_position, :added, diff_refs: diff_refs) end + let(:folded_text_position) do build(:text_diff_position, diff_refs: diff_refs, old_line: 1, new_line: 1) end + let(:image_position) do build(:image_diff_position, diff_refs: diff_refs) end diff --git a/spec/lib/gitlab/diff/suggestion_spec.rb b/spec/lib/gitlab/diff/suggestion_spec.rb index 5a5c5555818..40779faf917 100644 --- a/spec/lib/gitlab/diff/suggestion_spec.rb +++ b/spec/lib/gitlab/diff/suggestion_spec.rb @@ -31,9 +31,11 @@ RSpec.describe Gitlab::Diff::Suggestion do new_line: 9, diff_refs: merge_request.diff_refs) end + let(:diff_file) do position.diff_file(project.repository) end + let(:text) { "# parsed suggestion content\n# with comments" } def blob_lines_data(from_line, to_line) diff --git a/spec/lib/gitlab/email/message/repository_push_spec.rb b/spec/lib/gitlab/email/message/repository_push_spec.rb index 10586527239..6b1f03e0385 100644 --- a/spec/lib/gitlab/email/message/repository_push_spec.rb +++ b/spec/lib/gitlab/email/message/repository_push_spec.rb @@ -18,10 +18,12 @@ RSpec.describe Gitlab::Email::Message::RepositoryPush do { author_id: author.id, ref: 'master', action: :push, compare: compare, send_from_committer_email: true } end + let(:raw_compare) do Gitlab::Git::Compare.new(project.repository.raw_repository, sample_image_commit.id, sample_commit.id) end + let(:compare) do Compare.decorate(raw_compare, project) end diff --git a/spec/lib/gitlab/encoding_helper_spec.rb b/spec/lib/gitlab/encoding_helper_spec.rb index 5394c04c6ba..0ea974921bc 100644 --- a/spec/lib/gitlab/encoding_helper_spec.rb +++ b/spec/lib/gitlab/encoding_helper_spec.rb @@ -138,6 +138,7 @@ RSpec.describe Gitlab::EncodingHelper do let(:test_string) do "refs/heads/FixSymbolsTitleDropdown".encode("ASCII-8BIT") end + let(:expected_string) do "refs/heads/FixSymbolsTitleDropdown".encode("UTF-8") end diff --git a/spec/lib/gitlab/fogbugz_import/importer_spec.rb b/spec/lib/gitlab/fogbugz_import/importer_spec.rb index d2be3e3f6b1..eb0c4da6ce3 100644 --- a/spec/lib/gitlab/fogbugz_import/importer_spec.rb +++ b/spec/lib/gitlab/fogbugz_import/importer_spec.rb @@ -11,6 +11,7 @@ RSpec.describe Gitlab::FogbugzImport::Importer do path: 'vim', raw_data: '') end + let(:import_data) { { 'repo' => repo } } let(:credentials) do { diff --git a/spec/lib/gitlab/git/branch_spec.rb b/spec/lib/gitlab/git/branch_spec.rb index bac1b4c57f9..e1bcf4aeeb1 100644 --- a/spec/lib/gitlab/git/branch_spec.rb +++ b/spec/lib/gitlab/git/branch_spec.rb @@ -84,6 +84,7 @@ RSpec.describe Gitlab::Git::Branch, :seed_helper do parents: parents } end + let(:stale_sha) { Timecop.freeze(Gitlab::Git::Branch::STALE_BRANCH_THRESHOLD.ago - 5.days) { create_commit } } let(:active_sha) { Timecop.freeze(Gitlab::Git::Branch::STALE_BRANCH_THRESHOLD.ago + 5.days) { create_commit } } let(:future_sha) { Timecop.freeze(100.days.since) { create_commit } } diff --git a/spec/lib/gitlab/git/commit_spec.rb b/spec/lib/gitlab/git/commit_spec.rb index 666b49f27f7..491437856d4 100644 --- a/spec/lib/gitlab/git/commit_spec.rb +++ b/spec/lib/gitlab/git/commit_spec.rb @@ -9,6 +9,7 @@ RSpec.describe Gitlab::Git::Commit, :seed_helper do let(:rugged_repo) do Rugged::Repository.new(File.join(TestEnv.repos_path, TEST_REPO_PATH)) end + let(:commit) { described_class.find(repository, SeedRepo::Commit::ID) } let(:rugged_commit) { rugged_repo.lookup(SeedRepo::Commit::ID) } diff --git a/spec/lib/gitlab/git/conflict/parser_spec.rb b/spec/lib/gitlab/git/conflict/parser_spec.rb index 67bd48256ce..02b00f711b4 100644 --- a/spec/lib/gitlab/git/conflict/parser_spec.rb +++ b/spec/lib/gitlab/git/conflict/parser_spec.rb @@ -89,12 +89,15 @@ RSpec.describe Gitlab::Git::Conflict::Parser do let(:lines) do described_class.parse(text, our_path: 'files/ruby/regex.rb', their_path: 'files/ruby/regex.rb') end + let(:old_line_numbers) do lines.select { |line| line[:type] != 'new' }.map { |line| line[:line_old] } end + let(:new_line_numbers) do lines.select { |line| line[:type] != 'old' }.map { |line| line[:line_new] } end + let(:line_indexes) { lines.map { |line| line[:line_obj_index] } } it 'sets our lines as new lines' do diff --git a/spec/lib/gitlab/git/diff_spec.rb b/spec/lib/gitlab/git/diff_spec.rb index 91688c31f5e..117c519e98d 100644 --- a/spec/lib/gitlab/git/diff_spec.rb +++ b/spec/lib/gitlab/git/diff_spec.rb @@ -78,6 +78,7 @@ EOT patch: raw_patch ) end + let(:diff) { described_class.new(gitaly_diff) } context 'with a small diff' do @@ -134,6 +135,7 @@ EOT to_id: '8e5177d718c561d36efde08bad36b43687ee6bf0' ) end + let(:diff) { described_class.new(commit_delta) } it 'initializes the diff' do diff --git a/spec/lib/gitlab/git/patches/collection_spec.rb b/spec/lib/gitlab/git/patches/collection_spec.rb index eb92f4663c8..67a502242ea 100644 --- a/spec/lib/gitlab/git/patches/collection_spec.rb +++ b/spec/lib/gitlab/git/patches/collection_spec.rb @@ -6,6 +6,7 @@ RSpec.describe Gitlab::Git::Patches::Collection do let(:patch_content1) do File.read(File.join(patches_folder, "0001-This-does-not-apply-to-the-feature-branch.patch")) end + let(:patch_content2) do File.read(File.join(patches_folder, "0001-A-commit-from-a-patch.patch")) end diff --git a/spec/lib/gitlab/git/patches/commit_patches_spec.rb b/spec/lib/gitlab/git/patches/commit_patches_spec.rb index cd1e03a6de0..9ab0893eb55 100644 --- a/spec/lib/gitlab/git/patches/commit_patches_spec.rb +++ b/spec/lib/gitlab/git/patches/commit_patches_spec.rb @@ -10,6 +10,7 @@ RSpec.describe Gitlab::Git::Patches::CommitPatches do Gitlab::Git::Patches::Collection.new([content_1, content_2]) end + let(:user) { build(:user) } let(:branch_name) { 'branch-with-patches' } let(:repository) { create(:project, :repository).repository } diff --git a/spec/lib/gitlab/git/patches/patch_spec.rb b/spec/lib/gitlab/git/patches/patch_spec.rb index 629f43d3636..6588b18d0ae 100644 --- a/spec/lib/gitlab/git/patches/patch_spec.rb +++ b/spec/lib/gitlab/git/patches/patch_spec.rb @@ -6,6 +6,7 @@ RSpec.describe Gitlab::Git::Patches::Patch do let(:patch_content) do File.read(File.join(patches_folder, "0001-This-does-not-apply-to-the-feature-branch.patch")) end + let(:patch) { described_class.new(patch_content) } describe '#size' do diff --git a/spec/lib/gitlab/git/repository_spec.rb b/spec/lib/gitlab/git/repository_spec.rb index e7f4573c95f..73eecd3401a 100644 --- a/spec/lib/gitlab/git/repository_spec.rb +++ b/spec/lib/gitlab/git/repository_spec.rb @@ -579,9 +579,11 @@ RSpec.describe Gitlab::Git::Repository, :seed_helper do let(:commit_with_old_name) do Gitlab::Git::Commit.find(repository, @commit_with_old_name_id) end + let(:commit_with_new_name) do Gitlab::Git::Commit.find(repository, @commit_with_new_name_id) end + let(:rename_commit) do Gitlab::Git::Commit.find(repository, @rename_commit_id) end @@ -2178,6 +2180,7 @@ RSpec.describe Gitlab::Git::Repository, :seed_helper do let(:new_repository) do Gitlab::Git::Repository.new('test_second_storage', TEST_REPO_PATH, '', 'group/project') end + let(:new_repository_path) { File.join(TestEnv::SECOND_STORAGE_PATH, new_repository.relative_path) } subject { new_repository.replicate(repository) } diff --git a/spec/lib/gitlab/gitaly_client/commit_service_spec.rb b/spec/lib/gitlab/gitaly_client/commit_service_spec.rb index 45a25ccfc88..9581b017839 100644 --- a/spec/lib/gitlab/gitaly_client/commit_service_spec.rb +++ b/spec/lib/gitlab/gitaly_client/commit_service_spec.rb @@ -266,6 +266,7 @@ RSpec.describe Gitlab::GitalyClient::CommitService do repository: repository_message, revision: revision ) end + let(:response) do Gitaly::CommitStatsResponse.new( oid: revision, diff --git a/spec/lib/gitlab/gitaly_client/conflicts_service_spec.rb b/spec/lib/gitlab/gitaly_client/conflicts_service_spec.rb index b016e8bdf5a..e90cb966917 100644 --- a/spec/lib/gitlab/gitaly_client/conflicts_service_spec.rb +++ b/spec/lib/gitlab/gitaly_client/conflicts_service_spec.rb @@ -35,6 +35,7 @@ RSpec.describe Gitlab::GitalyClient::ConflictsService do let(:files) do [{ old_path: 'some/path', new_path: 'some/path', content: '' }] end + let(:source_branch) { 'master' } let(:target_branch) { 'feature' } let(:commit_message) { 'Solving conflicts\n\nTést' } diff --git a/spec/lib/gitlab/gitaly_client/operation_service_spec.rb b/spec/lib/gitlab/gitaly_client/operation_service_spec.rb index 4e16f760235..b974f456914 100644 --- a/spec/lib/gitlab/gitaly_client/operation_service_spec.rb +++ b/spec/lib/gitlab/gitaly_client/operation_service_spec.rb @@ -20,11 +20,13 @@ RSpec.describe Gitlab::GitalyClient::OperationService do user: gitaly_user ) end + let(:gitaly_commit) { build(:gitaly_commit) } let(:commit_id) { gitaly_commit.id } let(:gitaly_branch) do Gitaly::Branch.new(name: branch_name, target_commit: gitaly_commit) end + let(:response) { Gitaly::UserCreateBranchResponse.new(branch: gitaly_branch) } let(:commit) { Gitlab::Git::Commit.new(repository, gitaly_commit) } @@ -68,6 +70,7 @@ RSpec.describe Gitlab::GitalyClient::OperationService do user: gitaly_user ) end + let(:response) { Gitaly::UserUpdateBranchResponse.new } subject { client.user_update_branch(branch_name, user, newrev, oldrev) } @@ -123,6 +126,7 @@ RSpec.describe Gitlab::GitalyClient::OperationService do user: gitaly_user ) end + let(:response) { Gitaly::UserDeleteBranchResponse.new } subject { client.user_delete_branch(branch_name, user) } @@ -162,6 +166,7 @@ RSpec.describe Gitlab::GitalyClient::OperationService do user: gitaly_user ) end + let(:branch_update) do Gitaly::OperationBranchUpdate.new( commit_id: source_sha, @@ -169,6 +174,7 @@ RSpec.describe Gitlab::GitalyClient::OperationService do branch_created: false ) end + let(:response) { Gitaly::UserFFBranchResponse.new(branch_update: branch_update) } before do @@ -303,6 +309,7 @@ RSpec.describe Gitlab::GitalyClient::OperationService do commit_message: commit_message ) end + let(:squash_sha) { 'f00' } let(:response) { Gitaly::UserSquashResponse.new(squash_sha: squash_sha) } @@ -375,6 +382,7 @@ RSpec.describe Gitlab::GitalyClient::OperationService do let(:patch_content) do patch_names.map { |name| File.read(File.join(patches_folder, name)) }.join("\n") end + let(:patch_names) { %w(0001-This-does-not-apply-to-the-feature-branch.patch) } let(:branch_name) { 'branch-with-patches' } diff --git a/spec/lib/gitlab/gitaly_client/wiki_service_spec.rb b/spec/lib/gitlab/gitaly_client/wiki_service_spec.rb index a06f8459963..8a169acb69c 100644 --- a/spec/lib/gitlab/gitaly_client/wiki_service_spec.rb +++ b/spec/lib/gitlab/gitaly_client/wiki_service_spec.rb @@ -18,6 +18,7 @@ RSpec.describe Gitlab::GitalyClient::WikiService do Gitaly::WikiFindPageResponse.new(page: Gitaly::WikiPage.new(raw_data: 'b')) ] end + let(:wiki_page) { subject.first } let(:wiki_page_version) { subject.last } @@ -60,6 +61,7 @@ RSpec.describe Gitlab::GitalyClient::WikiService do Gitaly::WikiGetAllPagesResponse.new(end_of_page: true) ] end + let(:wiki_page_1) { subject[0].first } let(:wiki_page_1_version) { subject[0].last } let(:wiki_page_2) { subject[1].first } diff --git a/spec/lib/gitlab/gitlab_import/project_creator_spec.rb b/spec/lib/gitlab/gitlab_import/project_creator_spec.rb index 44bcfb93c51..53bf1db3438 100644 --- a/spec/lib/gitlab/gitlab_import/project_creator_spec.rb +++ b/spec/lib/gitlab/gitlab_import/project_creator_spec.rb @@ -14,6 +14,7 @@ RSpec.describe Gitlab::GitlabImport::ProjectCreator do owner: { name: "john" } }.with_indifferent_access end + let(:namespace) { create(:group) } let(:token) { "asdffg" } let(:access_params) { { gitlab_access_token: token } } diff --git a/spec/lib/gitlab/google_code_import/importer_spec.rb b/spec/lib/gitlab/google_code_import/importer_spec.rb index f681e3c9f31..a22e80ae1c0 100644 --- a/spec/lib/gitlab/google_code_import/importer_spec.rb +++ b/spec/lib/gitlab/google_code_import/importer_spec.rb @@ -12,6 +12,7 @@ RSpec.describe Gitlab::GoogleCodeImport::Importer do 'user_map' => { 'thilo...' => "@#{mapped_user.username}" } } end + let(:project) { create(:project) } subject { described_class.new(project) } diff --git a/spec/lib/gitlab/google_code_import/project_creator_spec.rb b/spec/lib/gitlab/google_code_import/project_creator_spec.rb index 4be2e16c116..cfebe57aed3 100644 --- a/spec/lib/gitlab/google_code_import/project_creator_spec.rb +++ b/spec/lib/gitlab/google_code_import/project_creator_spec.rb @@ -11,6 +11,7 @@ RSpec.describe Gitlab::GoogleCodeImport::ProjectCreator do "repositoryUrls" => ["https://vim.googlecode.com/git/"] ) end + let(:namespace) { create(:group) } before do diff --git a/spec/lib/gitlab/grape_logging/formatters/lograge_with_timestamp_spec.rb b/spec/lib/gitlab/grape_logging/formatters/lograge_with_timestamp_spec.rb index e5d0adcfd5f..91299de0751 100644 --- a/spec/lib/gitlab/grape_logging/formatters/lograge_with_timestamp_spec.rb +++ b/spec/lib/gitlab/grape_logging/formatters/lograge_with_timestamp_spec.rb @@ -29,6 +29,7 @@ RSpec.describe Gitlab::GrapeLogging::Formatters::LogrageWithTimestamp do correlation_id: 'WMefXn60429' } end + let(:time) { Time.now } let(:result) { Gitlab::Json.parse(subject) } diff --git a/spec/lib/gitlab/graphql/authorize/authorize_resource_spec.rb b/spec/lib/gitlab/graphql/authorize/authorize_resource_spec.rb index 83873081a98..c5d7665c3b2 100644 --- a/spec/lib/gitlab/graphql/authorize/authorize_resource_spec.rb +++ b/spec/lib/gitlab/graphql/authorize/authorize_resource_spec.rb @@ -116,6 +116,7 @@ RSpec.describe Gitlab::Graphql::Authorize::AuthorizeResource do end end end + let(:error) { /#{fake_class.name} has no authorizations/ } describe '#authorized_find!' do diff --git a/spec/lib/gitlab/graphql/find_argument_in_parent_spec.rb b/spec/lib/gitlab/graphql/find_argument_in_parent_spec.rb index 68b24a60a99..1b9301cd1aa 100644 --- a/spec/lib/gitlab/graphql/find_argument_in_parent_spec.rb +++ b/spec/lib/gitlab/graphql/find_argument_in_parent_spec.rb @@ -21,6 +21,7 @@ RSpec.describe Gitlab::Graphql::FindArgumentInParent do ) ) end + let(:arg_name) { :my_arg } it 'searches parents and returns the argument' do diff --git a/spec/lib/gitlab/graphql/pagination/keyset/connection_spec.rb b/spec/lib/gitlab/graphql/pagination/keyset/connection_spec.rb index 65698caac34..09d7e084172 100644 --- a/spec/lib/gitlab/graphql/pagination/keyset/connection_spec.rb +++ b/spec/lib/gitlab/graphql/pagination/keyset/connection_spec.rb @@ -185,6 +185,7 @@ RSpec.describe Gitlab::Graphql::Pagination::Keyset::Connection do let(:nodes) do Project.order(Arel.sql('projects.last_repository_check_at IS NULL')).order(last_repository_check_at: :asc).order(id: :asc) end + let(:ascending_nodes) { [project5, project1, project3, project2, project4] } it_behaves_like 'nodes are in ascending order' @@ -210,6 +211,7 @@ RSpec.describe Gitlab::Graphql::Pagination::Keyset::Connection do let(:nodes) do Project.order(Arel.sql('projects.last_repository_check_at IS NULL')).order(last_repository_check_at: :desc).order(id: :asc) end + let(:descending_nodes) { [project3, project1, project5, project2, project4] } it_behaves_like 'nodes are in descending order' @@ -243,6 +245,7 @@ RSpec.describe Gitlab::Graphql::Pagination::Keyset::Connection do let(:nodes) do Project.order(Arel::Table.new(:projects)['name'].lower.asc).order(id: :asc) end + let(:ascending_nodes) { [project1, project5, project3, project2, project4] } it_behaves_like 'nodes are in ascending order' @@ -252,6 +255,7 @@ RSpec.describe Gitlab::Graphql::Pagination::Keyset::Connection do let(:nodes) do Project.order(Arel::Table.new(:projects)['name'].lower.desc).order(id: :desc) end + let(:descending_nodes) { [project4, project2, project3, project5, project1] } it_behaves_like 'nodes are in descending order' diff --git a/spec/lib/gitlab/hook_data/issuable_builder_spec.rb b/spec/lib/gitlab/hook_data/issuable_builder_spec.rb index 50f3a4776be..f5ee8eba8bc 100644 --- a/spec/lib/gitlab/hook_data/issuable_builder_spec.rb +++ b/spec/lib/gitlab/hook_data/issuable_builder_spec.rb @@ -56,6 +56,7 @@ RSpec.describe Gitlab::HookData::IssuableBuilder do ] } end + let(:data) { builder.build(user: user, changes: changes) } it 'populates the :changes hash' do diff --git a/spec/lib/gitlab/import_export/base/object_builder_spec.rb b/spec/lib/gitlab/import_export/base/object_builder_spec.rb index d560c8ea5a7..38c3b23db36 100644 --- a/spec/lib/gitlab/import_export/base/object_builder_spec.rb +++ b/spec/lib/gitlab/import_export/base/object_builder_spec.rb @@ -10,6 +10,7 @@ RSpec.describe Gitlab::ImportExport::Base::ObjectBuilder do name: 'project', path: 'project') end + let(:klass) { Milestone } let(:attributes) { { 'title' => 'Test Base::ObjectBuilder Milestone', 'project' => project } } diff --git a/spec/lib/gitlab/import_export/json/streaming_serializer_spec.rb b/spec/lib/gitlab/import_export/json/streaming_serializer_spec.rb index eb6b07ce02f..949cfb5a34d 100644 --- a/spec/lib/gitlab/import_export/json/streaming_serializer_spec.rb +++ b/spec/lib/gitlab/import_export/json/streaming_serializer_spec.rb @@ -81,6 +81,7 @@ RSpec.describe Gitlab::ImportExport::JSON::StreamingSerializer do let(:group_options) do { include: [], only: [:name, :path, :description] } end + let(:include) do [{ group: group_options }] end diff --git a/spec/lib/gitlab/import_export/project/tree_restorer_spec.rb b/spec/lib/gitlab/import_export/project/tree_restorer_spec.rb index 6d5604dc40f..f75494aa7c7 100644 --- a/spec/lib/gitlab/import_export/project/tree_restorer_spec.rb +++ b/spec/lib/gitlab/import_export/project/tree_restorer_spec.rb @@ -502,6 +502,7 @@ RSpec.describe Gitlab::ImportExport::Project::TreeRestorer do let(:project_tree_restorer) do described_class.new(user: user, shared: shared, project: project) end + let(:restored_project_json) { project_tree_restorer.restore } it 'does not read a symlink' do @@ -919,6 +920,7 @@ RSpec.describe Gitlab::ImportExport::Project::TreeRestorer do } ] end + let(:tree_hash) { { 'project_members' => project_members } } before do diff --git a/spec/lib/gitlab/import_export/project/tree_saver_spec.rb b/spec/lib/gitlab/import_export/project/tree_saver_spec.rb index 40c103eeda6..a2c5848f100 100644 --- a/spec/lib/gitlab/import_export/project/tree_saver_spec.rb +++ b/spec/lib/gitlab/import_export/project/tree_saver_spec.rb @@ -275,6 +275,7 @@ RSpec.describe Gitlab::ImportExport::Project::TreeSaver do File.join(shared.export_path, Gitlab::ImportExport.project_filename) end end + let(:shared) { project.import_export_shared } let(:params) { {} } diff --git a/spec/lib/gitlab/incident_management/pager_duty/incident_issue_description_spec.rb b/spec/lib/gitlab/incident_management/pager_duty/incident_issue_description_spec.rb index 9a55e21d031..6dc96217f09 100644 --- a/spec/lib/gitlab/incident_management/pager_duty/incident_issue_description_spec.rb +++ b/spec/lib/gitlab/incident_management/pager_duty/incident_issue_description_spec.rb @@ -10,9 +10,11 @@ RSpec.describe Gitlab::IncidentManagement::PagerDuty::IncidentIssueDescription d let(:assignees) do [{ 'summary' => 'Laura Haley', 'url' => 'https://webdemo.pagerduty.com/users/P553OPV' }] end + let(:impacted_services) do [{ 'summary' => 'Production XDB Cluster', 'url' => 'https://webdemo.pagerduty.com/services/PN49J75' }] end + let(:incident_payload) do { 'url' => 'https://webdemo.pagerduty.com/incidents/PRORDTY', diff --git a/spec/lib/gitlab/issuable_sorter_spec.rb b/spec/lib/gitlab/issuable_sorter_spec.rb index 60f62062f04..b8d0c7b0609 100644 --- a/spec/lib/gitlab/issuable_sorter_spec.rb +++ b/spec/lib/gitlab/issuable_sorter_spec.rb @@ -52,6 +52,7 @@ RSpec.describe Gitlab::IssuableSorter do build_stubbed(:issue, iid: 1, project: project5), build_stubbed(:issue, iid: 1, project: project6)] end + let(:unsorted) do [sorted[3], sorted[1], sorted[4], sorted[2], sorted[6], sorted[5], sorted[0], sorted[7]] diff --git a/spec/lib/gitlab/jira_import/issue_serializer_spec.rb b/spec/lib/gitlab/jira_import/issue_serializer_spec.rb index 4adc4e4d22a..e57a8457e7c 100644 --- a/spec/lib/gitlab/jira_import/issue_serializer_spec.rb +++ b/spec/lib/gitlab/jira_import/issue_serializer_spec.rb @@ -25,6 +25,7 @@ RSpec.describe Gitlab::JiraImport::IssueSerializer do let(:parent_field) do { 'key' => 'FOO-2', 'id' => '1050', 'fields' => { 'summary' => 'parent issue FOO' } } end + let(:priority_field) { { 'name' => 'Medium' } } let(:labels_field) { %w(bug dev backend frontend) } diff --git a/spec/lib/gitlab/jira_import/metadata_collector_spec.rb b/spec/lib/gitlab/jira_import/metadata_collector_spec.rb index 86863d67f25..51751c7b75f 100644 --- a/spec/lib/gitlab/jira_import/metadata_collector_spec.rb +++ b/spec/lib/gitlab/jira_import/metadata_collector_spec.rb @@ -14,6 +14,7 @@ RSpec.describe Gitlab::JiraImport::MetadataCollector do let(:parent_field) do { 'key' => 'FOO-2', 'id' => '1050', 'fields' => { 'summary' => 'parent issue FOO' } } end + let(:issue_type_field) { { 'name' => 'Task' } } let(:fix_versions_field) { [{ 'name' => '1.0' }, { 'name' => '1.1' }] } let(:priority_field) { { 'name' => 'Medium' } } @@ -30,6 +31,7 @@ RSpec.describe Gitlab::JiraImport::MetadataCollector do 'duedate' => duedate_field } end + let(:jira_issue) do double( id: '1234', diff --git a/spec/lib/gitlab/kubernetes/network_policy_spec.rb b/spec/lib/gitlab/kubernetes/network_policy_spec.rb index a7bb12d1d06..f1730e400af 100644 --- a/spec/lib/gitlab/kubernetes/network_policy_spec.rb +++ b/spec/lib/gitlab/kubernetes/network_policy_spec.rb @@ -48,6 +48,7 @@ RSpec.describe Gitlab::Kubernetes::NetworkPolicy do labels: labels ) end + let(:spec) { { podSelector: selector, policyTypes: ["Ingress"], ingress: ingress, egress: nil } } end @@ -74,6 +75,7 @@ RSpec.describe Gitlab::Kubernetes::NetworkPolicy do project: myproject POLICY end + let(:resource) do ::Kubeclient::Resource.new( metadata: { name: name, namespace: namespace, labels: { app: 'foo' } }, @@ -170,6 +172,7 @@ RSpec.describe Gitlab::Kubernetes::NetworkPolicy do spec: { podSelector: pod_selector, policyTypes: %w(Ingress), ingress: ingress, egress: nil } ) end + let(:generated_resource) do ::Kubeclient::Resource.new( metadata: { name: name, namespace: namespace, labels: { app: 'foo' } }, diff --git a/spec/lib/gitlab/language_detection_spec.rb b/spec/lib/gitlab/language_detection_spec.rb index 04ad19a04ec..14523be8ec6 100644 --- a/spec/lib/gitlab/language_detection_spec.rb +++ b/spec/lib/gitlab/language_detection_spec.rb @@ -15,6 +15,7 @@ RSpec.describe Gitlab::LanguageDetection do { value: 1.51, label: "Go", color: "#2a4776", highlight: "#244776" }, { value: 1.1, label: "MepmepLang", color: "#2a4776", highlight: "#244776" }] end + let(:repository_languages) do [RepositoryLanguage.new(share: 10, programming_language: ruby)] end diff --git a/spec/lib/gitlab/legacy_github_import/importer_spec.rb b/spec/lib/gitlab/legacy_github_import/importer_spec.rb index c443944678f..56d708a1e11 100644 --- a/spec/lib/gitlab/legacy_github_import/importer_spec.rb +++ b/spec/lib/gitlab/legacy_github_import/importer_spec.rb @@ -238,6 +238,7 @@ RSpec.describe Gitlab::LegacyGithubImport::Importer do labels: [double(name: 'Label #2')] ) end + let(:closed_pull_request) do double( number: 1347, diff --git a/spec/lib/gitlab/legacy_github_import/issuable_formatter_spec.rb b/spec/lib/gitlab/legacy_github_import/issuable_formatter_spec.rb index 6a51cb6f39d..a5d2e00890b 100644 --- a/spec/lib/gitlab/legacy_github_import/issuable_formatter_spec.rb +++ b/spec/lib/gitlab/legacy_github_import/issuable_formatter_spec.rb @@ -6,6 +6,7 @@ RSpec.describe Gitlab::LegacyGithubImport::IssuableFormatter do let(:raw_data) do double(number: 42) end + let(:project) { double(import_type: 'github') } let(:issuable_formatter) { described_class.new(project, raw_data) } diff --git a/spec/lib/gitlab/legacy_github_import/milestone_formatter_spec.rb b/spec/lib/gitlab/legacy_github_import/milestone_formatter_spec.rb index 2ac79c4f5b8..148b59dedab 100644 --- a/spec/lib/gitlab/legacy_github_import/milestone_formatter_spec.rb +++ b/spec/lib/gitlab/legacy_github_import/milestone_formatter_spec.rb @@ -17,6 +17,7 @@ RSpec.describe Gitlab::LegacyGithubImport::MilestoneFormatter do closed_at: nil } end + let(:iid_attr) { :number } subject(:formatter) { described_class.new(project, raw_data) } diff --git a/spec/lib/gitlab/lograge/custom_options_spec.rb b/spec/lib/gitlab/lograge/custom_options_spec.rb index 218007c6e2a..9daedfc37e4 100644 --- a/spec/lib/gitlab/lograge/custom_options_spec.rb +++ b/spec/lib/gitlab/lograge/custom_options_spec.rb @@ -22,6 +22,7 @@ RSpec.describe Gitlab::Lograge::CustomOptions do metadata: { 'meta.user' => 'jane.doe' } } end + let(:event) { ActiveSupport::Notifications::Event.new('test', 1, 2, 'transaction_id', event_payload) } subject { described_class.call(event) } diff --git a/spec/lib/gitlab/markdown_cache/redis/store_spec.rb b/spec/lib/gitlab/markdown_cache/redis/store_spec.rb index 40ff9a765a6..bf40af8e62e 100644 --- a/spec/lib/gitlab/markdown_cache/redis/store_spec.rb +++ b/spec/lib/gitlab/markdown_cache/redis/store_spec.rb @@ -18,6 +18,7 @@ RSpec.describe Gitlab::MarkdownCache::Redis::Store, :clean_gitlab_redis_cache do end end end + let(:storable) { storable_class.new } let(:cache_key) { "markdown_cache:#{storable.cache_key}" } diff --git a/spec/lib/gitlab/metrics/dashboard/finder_spec.rb b/spec/lib/gitlab/metrics/dashboard/finder_spec.rb index a481c536f8d..730a31346d7 100644 --- a/spec/lib/gitlab/metrics/dashboard/finder_spec.rb +++ b/spec/lib/gitlab/metrics/dashboard/finder_spec.rb @@ -191,6 +191,7 @@ RSpec.describe Gitlab::Metrics::Dashboard::Finder, :use_clean_rails_memory_store out_of_the_box_dashboard: true } end + let(:dashboard_path) { '.gitlab/dashboards/test.yml' } let(:project) { project_with_dashboard(dashboard_path) } diff --git a/spec/lib/gitlab/metrics/dashboard/processor_spec.rb b/spec/lib/gitlab/metrics/dashboard/processor_spec.rb index e794e28a279..d5998bb2fa1 100644 --- a/spec/lib/gitlab/metrics/dashboard/processor_spec.rb +++ b/spec/lib/gitlab/metrics/dashboard/processor_spec.rb @@ -98,6 +98,7 @@ RSpec.describe Gitlab::Metrics::Dashboard::Processor do Gitlab::Metrics::Dashboard::Stages::Sorter ] end + let(:dashboard) { described_class.new(*process_params).process } it 'includes only dashboard metrics' do diff --git a/spec/lib/gitlab/phabricator_import/user_finder_spec.rb b/spec/lib/gitlab/phabricator_import/user_finder_spec.rb index e63ad6e6626..2ec2571b7fe 100644 --- a/spec/lib/gitlab/phabricator_import/user_finder_spec.rb +++ b/spec/lib/gitlab/phabricator_import/user_finder_spec.rb @@ -58,6 +58,7 @@ RSpec.describe Gitlab::PhabricatorImport::UserFinder, :clean_gitlab_redis_cache ) ] end + let(:client) do client = instance_double(Gitlab::PhabricatorImport::Conduit::User) allow(client).to receive(:users).and_return(response) diff --git a/spec/lib/gitlab/project_search_results_spec.rb b/spec/lib/gitlab/project_search_results_spec.rb index 75a3fe06632..6e3c60b58dc 100644 --- a/spec/lib/gitlab/project_search_results_spec.rb +++ b/spec/lib/gitlab/project_search_results_spec.rb @@ -430,6 +430,7 @@ RSpec.describe Gitlab::ProjectSearchResults do private_project.add_maintainer(user) user end + let(:team_reporter) do user = create(:user, username: 'private-project-reporter') private_project.add_reporter(user) diff --git a/spec/lib/gitlab/prometheus/queries/matched_metric_query_spec.rb b/spec/lib/gitlab/prometheus/queries/matched_metric_query_spec.rb index 117ca798022..60449aeef7d 100644 --- a/spec/lib/gitlab/prometheus/queries/matched_metric_query_spec.rb +++ b/spec/lib/gitlab/prometheus/queries/matched_metric_query_spec.rb @@ -17,6 +17,7 @@ RSpec.describe Gitlab::Prometheus::Queries::MatchedMetricQuery do [{ '__name__' => 'metric_a' }, { '__name__' => 'metric_b' }] end + let(:partially_empty_series_info) { [{ '__name__' => 'metric_a', 'environment' => '' }] } let(:empty_series_info) { [] } diff --git a/spec/lib/gitlab/prometheus_client_spec.rb b/spec/lib/gitlab/prometheus_client_spec.rb index 242a0ced031..0774c2f3144 100644 --- a/spec/lib/gitlab/prometheus_client_spec.rb +++ b/spec/lib/gitlab/prometheus_client_spec.rb @@ -191,6 +191,7 @@ RSpec.describe Gitlab::PrometheusClient do } } end + let(:query_url) { prometheus_query_with_time_url(query, Time.now.utc) } around do |example| diff --git a/spec/lib/gitlab/sidekiq_cluster_spec.rb b/spec/lib/gitlab/sidekiq_cluster_spec.rb index d625a2a2185..5dd913aebb0 100644 --- a/spec/lib/gitlab/sidekiq_cluster_spec.rb +++ b/spec/lib/gitlab/sidekiq_cluster_spec.rb @@ -91,6 +91,7 @@ RSpec.describe Gitlab::SidekiqCluster do let(:options) do { env: :production, directory: 'foo/bar', max_concurrency: 20, min_concurrency: 0, worker_id: first_worker_id, timeout: 10, dryrun: false } end + let(:env) { { "ENABLE_SIDEKIQ_CLUSTER" => "1", "SIDEKIQ_WORKER_ID" => first_worker_id.to_s } } let(:args) { ['bundle', 'exec', 'sidekiq', anything, '-eproduction', '-t10', *([anything] * 5)] } diff --git a/spec/lib/gitlab/sidekiq_logging/structured_logger_spec.rb b/spec/lib/gitlab/sidekiq_logging/structured_logger_spec.rb index 03ace9a01c7..ad106837c47 100644 --- a/spec/lib/gitlab/sidekiq_logging/structured_logger_spec.rb +++ b/spec/lib/gitlab/sidekiq_logging/structured_logger_spec.rb @@ -41,6 +41,7 @@ RSpec.describe Gitlab::SidekiqLogging::StructuredLogger do 'scheduling_latency_s' => scheduling_latency_s ) end + let(:end_payload) do start_payload.merge( 'message' => 'TestWorker JID-da883554ee4fe414012f5f42: done: 0.0 sec', @@ -51,6 +52,7 @@ RSpec.describe Gitlab::SidekiqLogging::StructuredLogger do 'db_duration_s' => 0.0 ) end + let(:exception_payload) do end_payload.merge( 'message' => 'TestWorker JID-da883554ee4fe414012f5f42: fail: 0.0 sec', diff --git a/spec/lib/gitlab/sidekiq_middleware_spec.rb b/spec/lib/gitlab/sidekiq_middleware_spec.rb index b4e47ac4cbb..4ee9569a0cf 100644 --- a/spec/lib/gitlab/sidekiq_middleware_spec.rb +++ b/spec/lib/gitlab/sidekiq_middleware_spec.rb @@ -63,6 +63,7 @@ RSpec.describe Gitlab::SidekiqMiddleware do Gitlab::SidekiqMiddleware::DuplicateJobs::Server ] end + let(:enabled_sidekiq_middlewares) { all_sidekiq_middlewares - disabled_sidekiq_middlewares } shared_examples "a server middleware chain" do diff --git a/spec/lib/gitlab/url_blocker_spec.rb b/spec/lib/gitlab/url_blocker_spec.rb index 7edfde09864..b49efd6a092 100644 --- a/spec/lib/gitlab/url_blocker_spec.rb +++ b/spec/lib/gitlab/url_blocker_spec.rb @@ -280,6 +280,7 @@ RSpec.describe Gitlab::UrlBlocker, :stub_invalid_dns_only do '[fc00:bf8b:e62c:abcd:abcd:aaaa:aaaa:aaaa]' ] end + let(:fake_domain) { 'www.fakedomain.fake' } shared_examples 'allows local requests' do |url_blocker_attributes| diff --git a/spec/lib/gitlab/usage_data/topology_spec.rb b/spec/lib/gitlab/usage_data/topology_spec.rb index bf61ddd9d83..0cea86726dc 100644 --- a/spec/lib/gitlab/usage_data/topology_spec.rb +++ b/spec/lib/gitlab/usage_data/topology_spec.rb @@ -177,6 +177,7 @@ RSpec.describe Gitlab::UsageData::Topology do } ] end + let(:node_uname_info_response) do [ { @@ -195,6 +196,7 @@ RSpec.describe Gitlab::UsageData::Topology do ] end # The services in this response should all be mapped to localhost i.e. the same node + let(:service_memory_response) do [ { diff --git a/spec/lib/json_web_token/rsa_token_spec.rb b/spec/lib/json_web_token/rsa_token_spec.rb index f19471917c2..8f0d62d8f0c 100644 --- a/spec/lib/json_web_token/rsa_token_spec.rb +++ b/spec/lib/json_web_token/rsa_token_spec.rb @@ -14,6 +14,7 @@ RSpec.describe JSONWebToken::RSAToken do -----END RSA PRIVATE KEY----- eos end + let(:rsa_token) { described_class.new(nil) } let(:rsa_encoded) { rsa_token.encoded } diff --git a/spec/lib/mattermost/session_spec.rb b/spec/lib/mattermost/session_spec.rb index 5110d3cdfa3..93422b01ca7 100644 --- a/spec/lib/mattermost/session_spec.rb +++ b/spec/lib/mattermost/session_spec.rb @@ -61,6 +61,7 @@ RSpec.describe Mattermost::Session, type: :request do redirect_uri: "#{mattermost_url}/signup/gitlab/complete", state: state } end + let(:location) do "#{gitlab_url}/oauth/authorize?#{URI.encode_www_form(params)}" end diff --git a/spec/lib/omni_auth/strategies/jwt_spec.rb b/spec/lib/omni_auth/strategies/jwt_spec.rb index 0f4528d4fbe..b29e48b0de5 100644 --- a/spec/lib/omni_auth/strategies/jwt_spec.rb +++ b/spec/lib/omni_auth/strategies/jwt_spec.rb @@ -19,6 +19,7 @@ RSpec.describe OmniAuth::Strategies::Jwt do iat: timestamp } end + let(:algorithm) { 'HS256' } let(:secret) { jwt_config.strategy.secret } let(:private_key) { secret } @@ -61,6 +62,7 @@ RSpec.describe OmniAuth::Strategies::Jwt do private_key_class.new(jwt_config.strategy.secret) end end + let(:private_key) { private_key_class ? private_key_class.new(secret) : secret } it 'decodes the user information' do diff --git a/spec/lib/rspec_flaky/example_spec.rb b/spec/lib/rspec_flaky/example_spec.rb index aaf5ddc6f74..4b45a15c463 100644 --- a/spec/lib/rspec_flaky/example_spec.rb +++ b/spec/lib/rspec_flaky/example_spec.rb @@ -15,6 +15,7 @@ RSpec.describe RspecFlaky::Example do attempts: 1 } end + let(:rspec_example) { double(example_attrs) } describe '#initialize' do diff --git a/spec/lib/rspec_flaky/flaky_example_spec.rb b/spec/lib/rspec_flaky/flaky_example_spec.rb index 8ac323475d6..b1647d5830a 100644 --- a/spec/lib/rspec_flaky/flaky_example_spec.rb +++ b/spec/lib/rspec_flaky/flaky_example_spec.rb @@ -16,6 +16,7 @@ RSpec.describe RspecFlaky::FlakyExample, :aggregate_failures do flaky_reports: 1 } end + let(:example_attrs) do { uid: 'abc123', @@ -28,6 +29,7 @@ RSpec.describe RspecFlaky::FlakyExample, :aggregate_failures do attempts: flaky_example_attrs[:last_attempts_count] } end + let(:example) { double(example_attrs) } before do diff --git a/spec/lib/rspec_flaky/flaky_examples_collection_spec.rb b/spec/lib/rspec_flaky/flaky_examples_collection_spec.rb index 5718d8211af..b2fd1d3733a 100644 --- a/spec/lib/rspec_flaky/flaky_examples_collection_spec.rb +++ b/spec/lib/rspec_flaky/flaky_examples_collection_spec.rb @@ -9,6 +9,7 @@ RSpec.describe RspecFlaky::FlakyExamplesCollection, :aggregate_failures do b: { example_id: 'spec/foo/baz_spec.rb:3' } } end + let(:collection_report) do { a: { diff --git a/spec/lib/rspec_flaky/listener_spec.rb b/spec/lib/rspec_flaky/listener_spec.rb index 2438ae171d3..10ed724d4de 100644 --- a/spec/lib/rspec_flaky/listener_spec.rb +++ b/spec/lib/rspec_flaky/listener_spec.rb @@ -19,6 +19,7 @@ RSpec.describe RspecFlaky::Listener, :aggregate_failures do } } end + let(:already_flaky_example_attrs) do { id: 'spec/foo/bar_spec.rb:2', @@ -30,6 +31,7 @@ RSpec.describe RspecFlaky::Listener, :aggregate_failures do execution_result: double(status: 'passed', exception: nil) } end + let(:already_flaky_example) { RspecFlaky::FlakyExample.new(suite_flaky_example_report[already_flaky_example_uid]) } let(:new_example_attrs) do { diff --git a/spec/lib/rspec_flaky/report_spec.rb b/spec/lib/rspec_flaky/report_spec.rb index e735329a8a3..5cacfdb82fb 100644 --- a/spec/lib/rspec_flaky/report_spec.rb +++ b/spec/lib/rspec_flaky/report_spec.rb @@ -10,6 +10,7 @@ RSpec.describe RspecFlaky::Report, :aggregate_failures do b: { example_id: 'spec/foo/baz_spec.rb:3', first_flaky_at: (Time.now - thirty_one_days).to_s, last_flaky_at: (Time.now - thirty_one_days).to_s } } end + let(:suite_flaky_example_report) do { '6e869794f4cfd2badd93eb68719371d1': { @@ -25,6 +26,7 @@ RSpec.describe RspecFlaky::Report, :aggregate_failures do } } end + let(:flaky_examples) { RspecFlaky::FlakyExamplesCollection.new(collection_hash) } let(:report) { described_class.new(flaky_examples) } diff --git a/spec/lib/sentry/client/event_spec.rb b/spec/lib/sentry/client/event_spec.rb index af1e28d09bb..07ed331c44c 100644 --- a/spec/lib/sentry/client/event_spec.rb +++ b/spec/lib/sentry/client/event_spec.rb @@ -13,6 +13,7 @@ RSpec.describe Sentry::Client do headers: { "Authorization" => "Bearer test-token" } } end + let(:client) { described_class.new(sentry_url, token) } describe '#issue_latest_event' do @@ -21,6 +22,7 @@ RSpec.describe Sentry::Client do Gitlab::Json.parse(fixture_file('sentry/issue_latest_event_sample_response.json')) ) end + let(:issue_id) { '1234' } let(:sentry_api_response) { sample_response } let(:sentry_url) { 'https://sentrytest.gitlab.com/api/0' } diff --git a/spec/lib/sentry/client/issue_spec.rb b/spec/lib/sentry/client/issue_spec.rb index a6279aeadd2..dedef905c95 100644 --- a/spec/lib/sentry/client/issue_spec.rb +++ b/spec/lib/sentry/client/issue_spec.rb @@ -65,6 +65,7 @@ RSpec.describe Sentry::Client::Issue do link: '<https://sentrytest.gitlab.com>; rel="previous"; results="true"; cursor="1573556671000:0:1", <https://sentrytest.gitlab.com>; rel="next"; results="true"; cursor="1572959139000:0:0"' } end + let!(:sentry_api_request) { stub_sentry_request(sentry_request_url, body: sentry_api_response, headers: headers) } it 'parses the pagination' do @@ -114,6 +115,7 @@ RSpec.describe Sentry::Client::Issue do 'https://sentrytest.gitlab.com/api/0/projects/sentry-org/sentry-project/' \ 'issues/?limit=20&query=is:unresolved&sort=freq' end + let!(:sentry_api_request) { stub_sentry_request(sentry_request_url, body: sentry_api_response) } subject { client.list_issues(issue_status: issue_status, limit: limit, sort: 'frequency') } diff --git a/spec/mailers/notify_spec.rb b/spec/mailers/notify_spec.rb index 9dde80f58d5..7bd1fae8f91 100644 --- a/spec/mailers/notify_spec.rb +++ b/spec/mailers/notify_spec.rb @@ -1373,6 +1373,7 @@ RSpec.describe Notify do group.request_access(user) group.requesters.find_by(user_id: user.id) end + let(:recipient) { user } subject { described_class.member_access_denied_email('group', group.id, user.id) } diff --git a/spec/migrations/20190924152703_migrate_issue_trackers_data_spec.rb b/spec/migrations/20190924152703_migrate_issue_trackers_data_spec.rb index 750d3d1fa30..6c957ee1428 100644 --- a/spec/migrations/20190924152703_migrate_issue_trackers_data_spec.rb +++ b/spec/migrations/20190924152703_migrate_issue_trackers_data_spec.rb @@ -13,27 +13,35 @@ RSpec.describe MigrateIssueTrackersData do 'url' => 'http://example.com' } end + let!(:jira_service) do services.create(type: 'JiraService', properties: properties, category: 'issue_tracker') end + let!(:jira_service_nil) do services.create(type: 'JiraService', properties: nil, category: 'issue_tracker') end + let!(:bugzilla_service) do services.create(type: 'BugzillaService', properties: properties, category: 'issue_tracker') end + let!(:youtrack_service) do services.create(type: 'YoutrackService', properties: properties, category: 'issue_tracker') end + let!(:youtrack_service_empty) do services.create(type: 'YoutrackService', properties: '', category: 'issue_tracker') end + let!(:gitlab_service) do services.create(type: 'GitlabIssueTrackerService', properties: properties, category: 'issue_tracker') end + let!(:gitlab_service_empty) do services.create(type: 'GitlabIssueTrackerService', properties: {}, category: 'issue_tracker') end + let!(:other_service) do services.create(type: 'OtherService', properties: properties, category: 'other_category') end diff --git a/spec/migrations/20200123155929_remove_invalid_jira_data_spec.rb b/spec/migrations/20200123155929_remove_invalid_jira_data_spec.rb index cae8e858af9..e69a30752db 100644 --- a/spec/migrations/20200123155929_remove_invalid_jira_data_spec.rb +++ b/spec/migrations/20200123155929_remove_invalid_jira_data_spec.rb @@ -28,32 +28,39 @@ RSpec.describe RemoveInvalidJiraData do data[:encrypted_api_url_iv] = nil jira_tracker_data.create(data) end + let!(:missing_api_url) do data[:encrypted_api_url] = '' data[:encrypted_api_url_iv] = nil jira_tracker_data.create(data) end + let!(:invalid_url) do data[:encrypted_url_iv] = nil jira_tracker_data.create(data) end + let!(:missing_url) do data[:encrypted_url] = '' jira_tracker_data.create(data) end + let!(:invalid_username) do data[:encrypted_username_iv] = nil jira_tracker_data.create(data) end + let!(:missing_username) do data[:encrypted_username] = nil data[:encrypted_username_iv] = nil jira_tracker_data.create(data) end + let!(:invalid_password) do data[:encrypted_password_iv] = nil jira_tracker_data.create(data) end + let!(:missing_password) do data[:encrypted_password] = nil data[:encrypted_username_iv] = nil diff --git a/spec/migrations/20200127090233_remove_invalid_issue_tracker_data_spec.rb b/spec/migrations/20200127090233_remove_invalid_issue_tracker_data_spec.rb index a86b5d83a0b..e7917cf5d72 100644 --- a/spec/migrations/20200127090233_remove_invalid_issue_tracker_data_spec.rb +++ b/spec/migrations/20200127090233_remove_invalid_issue_tracker_data_spec.rb @@ -26,23 +26,28 @@ RSpec.describe RemoveInvalidIssueTrackerData do data[:encrypted_issues_url_iv] = nil issue_tracker_data.create(data) end + let!(:missing_issues_url) do data[:encrypted_issues_url] = '' data[:encrypted_issues_url_iv] = nil issue_tracker_data.create(data) end + let!(:invalid_new_isue_url) do data[:encrypted_new_issue_url_iv] = nil issue_tracker_data.create(data) end + let!(:missing_new_issue_url) do data[:encrypted_new_issue_url] = '' issue_tracker_data.create(data) end + let!(:invalid_project_url) do data[:encrypted_project_url_iv] = nil issue_tracker_data.create(data) end + let!(:missing_project_url) do data[:encrypted_project_url] = nil data[:encrypted_project_url_iv] = nil diff --git a/spec/migrations/20200130145430_reschedule_migrate_issue_trackers_data_spec.rb b/spec/migrations/20200130145430_reschedule_migrate_issue_trackers_data_spec.rb index 146302ba650..d5208976928 100644 --- a/spec/migrations/20200130145430_reschedule_migrate_issue_trackers_data_spec.rb +++ b/spec/migrations/20200130145430_reschedule_migrate_issue_trackers_data_spec.rb @@ -13,27 +13,35 @@ RSpec.describe RescheduleMigrateIssueTrackersData do 'url' => 'http://example.com' } end + let!(:jira_service) do services.create(id: 10, type: 'JiraService', properties: properties, category: 'issue_tracker') end + let!(:jira_service_nil) do services.create(id: 11, type: 'JiraService', properties: nil, category: 'issue_tracker') end + let!(:bugzilla_service) do services.create(id: 12, type: 'BugzillaService', properties: properties, category: 'issue_tracker') end + let!(:youtrack_service) do services.create(id: 13, type: 'YoutrackService', properties: properties, category: 'issue_tracker') end + let!(:youtrack_service_empty) do services.create(id: 14, type: 'YoutrackService', properties: '', category: 'issue_tracker') end + let!(:gitlab_service) do services.create(id: 15, type: 'GitlabIssueTrackerService', properties: properties, category: 'issue_tracker') end + let!(:gitlab_service_empty) do services.create(id: 16, type: 'GitlabIssueTrackerService', properties: {}, category: 'issue_tracker') end + let!(:other_service) do services.create(id: 17, type: 'OtherService', properties: properties, category: 'other_category') end @@ -67,6 +75,7 @@ RSpec.describe RescheduleMigrateIssueTrackersData do encrypted_issues_url_iv: 'somevalue' ) end + let!(:invalid_issue_tracker_data) do issue_tracker_data.create( service_id: bugzilla_service.id, @@ -74,6 +83,7 @@ RSpec.describe RescheduleMigrateIssueTrackersData do encrypted_issues_url_iv: nil ) end + let!(:valid_jira_tracker_data) do jira_tracker_data.create( service_id: bugzilla_service.id, @@ -81,6 +91,7 @@ RSpec.describe RescheduleMigrateIssueTrackersData do encrypted_url_iv: 'somevalue' ) end + let!(:invalid_jira_tracker_data) do jira_tracker_data.create( service_id: bugzilla_service.id, diff --git a/spec/migrations/migrate_k8s_service_integration_spec.rb b/spec/migrations/migrate_k8s_service_integration_spec.rb index a1b2f2ae841..66e30b29f61 100644 --- a/spec/migrations/migrate_k8s_service_integration_spec.rb +++ b/spec/migrations/migrate_k8s_service_integration_spec.rb @@ -125,6 +125,7 @@ RSpec.describe MigrateK8sServiceIntegration do platform_type: :kubernetes ) end + let(:new_cluster) { MigrateK8sServiceIntegration::Cluster.instance_type.last! } let(:platform) { new_cluster.platform_kubernetes } diff --git a/spec/migrations/remove_duplicate_labels_from_project_spec.rb b/spec/migrations/remove_duplicate_labels_from_project_spec.rb index 5e287eaa4ed..5eb8ba96aae 100644 --- a/spec/migrations/remove_duplicate_labels_from_project_spec.rb +++ b/spec/migrations/remove_duplicate_labels_from_project_spec.rb @@ -27,6 +27,7 @@ RSpec.describe RemoveDuplicateLabelsFromProject do projects_table.create!(id: 1, name: 'project', path: 'project', visibility_level: 0, namespace_id: group_one.id) end + let(:label_title) { 'bug' } let(:label_color) { 'red' } let(:label_description) { 'nice label' } diff --git a/spec/migrations/remove_orphaned_invited_members_spec.rb b/spec/migrations/remove_orphaned_invited_members_spec.rb index 0474b5362be..10da63518c2 100644 --- a/spec/migrations/remove_orphaned_invited_members_spec.rb +++ b/spec/migrations/remove_orphaned_invited_members_spec.rb @@ -22,6 +22,7 @@ RSpec.describe RemoveOrphanedInvitedMembers do invite_token: SecureRandom.hex, invite_accepted_at: Time.now, access_level: 20) end + let!(:invited_member2) do create_member(user_id: nil, source_type: 'Group', source_id: group.id, invite_token: SecureRandom.hex, invite_accepted_at: Time.now, @@ -32,6 +33,7 @@ RSpec.describe RemoveOrphanedInvitedMembers do create_member(user_id: nil, source_type: 'Project', source_id: project.id, invite_accepted_at: Time.now, access_level: 30) end + let!(:orphaned_member2) do create_member(user_id: nil, source_type: 'Group', source_id: group.id, invite_accepted_at: Time.now, access_level: 20) diff --git a/spec/models/ability_spec.rb b/spec/models/ability_spec.rb index 9206f14fd37..3418d7d39ad 100644 --- a/spec/models/ability_spec.rb +++ b/spec/models/ability_spec.rb @@ -194,6 +194,7 @@ RSpec.describe Ability do let(:cross_project_merge_request) do create(:merge_request, source_project: create(:project, :public)) end + let(:other_merge_request) { create(:merge_request) } let(:all_merge_requests) do [merge_request, cross_project_merge_request, other_merge_request] diff --git a/spec/models/alert_management/alert_spec.rb b/spec/models/alert_management/alert_spec.rb index bf338a9f4ee..7c22af54c71 100644 --- a/spec/models/alert_management/alert_spec.rb +++ b/spec/models/alert_management/alert_spec.rb @@ -335,6 +335,7 @@ RSpec.describe AlertManagement::Alert do } } end + let(:alert) { build(:alert_management_alert, project: project, title: 'Details title', payload: payload) } subject { alert.details } diff --git a/spec/models/blob_viewer/composer_json_spec.rb b/spec/models/blob_viewer/composer_json_spec.rb index 8d66e9e951f..5af58f3d6c7 100644 --- a/spec/models/blob_viewer/composer_json_spec.rb +++ b/spec/models/blob_viewer/composer_json_spec.rb @@ -14,6 +14,7 @@ RSpec.describe BlobViewer::ComposerJson do } SPEC end + let(:blob) { fake_blob(path: 'composer.json', data: data) } subject { described_class.new(blob) } diff --git a/spec/models/blob_viewer/gemspec_spec.rb b/spec/models/blob_viewer/gemspec_spec.rb index b6f3e059c7e..43c63050c90 100644 --- a/spec/models/blob_viewer/gemspec_spec.rb +++ b/spec/models/blob_viewer/gemspec_spec.rb @@ -14,6 +14,7 @@ RSpec.describe BlobViewer::Gemspec do end SPEC end + let(:blob) { fake_blob(path: 'activerecord.gemspec', data: data) } subject { described_class.new(blob) } diff --git a/spec/models/blob_viewer/go_mod_spec.rb b/spec/models/blob_viewer/go_mod_spec.rb index 21e84d39a54..3249e86fb03 100644 --- a/spec/models/blob_viewer/go_mod_spec.rb +++ b/spec/models/blob_viewer/go_mod_spec.rb @@ -11,6 +11,7 @@ RSpec.describe BlobViewer::GoMod do module #{Settings.build_gitlab_go_url}/#{project.full_path} SPEC end + let(:blob) { fake_blob(path: 'go.mod', data: data) } subject { described_class.new(blob) } diff --git a/spec/models/blob_viewer/package_json_spec.rb b/spec/models/blob_viewer/package_json_spec.rb index d2e8ab6575f..8a394a7334f 100644 --- a/spec/models/blob_viewer/package_json_spec.rb +++ b/spec/models/blob_viewer/package_json_spec.rb @@ -14,6 +14,7 @@ RSpec.describe BlobViewer::PackageJson do } SPEC end + let(:blob) { fake_blob(path: 'package.json', data: data) } subject { described_class.new(blob) } @@ -54,6 +55,7 @@ RSpec.describe BlobViewer::PackageJson do } SPEC end + let(:blob) { fake_blob(path: 'package.json', data: data) } subject { described_class.new(blob) } diff --git a/spec/models/blob_viewer/podspec_json_spec.rb b/spec/models/blob_viewer/podspec_json_spec.rb index 61d2602c413..cdeea4e8744 100644 --- a/spec/models/blob_viewer/podspec_json_spec.rb +++ b/spec/models/blob_viewer/podspec_json_spec.rb @@ -14,6 +14,7 @@ RSpec.describe BlobViewer::PodspecJson do } SPEC end + let(:blob) { fake_blob(path: 'AFNetworking.podspec.json', data: data) } subject { described_class.new(blob) } diff --git a/spec/models/blob_viewer/podspec_spec.rb b/spec/models/blob_viewer/podspec_spec.rb index 0a0fbcaebd4..c2828067f22 100644 --- a/spec/models/blob_viewer/podspec_spec.rb +++ b/spec/models/blob_viewer/podspec_spec.rb @@ -14,6 +14,7 @@ RSpec.describe BlobViewer::Podspec do end SPEC end + let(:blob) { fake_blob(path: 'Reachability.podspec', data: data) } subject { described_class.new(blob) } diff --git a/spec/models/blob_viewer/route_map_spec.rb b/spec/models/blob_viewer/route_map_spec.rb index bb0284d7868..c412afaac4e 100644 --- a/spec/models/blob_viewer/route_map_spec.rb +++ b/spec/models/blob_viewer/route_map_spec.rb @@ -13,6 +13,7 @@ RSpec.describe BlobViewer::RouteMap do public: 'team/' MAP end + let(:blob) { fake_blob(path: '.gitlab/route-map.yml', data: data) } subject { described_class.new(blob) } diff --git a/spec/models/ci/build_spec.rb b/spec/models/ci/build_spec.rb index f8043798a99..0f410a15901 100644 --- a/spec/models/ci/build_spec.rb +++ b/spec/models/ci/build_spec.rb @@ -2797,6 +2797,7 @@ RSpec.describe Ci::Build do let(:ci_registry) do { key: 'CI_REGISTRY', value: 'registry.example.com', public: true, masked: false } end + let(:ci_registry_image) do { key: 'CI_REGISTRY_IMAGE', value: project.container_registry_url, public: true, masked: false } end diff --git a/spec/models/ci/daily_build_group_report_result_spec.rb b/spec/models/ci/daily_build_group_report_result_spec.rb index 059a5b76b9a..326366666cb 100644 --- a/spec/models/ci/daily_build_group_report_result_spec.rb +++ b/spec/models/ci/daily_build_group_report_result_spec.rb @@ -36,6 +36,7 @@ RSpec.describe Ci::DailyBuildGroupReportResult do data: { coverage: 71.2 } ) end + let!(:new_pipeline) { create(:ci_pipeline) } it 'creates or updates matching report results' do diff --git a/spec/models/ci/pipeline_spec.rb b/spec/models/ci/pipeline_spec.rb index bb3d02eb69f..836cbf90829 100644 --- a/spec/models/ci/pipeline_spec.rb +++ b/spec/models/ci/pipeline_spec.rb @@ -1935,6 +1935,7 @@ RSpec.describe Ci::Pipeline, :mailer do project: project ) end + let!(:commit_123_ref_develop) do create( :ci_empty_pipeline, @@ -1944,6 +1945,7 @@ RSpec.describe Ci::Pipeline, :mailer do project: project ) end + let!(:commit_456_ref_test) do create( :ci_empty_pipeline, diff --git a/spec/models/clusters/platforms/kubernetes_spec.rb b/spec/models/clusters/platforms/kubernetes_spec.rb index adccc72d13d..c6a2b67a008 100644 --- a/spec/models/clusters/platforms/kubernetes_spec.rb +++ b/spec/models/clusters/platforms/kubernetes_spec.rb @@ -410,6 +410,7 @@ RSpec.describe Clusters::Platforms::Kubernetes do let(:expected_pod_cached_data) do kube_pod.tap { |kp| kp['metadata'].delete('namespace') } end + let(:namespace) { "project-namespace" } let(:environment) { instance_double(Environment, deployment_namespace: namespace) } diff --git a/spec/models/commit_with_pipeline_spec.rb b/spec/models/commit_with_pipeline_spec.rb index ff451527929..c4b6deebae0 100644 --- a/spec/models/commit_with_pipeline_spec.rb +++ b/spec/models/commit_with_pipeline_spec.rb @@ -13,6 +13,7 @@ RSpec.describe CommitWithPipeline do sha: commit.sha, status: 'success') end + let!(:second_pipeline) do create(:ci_empty_pipeline, project: project, diff --git a/spec/models/concerns/featurable_spec.rb b/spec/models/concerns/featurable_spec.rb index cc01820cc97..31186b5fc77 100644 --- a/spec/models/concerns/featurable_spec.rb +++ b/spec/models/concerns/featurable_spec.rb @@ -42,6 +42,7 @@ RSpec.describe Featurable do end end end + let!(:instance) { klass.new } it { expect(klass.available_features).to eq [:feature1, :feature2] } diff --git a/spec/models/concerns/issuable_spec.rb b/spec/models/concerns/issuable_spec.rb index 96d3e2b7b1b..c943dd57f05 100644 --- a/spec/models/concerns/issuable_spec.rb +++ b/spec/models/concerns/issuable_spec.rb @@ -149,6 +149,7 @@ RSpec.describe Issuable do let!(:searchable_issue) do create(:issue, title: "Searchable awesome issue", description: 'Many cute kittens') end + let!(:searchable_issue2) { create(:issue, title: "Aw", description: "Cu") } it 'returns issues with a matching title' do diff --git a/spec/models/design_management/design_at_version_spec.rb b/spec/models/design_management/design_at_version_spec.rb index 2c640ee5c2c..3c1ff45c53f 100644 --- a/spec/models/design_management/design_at_version_spec.rb +++ b/spec/models/design_management/design_at_version_spec.rb @@ -78,18 +78,23 @@ RSpec.describe DesignManagement::DesignAtVersion do let!(:version_a) do create(:design_version, designs: [design_a]) end + let!(:version_b) do create(:design_version, designs: [design_b]) end + let!(:version_mod) do create(:design_version, modified_designs: [design_a, design_b]) end + let!(:version_c) do create(:design_version, deleted_designs: [design_a]) end + let!(:version_d) do create(:design_version, deleted_designs: [design_b]) end + let!(:version_e) do create(:design_version, designs: [design_a]) end @@ -296,9 +301,11 @@ RSpec.describe DesignManagement::DesignAtVersion do let!(:version_a) do create(:design_version, designs: create_list(:design, 3, issue: issue)) end + let!(:version_b) do create(:design_version, designs: create_list(:design, 1, issue: issue)) end + let!(:version_c) do create(:design_version, designs: create_list(:design, 1, issue: issue_b)) end @@ -346,10 +353,12 @@ RSpec.describe DesignManagement::DesignAtVersion do let!(:version_a) do create(:design_version, designs: create_list(:design, 3, issue: issue)) end + let!(:version_b) do create(:design_version, designs: create_list(:design, 2, issue: issue)) end # 1 version, with 3 designs on issue B, so 1*3 = 3 + let!(:version_c) do create(:design_version, designs: create_list(:design, 3, issue: issue_b)) end diff --git a/spec/models/merge_request_diff_commit_spec.rb b/spec/models/merge_request_diff_commit_spec.rb index 5ea0145e60f..84fdfae1ed1 100644 --- a/spec/models/merge_request_diff_commit_spec.rb +++ b/spec/models/merge_request_diff_commit_spec.rb @@ -30,6 +30,7 @@ RSpec.describe MergeRequestDiffCommit do project.commit('570e7b2abdd848b95f2f578043fc23bd6f6fd24d') ] end + let(:rows) do [ { @@ -73,6 +74,7 @@ RSpec.describe MergeRequestDiffCommit do # This commit's date is "Sun Aug 17 07:12:55 292278994 +0000" [project.commit('ba3343bc4fa403a8dfbfcab7fc1a8c29ee34bd69')] end + let(:timestamp) { Time.zone.at((1 << 31) - 1) } let(:rows) do [{ diff --git a/spec/models/merge_request_spec.rb b/spec/models/merge_request_spec.rb index f123a819224..6edef54b153 100644 --- a/spec/models/merge_request_spec.rb +++ b/spec/models/merge_request_spec.rb @@ -63,6 +63,7 @@ RSpec.describe MergeRequest do subject.source_project.repository.path end end + let(:squash_path) { File.join(repo_path, "gitlab-worktree", "squash-#{subject.id}") } before do @@ -742,6 +743,7 @@ RSpec.describe MergeRequest do let!(:diff_note) do create(:diff_note_on_merge_request, project: project, noteable: merge_request) end + let!(:draft_note) do create(:draft_note_on_text_diff, author: user, merge_request: merge_request) end @@ -3713,6 +3715,7 @@ RSpec.describe MergeRequest do source_branch: 'fixes', target_project: target_project) end + let(:user) { create(:user) } before do diff --git a/spec/models/namespace_spec.rb b/spec/models/namespace_spec.rb index ad4c8448745..4ef2ddd218a 100644 --- a/spec/models/namespace_spec.rb +++ b/spec/models/namespace_spec.rb @@ -507,6 +507,7 @@ RSpec.describe Namespace do Gitlab.config.repositories.storages.default.legacy_disk_path end end + let(:path_in_dir) { File.join(repository_storage_path, namespace.full_path) } let(:deleted_path) { namespace.full_path.gsub(namespace.path, "#{namespace.full_path}+#{namespace.id}+deleted") } let(:deleted_path_in_dir) { File.join(repository_storage_path, deleted_path) } diff --git a/spec/models/note_spec.rb b/spec/models/note_spec.rb index e6e6a8c35cf..864f7221181 100644 --- a/spec/models/note_spec.rb +++ b/spec/models/note_spec.rb @@ -471,6 +471,7 @@ RSpec.describe Note do note: "added label #{private_label.to_reference(ext_proj)}", system: true end + let!(:system_note_metadata) { create(:system_note_metadata, note: note, action: :label) } it_behaves_like "checks references" diff --git a/spec/models/pages_domain_spec.rb b/spec/models/pages_domain_spec.rb index d283389e29e..1fc4f098661 100644 --- a/spec/models/pages_domain_spec.rb +++ b/spec/models/pages_domain_spec.rb @@ -611,6 +611,7 @@ RSpec.describe PagesDomain do let!(:domain_with_expired_user_provided_certificate) do create(:pages_domain, :with_expired_certificate) end + let!(:domain_with_user_provided_certificate_and_auto_ssl) do create(:pages_domain, auto_ssl_enabled: true) end diff --git a/spec/models/project_services/jira_service_spec.rb b/spec/models/project_services/jira_service_spec.rb index cfc2c920cd2..28bba893be4 100644 --- a/spec/models/project_services/jira_service_spec.rb +++ b/spec/models/project_services/jira_service_spec.rb @@ -121,6 +121,7 @@ RSpec.describe JiraService do { url: url, api_url: api_url, username: username, password: password, jira_issue_transition_id: transition_id } end + let(:data_params) do { url: url, api_url: api_url, @@ -562,6 +563,7 @@ RSpec.describe JiraService do password: password ) end + let(:jira_issue) { ExternalIssue.new('JIRA-123', project) } subject { jira_service.create_cross_reference_note(jira_issue, resource, user) } diff --git a/spec/models/project_services/microsoft_teams_service_spec.rb b/spec/models/project_services/microsoft_teams_service_spec.rb index 610feb52827..53ab63ef030 100644 --- a/spec/models/project_services/microsoft_teams_service_spec.rb +++ b/spec/models/project_services/microsoft_teams_service_spec.rb @@ -121,6 +121,7 @@ RSpec.describe MicrosoftTeamsService do message: "user created page: Awesome wiki_page" } end + let(:wiki_page) { create(:wiki_page, wiki: project.wiki, **opts) } let(:wiki_page_sample_data) { Gitlab::DataBuilder::WikiPage.build(wiki_page, user, 'create') } diff --git a/spec/models/project_spec.rb b/spec/models/project_spec.rb index 9dada39a7a0..0caaa5394fa 100644 --- a/spec/models/project_spec.rb +++ b/spec/models/project_spec.rb @@ -401,6 +401,7 @@ RSpec.describe Project do create(:project, pending_delete: true) end + let(:new_project) do build(:project, name: project_pending_deletion.name, @@ -2262,6 +2263,7 @@ RSpec.describe Project do create(:ci_empty_pipeline, project: project, sha: project.commit.id, ref: project.default_branch) end + let!(:pipeline_for_second_branch) do create(:ci_empty_pipeline, project: project, sha: second_branch.target, ref: second_branch.name) @@ -3529,6 +3531,7 @@ RSpec.describe Project do public: '\\1' MAP end + let(:sha) { project.commit.id } context 'when there is a route map' do @@ -5145,6 +5148,7 @@ RSpec.describe Project do allow_collaboration: true ) end + let!(:merge_request) do create( :merge_request, diff --git a/spec/models/repository_spec.rb b/spec/models/repository_spec.rb index 17a66ef4f44..07b32aa69ef 100644 --- a/spec/models/repository_spec.rb +++ b/spec/models/repository_spec.rb @@ -2700,6 +2700,7 @@ RSpec.describe Repository do build(:commit, author: author_c), build(:commit, author: author_c)] end + let(:order_by) { nil } let(:sort) { nil } diff --git a/spec/models/snippet_repository_spec.rb b/spec/models/snippet_repository_spec.rb index 8c25d713c0a..0f5e0bfc75c 100644 --- a/spec/models/snippet_repository_spec.rb +++ b/spec/models/snippet_repository_spec.rb @@ -102,6 +102,7 @@ RSpec.describe SnippetRepository do { action: :move }.merge(move_file), { action: :update }.merge(update_file)] end + let(:repo) { double } before do diff --git a/spec/models/wiki_page_spec.rb b/spec/models/wiki_page_spec.rb index 7e2babe62c2..aa8b9ce58b9 100644 --- a/spec/models/wiki_page_spec.rb +++ b/spec/models/wiki_page_spec.rb @@ -49,9 +49,11 @@ RSpec.describe WikiPage do let(:dir_1) do WikiDirectory.new('dir_1', [wiki.find_page('dir_1/page_2')]) end + let(:dir_1_1) do WikiDirectory.new('dir_1/dir_1_1', [wiki.find_page('dir_1/dir_1_1/page_3')]) end + let(:dir_2) do pages = [wiki.find_page('dir_2/page_5'), wiki.find_page('dir_2/page_4')] diff --git a/spec/policies/project_policy_spec.rb b/spec/policies/project_policy_spec.rb index 7371fe5c3f7..a7bafd64167 100644 --- a/spec/policies/project_policy_spec.rb +++ b/spec/policies/project_policy_spec.rb @@ -325,6 +325,7 @@ RSpec.describe ProjectPolicy do allow_collaboration: true ) end + let(:maintainer_abilities) do %w(create_build create_pipeline) end diff --git a/spec/presenters/blob_presenter_spec.rb b/spec/presenters/blob_presenter_spec.rb index 8bc6b048823..47402fea2b5 100644 --- a/spec/presenters/blob_presenter_spec.rb +++ b/spec/presenters/blob_presenter_spec.rb @@ -12,6 +12,7 @@ RSpec.describe BlobPresenter, :seed_helper do 'files/ruby/regex.rb' ) end + let(:blob) { Blob.new(git_blob) } describe '.web_url' do diff --git a/spec/requests/api/commits_spec.rb b/spec/requests/api/commits_spec.rb index bacfbcf93da..21ff0a94db9 100644 --- a/spec/requests/api/commits_spec.rb +++ b/spec/requests/api/commits_spec.rb @@ -329,6 +329,7 @@ RSpec.describe API::Commits do ] } end + let(:valid_c_params) do { branch: 'master', @@ -342,6 +343,7 @@ RSpec.describe API::Commits do ] } end + let(:valid_utf8_c_params) do { branch: 'master', @@ -621,6 +623,7 @@ RSpec.describe API::Commits do ] } end + let(:valid_d_params) do { branch: 'markdown', @@ -664,6 +667,7 @@ RSpec.describe API::Commits do ] } end + let(:valid_m_params) do { branch: 'feature', @@ -708,6 +712,7 @@ RSpec.describe API::Commits do ] } end + let(:valid_u_params) do { branch: 'master', @@ -819,6 +824,7 @@ RSpec.describe API::Commits do ] } end + let(:valid_mo_params) do { branch: 'master', diff --git a/spec/requests/api/deploy_keys_spec.rb b/spec/requests/api/deploy_keys_spec.rb index 81cef653770..591d994fec9 100644 --- a/spec/requests/api/deploy_keys_spec.rb +++ b/spec/requests/api/deploy_keys_spec.rb @@ -165,6 +165,7 @@ RSpec.describe API::DeployKeys do let(:deploy_keys_project) do create(:deploy_keys_project, project: project, deploy_key: deploy_key) end + let(:extra_params) { { title: 'new title', can_push: true } } it 'updates the title of the deploy key' do diff --git a/spec/requests/api/files_spec.rb b/spec/requests/api/files_spec.rb index 4441a9114a6..d7571ad4bff 100644 --- a/spec/requests/api/files_spec.rb +++ b/spec/requests/api/files_spec.rb @@ -17,6 +17,7 @@ RSpec.describe API::Files do ref: 'master' } end + let(:author_email) { 'user@example.org' } let(:author_name) { 'John Doe' } @@ -773,6 +774,7 @@ RSpec.describe API::Files do Gitlab::Git::Commit .last_for_path(project.repository, 'master', URI.unescape(file_path)) end + let(:params_with_correct_id) { params.merge(last_commit_id: last_commit.id) } subject { put api(route(absolute_path), user), params: params_with_correct_id } @@ -868,6 +870,7 @@ RSpec.describe API::Files do encoding: 'base64' } end + let(:get_params) do { ref: 'master' diff --git a/spec/requests/api/go_proxy_spec.rb b/spec/requests/api/go_proxy_spec.rb index 91e455dac19..faffb6bd192 100644 --- a/spec/requests/api/go_proxy_spec.rb +++ b/spec/requests/api/go_proxy_spec.rb @@ -108,6 +108,7 @@ RSpec.describe API::GoProxy do project.repository.commit_by(oid: sha) end + let(:resource) { "#{version}.info" } it_behaves_like 'an unavailable resource' 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 bc1b42d68e6..7bef812bfec 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 @@ -18,6 +18,7 @@ RSpec.describe 'Updating the container expiration policy' do older_than: 'FOURTEEN_DAYS' } end + let(:mutation) do graphql_mutation(:update_container_expiration_policy, params, <<~QL @@ -32,6 +33,7 @@ RSpec.describe 'Updating the container expiration policy' do QL ) end + let(:mutation_response) { graphql_mutation_response(:update_container_expiration_policy) } let(:container_expiration_policy_response) { mutation_response['containerExpirationPolicy'] } diff --git a/spec/requests/api/graphql/mutations/design_management/move_spec.rb b/spec/requests/api/graphql/mutations/design_management/move_spec.rb new file mode 100644 index 00000000000..dd121ec733e --- /dev/null +++ b/spec/requests/api/graphql/mutations/design_management/move_spec.rb @@ -0,0 +1,122 @@ +# frozen_string_literal: true +require "spec_helper" + +RSpec.describe "moving designs" do + include GraphqlHelpers + include DesignManagementTestHelpers + + let_it_be(:issue) { create(:issue) } + let_it_be(:designs) { create_list(:design, 3, :with_versions, :with_relative_position, issue: issue) } + let_it_be(:developer) { create(:user, developer_projects: [issue.project]) } + + let(:user) { developer } + + let(:current_design) { designs.first } + let(:previous_design) { designs.second } + let(:next_design) { designs.third } + let(:mutation_name) { :design_management_move } + + let(:mutation) do + input = { + id: current_design.to_global_id.to_s, + previous: previous_design&.to_global_id&.to_s, + next: next_design&.to_global_id&.to_s + }.compact + + graphql_mutation(mutation_name, input, <<~FIELDS) + errors + designCollection { + designs { + nodes { + filename + } + } + } + FIELDS + end + + let(:move_designs) { post_graphql_mutation(mutation, current_user: user) } + let(:mutation_response) { graphql_mutation_response(mutation_name) } + + before do + enable_design_management + designs.each(&:reset) + issue.reset + end + + shared_examples 'a successful move' do + it 'does not error, and reports the current order' do + move_designs + + expect(graphql_errors).not_to be_present + + expect(mutation_response).to eq( + 'errors' => [], + 'designCollection' => { + 'designs' => { + 'nodes' => new_order.map { |d| { 'filename' => d.filename } } + } + } + ) + end + end + + context 'the user is not allowed to move designs' do + let(:user) { create(:user) } + + it 'returns an error' do + move_designs + + expect(graphql_errors).to be_present + end + end + + context 'the neighbors do not have positions' do + let!(:previous_design) { create(:design, :with_versions, issue: issue) } + let!(:next_design) { create(:design, :with_versions, issue: issue) } + + let(:new_order) do + [ + designs.second, + designs.third, + previous_design, current_design, next_design + ] + end + + it_behaves_like 'a successful move' + + it 'maintains the correct order in the presence of other unpositioned designs' do + other_design = create(:design, :with_versions, issue: issue) + + move_designs + moved_designs = mutation_response.dig('designCollection', 'designs', 'nodes') + + expect(moved_designs.map { |d| d['filename'] }) + .to eq([*new_order.map(&:filename), other_design.filename]) + end + end + + context 'moving a design between two others' do + let(:new_order) { [designs.second, designs.first, designs.third] } + + it_behaves_like 'a successful move' + end + + context 'moving a design to the start' do + let(:current_design) { designs.last } + let(:next_design) { designs.first } + let(:previous_design) { nil } + let(:new_order) { [designs.last, designs.first, designs.second] } + + it_behaves_like 'a successful move' + end + + context 'moving a design to the end' do + let(:current_design) { designs.first } + let(:next_design) { nil } + let(:previous_design) { designs.last } + let(:new_order) { [designs.second, designs.third, designs.first] } + + it_behaves_like 'a successful move' + end +end 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 e83da830935..457c37e900b 100644 --- a/spec/requests/api/graphql/mutations/discussions/toggle_resolve_spec.rb +++ b/spec/requests/api/graphql/mutations/discussions/toggle_resolve_spec.rb @@ -10,9 +10,11 @@ RSpec.describe 'Toggling the resolve status of a discussion' do let(:discussion) do create(:diff_note_on_merge_request, noteable: noteable, project: project).to_discussion end + let(:mutation) do graphql_mutation(:discussion_toggle_resolve, { id: discussion.to_global_id.to_s, resolve: true }) end + let(:mutation_response) { graphql_mutation_response(:discussion_toggle_resolve) } context 'when the user does not have permission' 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 d4ac639e226..9297ca054c7 100644 --- a/spec/requests/api/graphql/mutations/merge_requests/create_spec.rb +++ b/spec/requests/api/graphql/mutations/merge_requests/create_spec.rb @@ -15,6 +15,7 @@ RSpec.describe 'Creation of a new merge request' do target_branch: target_branch } end + let(:title) { 'MergeRequest' } let(:source_branch) { 'new_branch' } let(:target_branch) { 'master' } 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 f7be671e5f3..463a872d95d 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 @@ -33,6 +33,7 @@ RSpec.describe 'Updating an image DiffNote' do y: updated_y } end + let!(:diff_note) do create(:image_diff_note_on_merge_request, noteable: noteable, @@ -40,6 +41,7 @@ RSpec.describe 'Updating an image DiffNote' do note: original_body, position: original_position) end + let(:mutation) do variables = { id: GitlabSchema.id_from_object(diff_note).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 9101acdafbb..3f39c0ab851 100644 --- a/spec/requests/api/graphql/mutations/snippets/update_spec.rb +++ b/spec/requests/api/graphql/mutations/snippets/update_spec.rb @@ -26,6 +26,7 @@ RSpec.describe 'Updating a Snippet' do title: updated_title } end + let(:mutation) do graphql_mutation(:update_snippet, mutation_vars) end diff --git a/spec/requests/api/graphql/project/container_expiration_policy_spec.rb b/spec/requests/api/graphql/project/container_expiration_policy_spec.rb index b064e4d43e9..dc16847a669 100644 --- a/spec/requests/api/graphql/project/container_expiration_policy_spec.rb +++ b/spec/requests/api/graphql/project/container_expiration_policy_spec.rb @@ -13,6 +13,7 @@ RSpec.describe 'getting a repository in a project' do #{all_graphql_fields_for('container_expiration_policy'.classify)} QUERY end + let(:query) do graphql_query_for( 'project', 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 e47c025f8b2..decab900a43 100644 --- a/spec/requests/api/graphql/project/issue/designs/designs_spec.rb +++ b/spec/requests/api/graphql/project/issue/designs/designs_spec.rb @@ -24,12 +24,14 @@ RSpec.describe 'Getting designs related to an issue' do } NODE end + let(:issue) { design.issue } let(:project) { issue.project } let(:query) { make_query } let(:design_collection) do graphql_data_at(:project, :issue, :design_collection) end + let(:design_response) do design_collection.dig('designs', 'edges').first['node'] end @@ -185,6 +187,7 @@ RSpec.describe 'Getting designs related to an issue' do } NODE end + let(:design_response) do design_collection['designs']['edges'] end diff --git a/spec/requests/api/graphql/project/issues_spec.rb b/spec/requests/api/graphql/project/issues_spec.rb index cdfff2f50d4..06e613a09bc 100644 --- a/spec/requests/api/graphql/project/issues_spec.rb +++ b/spec/requests/api/graphql/project/issues_spec.rb @@ -12,6 +12,7 @@ RSpec.describe 'getting an issue list for a project' do [create(:issue, project: project, discussion_locked: true), create(:issue, project: project)] end + let(:fields) do <<~QUERY edges { diff --git a/spec/requests/api/graphql/project/jira_import_spec.rb b/spec/requests/api/graphql/project/jira_import_spec.rb index 814965262b6..59d24835ae5 100644 --- a/spec/requests/api/graphql/project/jira_import_spec.rb +++ b/spec/requests/api/graphql/project/jira_import_spec.rb @@ -53,6 +53,7 @@ RSpec.describe 'query Jira import data' do } ) end + let(:jira_imports) { graphql_data.dig('project', 'jiraImports', 'nodes')} let(:jira_import_status) { graphql_data.dig('project', 'jiraImportStatus')} diff --git a/spec/requests/api/graphql/project/repository_spec.rb b/spec/requests/api/graphql/project/repository_spec.rb index bd719a69647..a4984688557 100644 --- a/spec/requests/api/graphql/project/repository_spec.rb +++ b/spec/requests/api/graphql/project/repository_spec.rb @@ -11,6 +11,7 @@ RSpec.describe 'getting a repository in a project' do #{all_graphql_fields_for('repository'.classify)} QUERY end + let(:query) do graphql_query_for( 'project', diff --git a/spec/requests/api/graphql/project/tree/tree_spec.rb b/spec/requests/api/graphql/project/tree/tree_spec.rb index bce63d57c38..f4cd316da96 100644 --- a/spec/requests/api/graphql/project/tree/tree_spec.rb +++ b/spec/requests/api/graphql/project/tree/tree_spec.rb @@ -15,6 +15,7 @@ RSpec.describe 'getting a tree in a project' do } QUERY end + let(:query) do graphql_query_for( 'project', diff --git a/spec/requests/api/graphql/user_query_spec.rb b/spec/requests/api/graphql/user_query_spec.rb index 7ba1788a9ef..d8a2f96f5d8 100644 --- a/spec/requests/api/graphql/user_query_spec.rb +++ b/spec/requests/api/graphql/user_query_spec.rb @@ -83,6 +83,7 @@ RSpec.describe 'getting user information' do let(:user_fields) do query_graphql_field(:assigned_merge_requests, mr_args, 'nodes { id }') end + let(:mr_args) { nil } it_behaves_like 'a working graphql query' @@ -145,6 +146,7 @@ RSpec.describe 'getting user information' do let(:user_fields) do query_graphql_field(:authored_merge_requests, mr_args, 'nodes { id }') end + let(:mr_args) { nil } it_behaves_like 'a working graphql query' diff --git a/spec/requests/api/group_import_spec.rb b/spec/requests/api/group_import_spec.rb index ad67f737725..cb63206fcb8 100644 --- a/spec/requests/api/group_import_spec.rb +++ b/spec/requests/api/group_import_spec.rb @@ -217,12 +217,14 @@ RSpec.describe API::GroupImport do let!(:fog_connection) do stub_uploads_object_storage(ImportExportUploader, direct_upload: true) end + let(:tmp_object) do fog_connection.directories.new(key: 'uploads').files.create( key: "tmp/uploads/#{file_name}", body: file_upload ) end + let(:fog_file) { fog_to_uploaded_file(tmp_object) } let(:params) do { diff --git a/spec/requests/api/groups_spec.rb b/spec/requests/api/groups_spec.rb index a0f475a7b77..da423e986c3 100644 --- a/spec/requests/api/groups_spec.rb +++ b/spec/requests/api/groups_spec.rb @@ -1072,6 +1072,7 @@ RSpec.describe API::Groups do let!(:project4) do create(:project, namespace: group2, path: 'test_project', visibility_level: Gitlab::VisibilityLevel::PRIVATE) end + let(:path) { "/groups/#{group1.id}/projects/shared" } before do diff --git a/spec/requests/api/helpers_spec.rb b/spec/requests/api/helpers_spec.rb index 12cd5ace84e..fefa7105327 100644 --- a/spec/requests/api/helpers_spec.rb +++ b/spec/requests/api/helpers_spec.rb @@ -24,6 +24,7 @@ RSpec.describe API::Helpers do 'CONTENT_TYPE' => 'text/plain;charset=utf-8' } end + let(:header) { } let(:request) { Grape::Request.new(env)} let(:params) { request.params } diff --git a/spec/requests/api/internal/base_spec.rb b/spec/requests/api/internal/base_spec.rb index f410d82fed1..873189af397 100644 --- a/spec/requests/api/internal/base_spec.rb +++ b/spec/requests/api/internal/base_spec.rb @@ -683,6 +683,7 @@ RSpec.describe API::Internal::Base do } } end + let(:console_messages) { ['informational message'] } let(:custom_action_result) { Gitlab::GitAccessResult::CustomAction.new(payload, console_messages) } diff --git a/spec/requests/api/internal/pages_spec.rb b/spec/requests/api/internal/pages_spec.rb index 48fc95b6574..e58eba02132 100644 --- a/spec/requests/api/internal/pages_spec.rb +++ b/spec/requests/api/internal/pages_spec.rb @@ -7,6 +7,7 @@ RSpec.describe API::Internal::Pages do jwt_token = JWT.encode({ 'iss' => 'gitlab-pages' }, Gitlab::Pages.secret, 'HS256') { Gitlab::Pages::INTERNAL_API_REQUEST_HEADER => jwt_token } end + let(:pages_secret) { SecureRandom.random_bytes(Gitlab::Pages::SECRET_LENGTH) } before do diff --git a/spec/requests/api/issues/get_group_issues_spec.rb b/spec/requests/api/issues/get_group_issues_spec.rb index b53fac3679d..b0fbf3bf66d 100644 --- a/spec/requests/api/issues/get_group_issues_spec.rb +++ b/spec/requests/api/issues/get_group_issues_spec.rb @@ -36,6 +36,7 @@ RSpec.describe API::Issues do updated_at: 3.hours.ago, created_at: 1.day.ago end + let!(:group_confidential_issue) do create :issue, :confidential, @@ -45,6 +46,7 @@ RSpec.describe API::Issues do updated_at: 2.hours.ago, created_at: 2.days.ago end + let!(:group_issue) do create :issue, author: user, @@ -56,14 +58,17 @@ RSpec.describe API::Issues do description: issue_description, created_at: 5.days.ago end + let!(:group_label) do create(:label, title: 'group_lbl', color: '#FFAABB', project: group_project) end + let!(:group_label_link) { create(:label_link, label: group_label, target: group_issue) } let!(:group_milestone) { create(:milestone, title: '3.0.0', project: group_project) } let!(:group_empty_milestone) do create(:milestone, title: '4.0.0', project: group_project) end + let!(:group_note) { create(:note_on_issue, author: user, project: group_project, noteable: group_issue) } let(:base_url) { "/groups/#{group.id}/issues" } @@ -246,6 +251,7 @@ RSpec.describe API::Issues do target_project: private_mrs_project, description: "closes #{group_issue.to_reference(private_mrs_project)}") end + let!(:merge_request2) do create(:merge_request, :simple, diff --git a/spec/requests/api/issues/get_project_issues_spec.rb b/spec/requests/api/issues/get_project_issues_spec.rb index 43bb1e10d21..4228ca2d5fd 100644 --- a/spec/requests/api/issues/get_project_issues_spec.rb +++ b/spec/requests/api/issues/get_project_issues_spec.rb @@ -28,6 +28,7 @@ RSpec.describe API::Issues do updated_at: 3.hours.ago, closed_at: 1.hour.ago end + let!(:confidential_issue) do create :issue, :confidential, @@ -37,6 +38,7 @@ RSpec.describe API::Issues do created_at: generate(:past_time), updated_at: 2.hours.ago end + let!(:issue) do create :issue, author: user, @@ -48,6 +50,7 @@ RSpec.describe API::Issues do title: issue_title, description: issue_description end + let_it_be(:label) do create(:label, title: 'label', color: '#FFAABB', project: project) end @@ -69,6 +72,7 @@ RSpec.describe API::Issues do target_project: project, description: "closes #{issue.to_reference}") end + let!(:merge_request2) do create(:merge_request, :simple, diff --git a/spec/requests/api/issues/issues_spec.rb b/spec/requests/api/issues/issues_spec.rb index 519bea22501..a7a1b242f1f 100644 --- a/spec/requests/api/issues/issues_spec.rb +++ b/spec/requests/api/issues/issues_spec.rb @@ -28,6 +28,7 @@ RSpec.describe API::Issues do updated_at: 3.hours.ago, closed_at: 1.hour.ago end + let!(:confidential_issue) do create :issue, :confidential, @@ -37,6 +38,7 @@ RSpec.describe API::Issues do created_at: generate(:past_time), updated_at: 2.hours.ago end + let!(:issue) do create :issue, author: user, @@ -48,6 +50,7 @@ RSpec.describe API::Issues do title: issue_title, description: issue_description end + let_it_be(:label) do create(:label, title: 'label', color: '#FFAABB', project: project) end @@ -807,6 +810,7 @@ RSpec.describe API::Issues do target_project: private_mrs_project, description: "closes #{issue.to_reference(private_mrs_project)}") end + let!(:merge_request2) do create(:merge_request, :simple, diff --git a/spec/requests/api/issues/post_projects_issues_spec.rb b/spec/requests/api/issues/post_projects_issues_spec.rb index e2f1bb2cd1a..a7fe4d4509a 100644 --- a/spec/requests/api/issues/post_projects_issues_spec.rb +++ b/spec/requests/api/issues/post_projects_issues_spec.rb @@ -27,6 +27,7 @@ RSpec.describe API::Issues do updated_at: 3.hours.ago, closed_at: 1.hour.ago end + let!(:confidential_issue) do create :issue, :confidential, @@ -36,6 +37,7 @@ RSpec.describe API::Issues do created_at: generate(:past_time), updated_at: 2.hours.ago end + let!(:issue) do create :issue, author: user, @@ -47,6 +49,7 @@ RSpec.describe API::Issues do title: issue_title, description: issue_description end + let_it_be(:label) do create(:label, title: 'label', color: '#FFAABB', project: project) end diff --git a/spec/requests/api/notes_spec.rb b/spec/requests/api/notes_spec.rb index 1510d31a1a6..ca4ebd3689f 100644 --- a/spec/requests/api/notes_spec.rb +++ b/spec/requests/api/notes_spec.rb @@ -55,6 +55,7 @@ RSpec.describe API::Notes do create(:project, namespace: private_user.namespace) .tap { |p| p.add_maintainer(private_user) } end + let(:private_issue) { create(:issue, project: private_project) } let(:ext_proj) { create(:project, :public) } diff --git a/spec/requests/api/pages_domains_spec.rb b/spec/requests/api/pages_domains_spec.rb index b6838a39257..75183156c9d 100644 --- a/spec/requests/api/pages_domains_spec.rb +++ b/spec/requests/api/pages_domains_spec.rb @@ -17,6 +17,7 @@ RSpec.describe API::PagesDomains do build(:pages_domain, :without_key, :without_certificate, domain: 'www.other-domain.test', auto_ssl_enabled: true) .slice(:domain, :auto_ssl_enabled) end + let(:pages_domain_secure_params) { build(:pages_domain, domain: 'ssl.other-domain.test', project: project).slice(:domain, :certificate, :key) } let(:pages_domain_secure_key_missmatch_params) {build(:pages_domain, :with_trusted_chain, project: project).slice(:domain, :certificate, :key) } let(:pages_domain_secure_missing_chain_params) {build(:pages_domain, :with_missing_chain, project: project).slice(:certificate) } diff --git a/spec/requests/api/projects_spec.rb b/spec/requests/api/projects_spec.rb index 1f2280a1ab5..46340f86f69 100644 --- a/spec/requests/api/projects_spec.rb +++ b/spec/requests/api/projects_spec.rb @@ -70,12 +70,14 @@ RSpec.describe API::Projects do builds_enabled: false, snippets_enabled: false) end + let(:project_member2) do create(:project_member, user: user4, project: project3, access_level: ProjectMember::MAINTAINER) end + let(:project4) do create(:project, name: 'third_project', diff --git a/spec/requests/api/snippets_spec.rb b/spec/requests/api/snippets_spec.rb index 57131ed8c5b..4e2f6e108eb 100644 --- a/spec/requests/api/snippets_spec.rb +++ b/spec/requests/api/snippets_spec.rb @@ -233,6 +233,7 @@ RSpec.describe API::Snippets do visibility: 'public' } end + let(:file_path) { 'file_1.rb' } let(:file_content) { 'puts "hello world"' } diff --git a/spec/requests/groups/milestones_controller_spec.rb b/spec/requests/groups/milestones_controller_spec.rb index 2c4d97ec4c3..4afdde8be04 100644 --- a/spec/requests/groups/milestones_controller_spec.rb +++ b/spec/requests/groups/milestones_controller_spec.rb @@ -10,6 +10,7 @@ RSpec.describe Groups::MilestonesController do let!(:public_project_with_private_issues_and_mrs) do create(:project, :public, :issues_private, :merge_requests_private, group: public_group) end + let!(:private_milestone) { create(:milestone, project: public_project_with_private_issues_and_mrs, title: 'project milestone') } describe 'GET #index' do diff --git a/spec/requests/lfs_http_spec.rb b/spec/requests/lfs_http_spec.rb index 0ae3feba4ba..7a06fe21e60 100644 --- a/spec/requests/lfs_http_spec.rb +++ b/spec/requests/lfs_http_spec.rb @@ -17,6 +17,7 @@ RSpec.describe 'Git LFS API and storage' do 'X-Sendfile-Type' => sendfile }.compact end + let(:include_workhorse_jwt_header) { true } let(:authorization) { } let(:sendfile) { } diff --git a/spec/requests/rack_attack_global_spec.rb b/spec/requests/rack_attack_global_spec.rb index 106515a6b13..444ee478cbb 100644 --- a/spec/requests/rack_attack_global_spec.rb +++ b/spec/requests/rack_attack_global_spec.rb @@ -227,6 +227,7 @@ RSpec.describe 'Rack Attack global throttles' do let(:protected_path_that_does_not_require_authentication) do '/users/sign_in' end + let(:post_params) { { user: { login: 'username', password: 'password' } } } before do diff --git a/spec/rubocop/cop/gitlab/finder_with_find_by_spec.rb b/spec/rubocop/cop/gitlab/finder_with_find_by_spec.rb index 30ee422f420..a47625d5dc1 100644 --- a/spec/rubocop/cop/gitlab/finder_with_find_by_spec.rb +++ b/spec/rubocop/cop/gitlab/finder_with_find_by_spec.rb @@ -20,6 +20,7 @@ RSpec.describe RuboCop::Cop::Gitlab::FinderWithFindBy, type: :rubocop do .find_by!(1) SRC end + let(:corrected_source) do <<~SRC DummyFinder.new(some_args) diff --git a/spec/rubocop/cop/rspec/any_instance_of_spec.rb b/spec/rubocop/cop/rspec/any_instance_of_spec.rb index 11c0f109850..971e28853a3 100644 --- a/spec/rubocop/cop/rspec/any_instance_of_spec.rb +++ b/spec/rubocop/cop/rspec/any_instance_of_spec.rb @@ -15,6 +15,7 @@ RSpec.describe RuboCop::Cop::RSpec::AnyInstanceOf, type: :rubocop do allow_any_instance_of(User).to receive(:invalidate_issue_cache_counts) SRC end + let(:corrected_source) do <<~SRC allow_next_instance_of(User) do |instance| @@ -40,6 +41,7 @@ RSpec.describe RuboCop::Cop::RSpec::AnyInstanceOf, type: :rubocop do expect_any_instance_of(User).to receive(:invalidate_issue_cache_counts).with(args).and_return(double) SRC end + let(:corrected_source) do <<~SRC expect_next_instance_of(User) do |instance| diff --git a/spec/serializers/accessibility_reports_comparer_entity_spec.rb b/spec/serializers/accessibility_reports_comparer_entity_spec.rb index 3024974710e..c576dfa4dd1 100644 --- a/spec/serializers/accessibility_reports_comparer_entity_spec.rb +++ b/spec/serializers/accessibility_reports_comparer_entity_spec.rb @@ -22,6 +22,7 @@ RSpec.describe AccessibilityReportsComparerEntity do } ] end + let(:different_error) do [ { diff --git a/spec/serializers/accessibility_reports_comparer_serializer_spec.rb b/spec/serializers/accessibility_reports_comparer_serializer_spec.rb index ef56f5b6b6b..94d2a2a4065 100644 --- a/spec/serializers/accessibility_reports_comparer_serializer_spec.rb +++ b/spec/serializers/accessibility_reports_comparer_serializer_spec.rb @@ -23,6 +23,7 @@ RSpec.describe AccessibilityReportsComparerSerializer do } ] end + let(:different_error) do [ { diff --git a/spec/serializers/ci/daily_build_group_report_result_serializer_spec.rb b/spec/serializers/ci/daily_build_group_report_result_serializer_spec.rb index 69bf599c0dd..ddeeb367afe 100644 --- a/spec/serializers/ci/daily_build_group_report_result_serializer_spec.rb +++ b/spec/serializers/ci/daily_build_group_report_result_serializer_spec.rb @@ -11,6 +11,7 @@ RSpec.describe Ci::DailyBuildGroupReportResultSerializer do double(date: '2020-05-19', group_name: 'karma', data: { 'coverage' => 89.1 }) ] end + let(:serializer) { described_class.new.represent(report_result, param_type: 'coverage') } describe '#to_json' do diff --git a/spec/serializers/commit_entity_spec.rb b/spec/serializers/commit_entity_spec.rb index e2ea63893a4..6b4346faf5b 100644 --- a/spec/serializers/commit_entity_spec.rb +++ b/spec/serializers/commit_entity_spec.rb @@ -8,6 +8,7 @@ RSpec.describe CommitEntity do let(:entity) do described_class.new(commit, request: request) end + let(:request) { double('request') } let(:project) { create(:project, :repository) } let(:commit) { project.commit } diff --git a/spec/serializers/diff_file_base_entity_spec.rb b/spec/serializers/diff_file_base_entity_spec.rb index 153f854aa58..bf69a50a072 100644 --- a/spec/serializers/diff_file_base_entity_spec.rb +++ b/spec/serializers/diff_file_base_entity_spec.rb @@ -11,6 +11,7 @@ RSpec.describe DiffFileBaseEntity do let(:commit_sha_with_changed_submodule) do "cfe32cf61b73a0d5e9f13e774abde7ff789b1660" end + let(:commit) { project.commit(commit_sha_with_changed_submodule) } let(:options) { { request: {}, submodule_links: Gitlab::SubmoduleLinks.new(repository) } } let(:diff_file) { commit.diffs.diff_files.to_a.last } diff --git a/spec/serializers/environment_serializer_spec.rb b/spec/serializers/environment_serializer_spec.rb index 1e3980b7720..1eba9ae4e5e 100644 --- a/spec/serializers/environment_serializer_spec.rb +++ b/spec/serializers/environment_serializer_spec.rb @@ -26,6 +26,7 @@ RSpec.describe EnvironmentSerializer do project: project, sha: project.commit.id) end + let(:resource) { deployment.environment } before do diff --git a/spec/serializers/import/bitbucket_provider_repo_entity_spec.rb b/spec/serializers/import/bitbucket_provider_repo_entity_spec.rb index 2a0386b779f..d59a476961e 100644 --- a/spec/serializers/import/bitbucket_provider_repo_entity_spec.rb +++ b/spec/serializers/import/bitbucket_provider_repo_entity_spec.rb @@ -17,6 +17,7 @@ RSpec.describe Import::BitbucketProviderRepoEntity do } } end + let(:repo) { Bitbucket::Representation::Repo.new(repo_data) } subject { described_class.new(repo).as_json } diff --git a/spec/serializers/import/bitbucket_server_provider_repo_entity_spec.rb b/spec/serializers/import/bitbucket_server_provider_repo_entity_spec.rb index 6e00d608d9a..8fe9fa16904 100644 --- a/spec/serializers/import/bitbucket_server_provider_repo_entity_spec.rb +++ b/spec/serializers/import/bitbucket_server_provider_repo_entity_spec.rb @@ -19,6 +19,7 @@ RSpec.describe Import::BitbucketServerProviderRepoEntity do } } end + let(:repo) { BitbucketServer::Representation::Repo.new(repo_data) } subject { described_class.new(repo).as_json } diff --git a/spec/serializers/import/fogbugz_provider_repo_entity_spec.rb b/spec/serializers/import/fogbugz_provider_repo_entity_spec.rb index 748ddd2a108..62bb0addb87 100644 --- a/spec/serializers/import/fogbugz_provider_repo_entity_spec.rb +++ b/spec/serializers/import/fogbugz_provider_repo_entity_spec.rb @@ -10,6 +10,7 @@ RSpec.describe Import::FogbugzProviderRepoEntity do 'sProject' => 'demo' } end + let(:repo) { Gitlab::FogbugzImport::Repository.new(repo_data) } subject { described_class.represent(repo, { provider_url: provider_url }).as_json } diff --git a/spec/serializers/paginated_diff_entity_spec.rb b/spec/serializers/paginated_diff_entity_spec.rb index 30360b00537..a2c58baed55 100644 --- a/spec/serializers/paginated_diff_entity_spec.rb +++ b/spec/serializers/paginated_diff_entity_spec.rb @@ -14,6 +14,7 @@ RSpec.describe PaginatedDiffEntity do pagination_data: diff_batch.pagination_data } end + let(:entity) { described_class.new(diff_batch, options) } subject { entity.as_json } diff --git a/spec/services/ci/create_pipeline_service_spec.rb b/spec/services/ci/create_pipeline_service_spec.rb index f6082ab08b1..251020828e3 100644 --- a/spec/services/ci/create_pipeline_service_spec.rb +++ b/spec/services/ci/create_pipeline_service_spec.rb @@ -93,6 +93,7 @@ RSpec.describe Ci::CreatePipelineService do let(:merge_request_1) do create(:merge_request, source_branch: 'feature', target_branch: "master", source_project: project) end + let(:merge_request_2) do create(:merge_request, source_branch: 'feature', target_branch: "v1.1.0", source_project: project) end diff --git a/spec/services/ci/daily_build_group_report_result_service_spec.rb b/spec/services/ci/daily_build_group_report_result_service_spec.rb index 7d181a5c2ba..f196afb05e8 100644 --- a/spec/services/ci/daily_build_group_report_result_service_spec.rb +++ b/spec/services/ci/daily_build_group_report_result_service_spec.rb @@ -65,6 +65,7 @@ RSpec.describe Ci::DailyBuildGroupReportResultService, '#execute' do created_at: '2020-02-06 00:02:20' ) end + let!(:new_rspec_job) { create(:ci_build, pipeline: new_pipeline, name: '4/4 rspec', coverage: 84) } let!(:new_karma_job) { create(:ci_build, pipeline: new_pipeline, name: '3/3 karma', coverage: 92) } @@ -104,6 +105,7 @@ RSpec.describe Ci::DailyBuildGroupReportResultService, '#execute' do created_at: '2020-02-06 00:02:20' ) end + let!(:new_rspec_job) { create(:ci_build, pipeline: new_pipeline, name: '4/4 rspec', coverage: 84) } let!(:new_karma_job) { create(:ci_build, pipeline: new_pipeline, name: '3/3 karma', coverage: 92) } @@ -149,6 +151,7 @@ RSpec.describe Ci::DailyBuildGroupReportResultService, '#execute' do created_at: '2020-02-06 00:02:20' ) end + let!(:some_job) { create(:ci_build, pipeline: new_pipeline, name: 'foo') } it 'does nothing' do diff --git a/spec/services/clusters/cleanup/project_namespace_service_spec.rb b/spec/services/clusters/cleanup/project_namespace_service_spec.rb index 761ad8dd8c8..605aaea17e4 100644 --- a/spec/services/clusters/cleanup/project_namespace_service_spec.rb +++ b/spec/services/clusters/cleanup/project_namespace_service_spec.rb @@ -16,6 +16,7 @@ RSpec.describe Clusters::Cleanup::ProjectNamespaceService do execution_count: 0 } end + let(:kubeclient_instance_double) do instance_double(Gitlab::Kubernetes::KubeClient, delete_namespace: nil, delete_service_account: nil) end diff --git a/spec/services/clusters/cleanup/service_account_service_spec.rb b/spec/services/clusters/cleanup/service_account_service_spec.rb index 6fe3d0c286e..f256df1b2fc 100644 --- a/spec/services/clusters/cleanup/service_account_service_spec.rb +++ b/spec/services/clusters/cleanup/service_account_service_spec.rb @@ -16,6 +16,7 @@ RSpec.describe Clusters::Cleanup::ServiceAccountService do execution_count: 0 } end + let(:kubeclient_instance_double) do instance_double(Gitlab::Kubernetes::KubeClient, delete_namespace: nil, delete_service_account: nil) end diff --git a/spec/services/commits/commit_patch_service_spec.rb b/spec/services/commits/commit_patch_service_spec.rb index c8c0cbe23b2..55cbd0e5d66 100644 --- a/spec/services/commits/commit_patch_service_spec.rb +++ b/spec/services/commits/commit_patch_service_spec.rb @@ -10,6 +10,7 @@ RSpec.describe Commits::CommitPatchService do [content_1, content_2] end + let(:user) { project.creator } let(:branch_name) { 'branch-with-patches' } let(:project) { create(:project, :repository) } diff --git a/spec/services/git/base_hooks_service_spec.rb b/spec/services/git/base_hooks_service_spec.rb index 661c77b56bb..4ab27c7ab05 100644 --- a/spec/services/git/base_hooks_service_spec.rb +++ b/spec/services/git/base_hooks_service_spec.rb @@ -171,6 +171,7 @@ RSpec.describe Git::BaseHooksService do } } end + let(:variables_attributes) { [] } before do @@ -192,6 +193,7 @@ RSpec.describe Git::BaseHooksService do } } end + let(:variables_attributes) do [ { "key" => "FOO", "variable_type" => "env_var", "secret_value" => "123" }, @@ -219,6 +221,7 @@ RSpec.describe Git::BaseHooksService do } } end + let(:variables_attributes) do [ { "key" => "FOO", "variable_type" => "env_var", "secret_value" => "123" } diff --git a/spec/services/git/process_ref_changes_service_spec.rb b/spec/services/git/process_ref_changes_service_spec.rb index d2d5ac5a7e8..fc313bf6eb9 100644 --- a/spec/services/git/process_ref_changes_service_spec.rb +++ b/spec/services/git/process_ref_changes_service_spec.rb @@ -167,6 +167,7 @@ RSpec.describe Git::ProcessRefChangesService do { index: 0, oldrev: Gitlab::Git::BLANK_SHA, newrev: '789012', ref: "refs/tags/v10.0.0" } ] end + let(:branch_changes) do [ { index: 0, oldrev: Gitlab::Git::BLANK_SHA, newrev: '789012', ref: "#{ref_prefix}/create1" }, @@ -174,6 +175,7 @@ RSpec.describe Git::ProcessRefChangesService do { index: 2, oldrev: Gitlab::Git::BLANK_SHA, newrev: '789014', ref: "#{ref_prefix}/create3" } ] end + let(:git_changes) { double(branch_changes: branch_changes, tag_changes: tag_changes) } it 'schedules job for existing merge requests' do diff --git a/spec/services/groups/group_links/create_service_spec.rb b/spec/services/groups/group_links/create_service_spec.rb index bca03863d1e..fb88433d8f6 100644 --- a/spec/services/groups/group_links/create_service_spec.rb +++ b/spec/services/groups/group_links/create_service_spec.rb @@ -25,6 +25,7 @@ RSpec.describe Groups::GroupLinks::CreateService, '#execute' do expires_at: nil } end + let(:user) { group_user } subject { described_class.new(group, user, opts) } diff --git a/spec/services/issuable/clone/content_rewriter_spec.rb b/spec/services/issuable/clone/content_rewriter_spec.rb index f39439b7c2f..b1cef0789b3 100644 --- a/spec/services/issuable/clone/content_rewriter_spec.rb +++ b/spec/services/issuable/clone/content_rewriter_spec.rb @@ -93,6 +93,7 @@ RSpec.describe Issuable::Clone::ContentRewriter do create(:note, system: true, noteable: original_issue, project: project1) ] end + let!(:system_note_metadata) { create(:system_note_metadata, note: notes.last) } let!(:award_emoji) { create(:award_emoji, awardable: notes.first, name: 'thumbsup')} @@ -136,6 +137,7 @@ RSpec.describe Issuable::Clone::ContentRewriter do let(:text) do "See ##{other_issue.iid} and #{merge_request.project.full_path}!#{merge_request.iid}" end + let!(:note) { create(:note, noteable: original_issue, note: text, project: project1) } it 'rewrites the references correctly' do diff --git a/spec/services/merge_requests/conflicts/resolve_service_spec.rb b/spec/services/merge_requests/conflicts/resolve_service_spec.rb index c4d50124ca9..0abc70f71b0 100644 --- a/spec/services/merge_requests/conflicts/resolve_service_spec.rb +++ b/spec/services/merge_requests/conflicts/resolve_service_spec.rb @@ -205,6 +205,7 @@ RSpec.describe MergeRequests::Conflicts::ResolveService do let(:resolver) do MergeRequests::Conflicts::ListService.new(merge_request).conflicts.resolver end + let(:regex_conflict) do resolver.conflict_for_path(resolver.conflicts, 'files/ruby/regex.rb', 'files/ruby/regex.rb') end diff --git a/spec/services/merge_requests/create_service_spec.rb b/spec/services/merge_requests/create_service_spec.rb index a8661f027e8..bb62e594e7a 100644 --- a/spec/services/merge_requests/create_service_spec.rb +++ b/spec/services/merge_requests/create_service_spec.rb @@ -347,6 +347,7 @@ RSpec.describe MergeRequests::CreateService, :clean_gitlab_redis_shared_state do target_branch: 'master' } end + let(:issuable) { described_class.new(project, user, params).execute } end diff --git a/spec/services/merge_requests/ff_merge_service_spec.rb b/spec/services/merge_requests/ff_merge_service_spec.rb index b4e3516eb9d..55856deeaca 100644 --- a/spec/services/merge_requests/ff_merge_service_spec.rb +++ b/spec/services/merge_requests/ff_merge_service_spec.rb @@ -12,6 +12,7 @@ RSpec.describe MergeRequests::FfMergeService do assignees: [user2], author: create(:user)) end + let(:project) { merge_request.project } let(:valid_merge_params) { { sha: merge_request.diff_head_sha } } diff --git a/spec/services/merge_requests/rebase_service_spec.rb b/spec/services/merge_requests/rebase_service_spec.rb index 2e525f2ed01..653fcf12a76 100644 --- a/spec/services/merge_requests/rebase_service_spec.rb +++ b/spec/services/merge_requests/rebase_service_spec.rb @@ -13,6 +13,7 @@ RSpec.describe MergeRequests::RebaseService do target_branch: 'master', rebase_jid: rebase_jid end + let(:project) { merge_request.project } let(:repository) { project.repository.raw } let(:skip_ci) { false } diff --git a/spec/services/merge_requests/refresh_service_spec.rb b/spec/services/merge_requests/refresh_service_spec.rb index 18c4cef7087..0696e8a247f 100644 --- a/spec/services/merge_requests/refresh_service_spec.rb +++ b/spec/services/merge_requests/refresh_service_spec.rb @@ -555,11 +555,13 @@ RSpec.describe MergeRequests::RefreshService do message: 'Test commit', branch_name: 'master') end + let!(:second_commit) do @fork_project.repository.create_file(@user, 'test2.txt', 'More test data', message: 'Second test commit', branch_name: 'master') end + let!(:forked_master_mr) do create(:merge_request, source_project: @fork_project, @@ -567,6 +569,7 @@ RSpec.describe MergeRequests::RefreshService do target_branch: 'master', target_project: @project) end + let(:force_push_commit) { @project.commit('feature').id } it 'reloads a new diff for a push to the forked project' do diff --git a/spec/services/merge_requests/squash_service_spec.rb b/spec/services/merge_requests/squash_service_spec.rb index 1ec1dc0f6eb..acbd0a42fcd 100644 --- a/spec/services/merge_requests/squash_service_spec.rb +++ b/spec/services/merge_requests/squash_service_spec.rb @@ -13,6 +13,7 @@ RSpec.describe MergeRequests::SquashService do let(:squash_dir_path) do File.join(Gitlab.config.shared.path, 'tmp/squash', repository.gl_repository, merge_request.id.to_s) end + let(:merge_request_with_one_commit) do create(:merge_request, source_branch: 'feature', source_project: project, diff --git a/spec/services/metrics/dashboard/cluster_metrics_embed_service_spec.rb b/spec/services/metrics/dashboard/cluster_metrics_embed_service_spec.rb index e80911d6265..dbb89af45d0 100644 --- a/spec/services/metrics/dashboard/cluster_metrics_embed_service_spec.rb +++ b/spec/services/metrics/dashboard/cluster_metrics_embed_service_spec.rb @@ -52,6 +52,7 @@ RSpec.describe Metrics::Dashboard::ClusterMetricsEmbedService, :use_clean_rails_ } ] end + let(:service_call) { described_class.new(*service_params).get_dashboard } let(:panel_groups) { service_call[:dashboard][:panel_groups] } let(:panel) { panel_groups.first[:panels].first } diff --git a/spec/services/notes/create_service_spec.rb b/spec/services/notes/create_service_spec.rb index fd824621db7..15defd7e22f 100644 --- a/spec/services/notes/create_service_spec.rb +++ b/spec/services/notes/create_service_spec.rb @@ -117,6 +117,7 @@ RSpec.describe Notes::CreateService do source_project: project_with_repo, target_project: project_with_repo) end + let(:line_number) { 14 } let(:position) do Gitlab::Diff::Position.new(old_path: "files/ruby/popen.rb", @@ -125,6 +126,7 @@ RSpec.describe Notes::CreateService do new_line: line_number, diff_refs: merge_request.diff_refs) end + let(:previous_note) do create(:diff_note_on_merge_request, noteable: merge_request, project: project_with_repo) end diff --git a/spec/services/packages/create_dependency_service_spec.rb b/spec/services/packages/create_dependency_service_spec.rb index 00e5e5c6d96..3ad59b31b2c 100644 --- a/spec/services/packages/create_dependency_service_spec.rb +++ b/spec/services/packages/create_dependency_service_spec.rb @@ -15,6 +15,7 @@ RSpec.describe Packages::CreateDependencyService do .gsub('1.0.1', version)) .with_indifferent_access end + let(:package_version) { params[:versions].each_key.first } let(:dependencies) { params[:versions][package_version] } let(:package) { create(:npm_package) } diff --git a/spec/services/packages/npm/create_package_service_spec.rb b/spec/services/packages/npm/create_package_service_spec.rb index 25bbbf82bec..c1391746f52 100644 --- a/spec/services/packages/npm/create_package_service_spec.rb +++ b/spec/services/packages/npm/create_package_service_spec.rb @@ -13,6 +13,7 @@ RSpec.describe Packages::Npm::CreatePackageService do .gsub('1.0.1', version)).with_indifferent_access .merge!(override) end + let(:override) { {} } let(:package_name) { "@#{namespace.path}/my-app".freeze } diff --git a/spec/services/pod_logs/elasticsearch_service_spec.rb b/spec/services/pod_logs/elasticsearch_service_spec.rb index 9431e47c6f2..e233abcd96a 100644 --- a/spec/services/pod_logs/elasticsearch_service_spec.rb +++ b/spec/services/pod_logs/elasticsearch_service_spec.rb @@ -243,6 +243,7 @@ RSpec.describe ::PodLogs::ElasticsearchService do cursor: cursor } end + let(:expected_cursor) { '9999934,1572449784442' } before do diff --git a/spec/services/preview_markdown_service_spec.rb b/spec/services/preview_markdown_service_spec.rb index 2509d1300b3..53f8f5b7253 100644 --- a/spec/services/preview_markdown_service_spec.rb +++ b/spec/services/preview_markdown_service_spec.rb @@ -25,12 +25,14 @@ RSpec.describe PreviewMarkdownService do let(:merge_request) do create(:merge_request, target_project: project, source_project: project) end + let(:text) { "```suggestion\nfoo\n```" } let(:params) do suggestion_params.merge(text: text, target_type: 'MergeRequest', target_id: merge_request.iid) end + let(:service) { described_class.new(project, user, params) } context 'when preview markdown param is present' do @@ -106,6 +108,7 @@ RSpec.describe PreviewMarkdownService do target_id: issue.id } end + let(:service) { described_class.new(project, user, params) } it 'removes quick actions from text' do @@ -128,6 +131,7 @@ RSpec.describe PreviewMarkdownService do target_type: 'MergeRequest' } end + let(:service) { described_class.new(project, user, params) } it 'removes quick actions from text' do @@ -153,6 +157,7 @@ RSpec.describe PreviewMarkdownService do target_id: commit.id } end + let(:service) { described_class.new(project, user, params) } it 'removes quick actions from text' do diff --git a/spec/services/projects/alerting/notify_service_spec.rb b/spec/services/projects/alerting/notify_service_spec.rb index 3398fe26b55..3e74a15c3c0 100644 --- a/spec/services/projects/alerting/notify_service_spec.rb +++ b/spec/services/projects/alerting/notify_service_spec.rb @@ -66,6 +66,7 @@ RSpec.describe Projects::Alerting::NotifyService do fingerprint: fingerprint }.with_indifferent_access end + let(:payload) { ActionController::Parameters.new(payload_raw).permit! } subject { service.execute(token) } diff --git a/spec/services/projects/fork_service_spec.rb b/spec/services/projects/fork_service_spec.rb index 1e4038fab79..925c2ff5d88 100644 --- a/spec/services/projects/fork_service_spec.rb +++ b/spec/services/projects/fork_service_spec.rb @@ -105,6 +105,7 @@ RSpec.describe Projects::ForkService do group.add_owner(@to_user) group end + let(:to_project) { fork_project(from_forked_project, @to_user, namespace: other_namespace) } it 'sets the root of the network to the root project' do diff --git a/spec/services/projects/operations/update_service_spec.rb b/spec/services/projects/operations/update_service_spec.rb index 3cfc9844d65..8a538bc67ed 100644 --- a/spec/services/projects/operations/update_service_spec.rb +++ b/spec/services/projects/operations/update_service_spec.rb @@ -384,6 +384,7 @@ RSpec.describe Projects::Operations::UpdateService do manual_configuration: "0" }) end + let(:params) do { prometheus_integration_attributes: { diff --git a/spec/services/releases/create_service_spec.rb b/spec/services/releases/create_service_spec.rb index 3c0698aa203..ad4696b0074 100644 --- a/spec/services/releases/create_service_spec.rb +++ b/spec/services/releases/create_service_spec.rb @@ -198,6 +198,7 @@ RSpec.describe Releases::CreateService do released_at: released_at }.compact end + let(:last_release) { project.releases.last } around do |example| diff --git a/spec/services/snippets/create_service_spec.rb b/spec/services/snippets/create_service_spec.rb index 62eef00b67f..2106a9c2045 100644 --- a/spec/services/snippets/create_service_spec.rb +++ b/spec/services/snippets/create_service_spec.rb @@ -15,6 +15,7 @@ RSpec.describe Snippets::CreateService do visibility_level: Gitlab::VisibilityLevel::PRIVATE } end + let(:extra_opts) { {} } let(:creator) { admin } diff --git a/spec/services/snippets/update_service_spec.rb b/spec/services/snippets/update_service_spec.rb index 66dddcc49de..638fe1948fd 100644 --- a/spec/services/snippets/update_service_spec.rb +++ b/spec/services/snippets/update_service_spec.rb @@ -15,6 +15,7 @@ RSpec.describe Snippets::UpdateService do visibility_level: visibility_level } end + let(:extra_opts) { {} } let(:options) { base_opts.merge(extra_opts) } let(:updater) { user } diff --git a/spec/services/spam/spam_action_service_spec.rb b/spec/services/spam/spam_action_service_spec.rb index abb8e49ec52..8edd9406bce 100644 --- a/spec/services/spam/spam_action_service_spec.rb +++ b/spec/services/spam/spam_action_service_spec.rb @@ -13,6 +13,7 @@ RSpec.describe Spam::SpamActionService do 'HTTP_USER_AGENT' => fake_user_agent, 'HTTP_REFERRER' => fake_referrer } end + let(:request) { double(:request, env: env) } let_it_be(:project) { create(:project, :public) } diff --git a/spec/services/spam/spam_verdict_service_spec.rb b/spec/services/spam/spam_verdict_service_spec.rb index d775e1bdfb5..14b788e3a86 100644 --- a/spec/services/spam/spam_verdict_service_spec.rb +++ b/spec/services/spam/spam_verdict_service_spec.rb @@ -13,6 +13,7 @@ RSpec.describe Spam::SpamVerdictService do 'HTTP_USER_AGENT' => fake_user_agent, 'HTTP_REFERRER' => fake_referrer } end + let(:request) { double(:request, env: env) } let(:check_for_spam) { true } diff --git a/spec/services/suggestions/create_service_spec.rb b/spec/services/suggestions/create_service_spec.rb index 54e7c5cc127..80823364fe8 100644 --- a/spec/services/suggestions/create_service_spec.rb +++ b/spec/services/suggestions/create_service_spec.rb @@ -159,6 +159,7 @@ RSpec.describe Suggestions::CreateService do ``` MARKDOWN end + let(:position) { build_position(new_line: 13) } it 'creates an appliable suggestion' do diff --git a/spec/services/system_notes/design_management_service_spec.rb b/spec/services/system_notes/design_management_service_spec.rb index 6267ad2aaad..19e1f338eb8 100644 --- a/spec/services/system_notes/design_management_service_spec.rb +++ b/spec/services/system_notes/design_management_service_spec.rb @@ -134,6 +134,7 @@ RSpec.describe SystemNotes::DesignManagementService do let(:discussion_note) do create(:diff_note_on_design, noteable: design, author: author) end + let(:action) { 'designs_discussion_added' } it_behaves_like 'a system note' do diff --git a/spec/services/users/create_service_spec.rb b/spec/services/users/create_service_spec.rb index 69d2d6ca9ff..9040966215c 100644 --- a/spec/services/users/create_service_spec.rb +++ b/spec/services/users/create_service_spec.rb @@ -154,6 +154,7 @@ RSpec.describe Users::CreateService do let(:params) do { name: 'John Doe', username: 'jduser', email: 'jd@example.com', password: 'mydummypass', skip_confirmation: true } end + let(:service) { described_class.new(nil, params) } it 'persists the given attributes' do diff --git a/spec/services/web_hook_service_spec.rb b/spec/services/web_hook_service_spec.rb index 2be481c5b62..02d36ed5aba 100644 --- a/spec/services/web_hook_service_spec.rb +++ b/spec/services/web_hook_service_spec.rb @@ -13,9 +13,11 @@ RSpec.describe WebHookService do 'X-Gitlab-Event' => 'Push Hook' } end + let(:data) do { before: 'oldrev', after: 'newrev', ref: 'ref' } end + let(:service_instance) { described_class.new(project_hook, data, :push_hooks) } describe '#initialize' do diff --git a/spec/services/wikis/create_attachment_service_spec.rb b/spec/services/wikis/create_attachment_service_spec.rb index 50cb9ac111c..22e34e1f373 100644 --- a/spec/services/wikis/create_attachment_service_spec.rb +++ b/spec/services/wikis/create_attachment_service_spec.rb @@ -13,6 +13,7 @@ RSpec.describe Wikis::CreateAttachmentService do file_content: 'Content of attachment' } end + let(:opts) { file_opts } subject(:service) { described_class.new(container: container, current_user: user, params: opts) } diff --git a/spec/support/shared_contexts/finders/merge_requests_finder_shared_contexts.rb b/spec/support/shared_contexts/finders/merge_requests_finder_shared_contexts.rb index 07b6b98222f..010c445d8df 100644 --- a/spec/support/shared_contexts/finders/merge_requests_finder_shared_contexts.rb +++ b/spec/support/shared_contexts/finders/merge_requests_finder_shared_contexts.rb @@ -28,6 +28,7 @@ RSpec.shared_context 'MergeRequestsFinder multiple projects with merge requests fork_project(project1, user) end end + let!(:project3) do allow_gitaly_n_plus_1 do fork_project(project1, user).tap do |project| @@ -35,6 +36,7 @@ RSpec.shared_context 'MergeRequestsFinder multiple projects with merge requests end end end + let_it_be(:project4, reload: true) do allow_gitaly_n_plus_1 { create(:project, :repository, group: subgroup) } end @@ -53,22 +55,26 @@ RSpec.shared_context 'MergeRequestsFinder multiple projects with merge requests source_project: project2, target_project: project1, target_branch: 'merged-target') end + let!(:merge_request2) do create(:merge_request, :conflict, assignees: [user], author: user, source_project: project2, target_project: project1, state: 'closed') end + let!(:merge_request3) do create(:merge_request, :simple, author: user, assignees: [user2], source_project: project2, target_project: project2, state: 'locked', title: 'thing WIP thing') end + let!(:merge_request4) do create(:merge_request, :simple, author: user, source_project: project3, target_project: project3, title: 'WIP thing') end + let_it_be(:merge_request5) do create(:merge_request, :simple, author: user, source_project: project4, target_project: project4, diff --git a/spec/support/shared_contexts/policies/group_policy_shared_context.rb b/spec/support/shared_contexts/policies/group_policy_shared_context.rb index 4b0c7afab6d..af46e5474b0 100644 --- a/spec/support/shared_contexts/policies/group_policy_shared_context.rb +++ b/spec/support/shared_contexts/policies/group_policy_shared_context.rb @@ -17,6 +17,7 @@ RSpec.shared_context 'GroupPolicy context' do read_group_merge_requests ] end + let(:read_group_permissions) { %i[read_label read_list read_milestone read_board] } let(:reporter_permissions) { %i[admin_label read_container_image read_metrics_dashboard_annotation read_prometheus] } let(:developer_permissions) { %i[admin_milestone create_metrics_dashboard_annotation delete_metrics_dashboard_annotation update_metrics_dashboard_annotation] } @@ -26,6 +27,7 @@ RSpec.shared_context 'GroupPolicy context' do read_cluster create_cluster update_cluster admin_cluster add_cluster ] end + let(:owner_permissions) do [ :admin_group, @@ -38,6 +40,7 @@ RSpec.shared_context 'GroupPolicy context' do :update_default_branch_protection ].compact end + let(:admin_permissions) { %i[read_confidential_issues] } before_all do diff --git a/spec/support/shared_examples/controllers/metrics/dashboard/prometheus_api_proxy_shared_examples.rb b/spec/support/shared_examples/controllers/metrics/dashboard/prometheus_api_proxy_shared_examples.rb index 94cd6971f7c..19b1cee44ee 100644 --- a/spec/support/shared_examples/controllers/metrics/dashboard/prometheus_api_proxy_shared_examples.rb +++ b/spec/support/shared_examples/controllers/metrics/dashboard/prometheus_api_proxy_shared_examples.rb @@ -9,6 +9,7 @@ RSpec.shared_examples_for 'metrics dashboard prometheus api proxy' do id: proxyable.id.to_s } end + let(:expected_params) do ActionController::Parameters.new( prometheus_proxy_params( diff --git a/spec/support/shared_examples/controllers/variables_shared_examples.rb b/spec/support/shared_examples/controllers/variables_shared_examples.rb index 9ff0bc3d217..34632993cf0 100644 --- a/spec/support/shared_examples/controllers/variables_shared_examples.rb +++ b/spec/support/shared_examples/controllers/variables_shared_examples.rb @@ -21,6 +21,7 @@ RSpec.shared_examples 'PATCH #update updates variables' do secret_value: variable.value, protected: variable.protected?.to_s } end + let(:new_variable_attributes) do { key: 'new_key', secret_value: 'dummy_value', 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 029d7e677da..ef7086234c4 100644 --- a/spec/support/shared_examples/graphql/design_fields_shared_examples.rb +++ b/spec/support/shared_examples/graphql/design_fields_shared_examples.rb @@ -35,6 +35,7 @@ RSpec.shared_examples 'a GraphQL type with design fields' do object = GitlabSchema.sync_lazy(GitlabSchema.object_from_id(object_id)) object_type.authorized_new(object, query.context) end + let(:instance_b) do object_b = GitlabSchema.sync_lazy(GitlabSchema.object_from_id(object_id_b)) object_type.authorized_new(object_b, query.context) diff --git a/spec/support/shared_examples/graphql/notes_on_noteables_shared_examples.rb b/spec/support/shared_examples/graphql/notes_on_noteables_shared_examples.rb index e1dd98814f1..41b7da07d2d 100644 --- a/spec/support/shared_examples/graphql/notes_on_noteables_shared_examples.rb +++ b/spec/support/shared_examples/graphql/notes_on_noteables_shared_examples.rb @@ -8,6 +8,7 @@ RSpec.shared_context 'exposing regular notes on a noteable in GraphQL' do noteable: noteable, project: (noteable.project if noteable.respond_to?(:project))) end + let(:user) { note.author } context 'for regular notes' do diff --git a/spec/support/shared_examples/models/chat_service_shared_examples.rb b/spec/support/shared_examples/models/chat_service_shared_examples.rb index 0a1c27b32db..ad237ad9f49 100644 --- a/spec/support/shared_examples/models/chat_service_shared_examples.rb +++ b/spec/support/shared_examples/models/chat_service_shared_examples.rb @@ -198,6 +198,7 @@ RSpec.shared_examples "chat service" do |service_name| message: "user created page: Awesome wiki_page" } end + let(:wiki_page) { create(:wiki_page, wiki: project.wiki, **opts) } let(:sample_data) { Gitlab::DataBuilder::WikiPage.build(wiki_page, user, "create") } @@ -250,6 +251,7 @@ RSpec.shared_examples "chat service" do |service_name| project: project, status: status, sha: project.commit.sha, ref: project.default_branch) end + let(:sample_data) { Gitlab::DataBuilder::Pipeline.build(pipeline) } context "with failed pipeline" do diff --git a/spec/support/shared_examples/models/issuable_hook_data_shared_examples.rb b/spec/support/shared_examples/models/issuable_hook_data_shared_examples.rb index 21ab9b06c33..13ffc1b7f87 100644 --- a/spec/support/shared_examples/models/issuable_hook_data_shared_examples.rb +++ b/spec/support/shared_examples/models/issuable_hook_data_shared_examples.rb @@ -38,6 +38,7 @@ RSpec.shared_examples 'issuable hook data' do |kind| title_html: %w[foo bar] } end + let(:data) { builder.build(user: user, changes: changes) } it 'populates the :changes hash' do diff --git a/spec/support/shared_examples/requests/api/milestones_shared_examples.rb b/spec/support/shared_examples/requests/api/milestones_shared_examples.rb index 77b49b7caef..249a7b7cdac 100644 --- a/spec/support/shared_examples/requests/api/milestones_shared_examples.rb +++ b/spec/support/shared_examples/requests/api/milestones_shared_examples.rb @@ -266,6 +266,7 @@ RSpec.shared_examples 'group and project milestones' do |route_definition| let!(:milestone) do context_group ? create(:milestone, group: context_group) : create(:milestone, project: public_project) end + let!(:issue) { create(:issue, project: public_project) } let!(:confidential_issue) { create(:issue, confidential: true, project: public_project) } let!(:issues_route) do diff --git a/spec/support/shared_examples/requests/api/nuget_packages_shared_examples.rb b/spec/support/shared_examples/requests/api/nuget_packages_shared_examples.rb index 8d8483cae72..dab0ed82883 100644 --- a/spec/support/shared_examples/requests/api/nuget_packages_shared_examples.rb +++ b/spec/support/shared_examples/requests/api/nuget_packages_shared_examples.rb @@ -180,6 +180,7 @@ RSpec.shared_examples 'process nuget upload' do |user_type, status, add_member = body: 'content' ) end + let(:fog_file) { fog_to_uploaded_file(tmp_object) } let(:params) { { package: fog_file, 'package.remote_id' => file_name } } diff --git a/spec/support/shared_examples/requests/api/pypi_packages_shared_examples.rb b/spec/support/shared_examples/requests/api/pypi_packages_shared_examples.rb index 0dfa21c891f..67666b6cf34 100644 --- a/spec/support/shared_examples/requests/api/pypi_packages_shared_examples.rb +++ b/spec/support/shared_examples/requests/api/pypi_packages_shared_examples.rb @@ -63,6 +63,7 @@ RSpec.shared_examples 'PyPi package creation' do |user_type, status, add_member body: 'content' ) end + let(:fog_file) { fog_to_uploaded_file(tmp_object) } let(:params) { base_params.merge(content: fog_file, 'content.remote_id' => file_name) } diff --git a/spec/support/shared_examples/services/wikis/create_attachment_service_shared_examples.rb b/spec/support/shared_examples/services/wikis/create_attachment_service_shared_examples.rb index 541e332e3a1..555a6d5eed0 100644 --- a/spec/support/shared_examples/services/wikis/create_attachment_service_shared_examples.rb +++ b/spec/support/shared_examples/services/wikis/create_attachment_service_shared_examples.rb @@ -14,6 +14,7 @@ RSpec.shared_examples 'Wikis::CreateAttachmentService#execute' do |container_typ file_content: 'Content of attachment' } end + let(:opts) { file_opts } let(:service) { Wikis::CreateAttachmentService.new(container: container, current_user: user, params: opts) } diff --git a/spec/tasks/gitlab/backup_rake_spec.rb b/spec/tasks/gitlab/backup_rake_spec.rb index 661ce8e74d2..0ab407a0a7b 100644 --- a/spec/tasks/gitlab/backup_rake_spec.rb +++ b/spec/tasks/gitlab/backup_rake_spec.rb @@ -286,6 +286,7 @@ RSpec.describe 'gitlab:app namespace rake task', :delete do let(:test_second_storage) do Gitlab::GitalyClient::StorageSettings.new(@default_storage_hash.merge('path' => 'tmp/tests/custom_storage')) end + let(:storages) do { 'default' => Gitlab.config.repositories.storages.default, diff --git a/spec/tooling/lib/tooling/helm3_client_spec.rb b/spec/tooling/lib/tooling/helm3_client_spec.rb index f12bae051f0..41c51ec5754 100644 --- a/spec/tooling/lib/tooling/helm3_client_spec.rb +++ b/spec/tooling/lib/tooling/helm3_client_spec.rb @@ -15,6 +15,7 @@ RSpec.describe Tooling::Helm3Client do ] OUTPUT end + let(:raw_helm_list_page2) do <<~OUTPUT [ @@ -22,6 +23,7 @@ RSpec.describe Tooling::Helm3Client do ] OUTPUT end + let(:raw_helm_list_empty) do <<~OUTPUT [] diff --git a/spec/uploaders/file_mover_spec.rb b/spec/uploaders/file_mover_spec.rb index 0f7496f17d5..3b8c6f6f881 100644 --- a/spec/uploaders/file_mover_spec.rb +++ b/spec/uploaders/file_mover_spec.rb @@ -14,6 +14,7 @@ RSpec.describe FileMover do "test ![banana_sample](/#{temp_file_path}) "\ "same ![banana_sample](/#{temp_file_path}) " end + let(:file_path) { File.join('uploads/-/system/personal_snippet', snippet.id.to_s, secret, filename) } let(:snippet) { create(:personal_snippet, description: temp_description) } diff --git a/spec/validators/qualified_domain_array_validator_spec.rb b/spec/validators/qualified_domain_array_validator_spec.rb index 788e007970a..865ecffe05a 100644 --- a/spec/validators/qualified_domain_array_validator_spec.rb +++ b/spec/validators/qualified_domain_array_validator_spec.rb @@ -14,6 +14,7 @@ RSpec.describe QualifiedDomainArrayValidator do end end end + let!(:record) do qualified_domain_array_validator_test_class.new(['gitlab.com']) end diff --git a/spec/workers/pages_domain_ssl_renewal_cron_worker_spec.rb b/spec/workers/pages_domain_ssl_renewal_cron_worker_spec.rb index 7c745e51df5..dac8c529984 100644 --- a/spec/workers/pages_domain_ssl_renewal_cron_worker_spec.rb +++ b/spec/workers/pages_domain_ssl_renewal_cron_worker_spec.rb @@ -18,9 +18,11 @@ RSpec.describe PagesDomainSslRenewalCronWorker do let!(:domain_with_obtained_letsencrypt) do create(:pages_domain, :letsencrypt, project: project, auto_ssl_enabled: true) end + let!(:domain_without_auto_certificate) do create(:pages_domain, :without_certificate, :without_key, project: project, auto_ssl_enabled: true) end + let!(:domain_with_failed_auto_ssl) do create(:pages_domain, :without_certificate, :without_key, project: project, auto_ssl_enabled: true, auto_ssl_failed: true) diff --git a/spec/workers/remove_unreferenced_lfs_objects_worker_spec.rb b/spec/workers/remove_unreferenced_lfs_objects_worker_spec.rb index d6a093a6b51..f14c2b67f2c 100644 --- a/spec/workers/remove_unreferenced_lfs_objects_worker_spec.rb +++ b/spec/workers/remove_unreferenced_lfs_objects_worker_spec.rb @@ -18,12 +18,14 @@ RSpec.describe RemoveUnreferencedLfsObjectsWorker do lfs_object: referenced_lfs_object1 ) end + let!(:lfs_objects_project2_1) do create(:lfs_objects_project, project: project2, lfs_object: referenced_lfs_object1 ) end + let!(:lfs_objects_project1_2) do create(:lfs_objects_project, project: project1, diff --git a/spec/workers/update_highest_role_worker_spec.rb b/spec/workers/update_highest_role_worker_spec.rb index 19512fb0cfc..0c8ee53da9a 100644 --- a/spec/workers/update_highest_role_worker_spec.rb +++ b/spec/workers/update_highest_role_worker_spec.rb @@ -21,6 +21,7 @@ RSpec.describe UpdateHighestRoleWorker, :clean_gitlab_redis_shared_state do user_type: nil } end + let(:user) { create(:user, active_attributes) } subject { worker.perform(user.id) } |