diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2019-12-12 12:07:33 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2019-12-12 12:07:33 +0000 |
commit | 784fae4b9d7e92350075df2a43d06893080ed1e6 (patch) | |
tree | c7a6fd444acd6897622b233b250a34fd176f01da /spec | |
parent | fc53ce8e6ca67bf217470179a1ea6cf139bcffad (diff) | |
download | gitlab-ce-784fae4b9d7e92350075df2a43d06893080ed1e6.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec')
142 files changed, 370 insertions, 150 deletions
diff --git a/spec/controllers/abuse_reports_controller_spec.rb b/spec/controllers/abuse_reports_controller_spec.rb index e573ef4be49..087b564dddb 100644 --- a/spec/controllers/abuse_reports_controller_spec.rb +++ b/spec/controllers/abuse_reports_controller_spec.rb @@ -24,7 +24,7 @@ describe AbuseReportsController do get :new, params: { user_id: user_id } expect(response).to redirect_to root_path - expect(flash[:alert]).to eq('Cannot create the abuse report. The user has been deleted.') + expect(flash[:alert]).to eq(_('Cannot create the abuse report. The user has been deleted.')) end end @@ -35,7 +35,7 @@ describe AbuseReportsController do get :new, params: { user_id: user.id } expect(response).to redirect_to user - expect(flash[:alert]).to eq('Cannot create the abuse report. This user has been blocked.') + expect(flash[:alert]).to eq(_('Cannot create the abuse report. This user has been blocked.')) end end end diff --git a/spec/controllers/admin/users_controller_spec.rb b/spec/controllers/admin/users_controller_spec.rb index 50ba7418d2c..f11b5e798c9 100644 --- a/spec/controllers/admin/users_controller_spec.rb +++ b/spec/controllers/admin/users_controller_spec.rb @@ -155,7 +155,7 @@ describe Admin::UsersController do put :block, params: { id: user.username } user.reload expect(user.blocked?).to be_truthy - expect(flash[:notice]).to eq 'Successfully blocked' + expect(flash[:notice]).to eq _('Successfully blocked') end end @@ -171,7 +171,7 @@ describe Admin::UsersController do put :unblock, params: { id: user.username } user.reload expect(user.blocked?).to be_truthy - expect(flash[:alert]).to eq 'This user cannot be unlocked manually from GitLab' + expect(flash[:alert]).to eq _('This user cannot be unlocked manually from GitLab') end end @@ -184,7 +184,7 @@ describe Admin::UsersController do put :unblock, params: { id: user.username } user.reload expect(user.blocked?).to be_falsey - expect(flash[:notice]).to eq 'Successfully unblocked' + expect(flash[:notice]).to eq _('Successfully unblocked') end end end @@ -234,7 +234,7 @@ describe Admin::UsersController do go expect(flash[:notice]) - .to eq 'Two-factor Authentication has been disabled for this user' + .to eq _('Two-factor Authentication has been disabled for this user') end def go @@ -249,7 +249,9 @@ describe Admin::UsersController do it 'shows only one error message for an invalid email' do post :create, params: { user: attributes_for(:user, email: 'bogus') } - expect(assigns[:user].errors).to contain_exactly("Email is invalid") + + errors = assigns[:user].errors + expect(errors).to contain_exactly(errors.full_message(:email, I18n.t('errors.messages.invalid'))) end end @@ -346,7 +348,7 @@ describe Admin::UsersController do it "shows a notice" do post :impersonate, params: { id: user.username } - expect(flash[:alert]).to eq("You cannot impersonate a blocked user") + expect(flash[:alert]).to eq(_('You cannot impersonate a blocked user')) end it "doesn't sign us in as the user" do diff --git a/spec/controllers/passwords_controller_spec.rb b/spec/controllers/passwords_controller_spec.rb index f2db024804d..bf9680329ce 100644 --- a/spec/controllers/passwords_controller_spec.rb +++ b/spec/controllers/passwords_controller_spec.rb @@ -16,7 +16,7 @@ describe PasswordsController do post :create expect(response).to have_gitlab_http_status(302) - expect(flash[:alert]).to eq 'Password authentication is unavailable.' + expect(flash[:alert]).to eq _('Password authentication is unavailable.') end end @@ -26,7 +26,7 @@ describe PasswordsController do it 'prevents a password reset' do post :create, params: { user: { email: user.email } } - expect(flash[:alert]).to eq 'Password authentication is unavailable.' + expect(flash[:alert]).to eq _('Password authentication is unavailable.') end end end diff --git a/spec/controllers/profiles/preferences_controller_spec.rb b/spec/controllers/profiles/preferences_controller_spec.rb index 929d57ebaec..e0e6d78bdcd 100644 --- a/spec/controllers/profiles/preferences_controller_spec.rb +++ b/spec/controllers/profiles/preferences_controller_spec.rb @@ -37,7 +37,7 @@ describe Profiles::PreferencesController do context 'on successful update' do it 'sets the flash' do go - expect(flash[:notice]).to eq 'Preferences saved.' + expect(flash[:notice]).to eq _('Preferences saved.') end it "changes the user's preferences" do @@ -62,7 +62,7 @@ describe Profiles::PreferencesController do go - expect(flash[:alert]).to eq('Failed to save preferences.') + expect(flash[:alert]).to eq(_('Failed to save preferences.')) end end diff --git a/spec/controllers/profiles/two_factor_auths_controller_spec.rb b/spec/controllers/profiles/two_factor_auths_controller_spec.rb index bcda8573468..b02af0096a5 100644 --- a/spec/controllers/profiles/two_factor_auths_controller_spec.rb +++ b/spec/controllers/profiles/two_factor_auths_controller_spec.rb @@ -70,7 +70,7 @@ describe Profiles::TwoFactorAuthsController do it 'assigns error' do go - expect(assigns[:error]).to eq 'Invalid pin code' + expect(assigns[:error]).to eq _('Invalid pin code') end it 'assigns qr_code' do diff --git a/spec/controllers/profiles_controller_spec.rb b/spec/controllers/profiles_controller_spec.rb index eb479d9a0aa..265f941e146 100644 --- a/spec/controllers/profiles_controller_spec.rb +++ b/spec/controllers/profiles_controller_spec.rb @@ -118,7 +118,7 @@ describe ProfilesController, :request_store do format: :json expect(response.status).to eq(200) - expect(json_response['message']).to eq('Username successfully changed') + expect(json_response['message']).to eq(s_('Profiles|Username successfully changed')) end it 'renders an error message when the username was not updated' do diff --git a/spec/controllers/projects/artifacts_controller_spec.rb b/spec/controllers/projects/artifacts_controller_spec.rb index acc6935cb71..126bb1c9822 100644 --- a/spec/controllers/projects/artifacts_controller_spec.rb +++ b/spec/controllers/projects/artifacts_controller_spec.rb @@ -97,7 +97,7 @@ describe Projects::ArtifactsController do it 'sets the notice' do subject - expect(flash[:notice]).to eq('Artifact was successfully deleted.') + expect(flash[:notice]).to eq(_('Artifact was successfully deleted.')) end context 'when artifact deletion fails' do @@ -114,7 +114,7 @@ describe Projects::ArtifactsController do it 'sets the notice' do subject - expect(flash[:notice]).to eq('Artifact could not be deleted.') + expect(flash[:notice]).to eq(_('Artifact could not be deleted.')) end end diff --git a/spec/controllers/projects/environments/prometheus_api_controller_spec.rb b/spec/controllers/projects/environments/prometheus_api_controller_spec.rb index b8cf47cb1f2..0940fccb431 100644 --- a/spec/controllers/projects/environments/prometheus_api_controller_spec.rb +++ b/spec/controllers/projects/environments/prometheus_api_controller_spec.rb @@ -86,8 +86,8 @@ describe Projects::Environments::PrometheusApiController do it 'returns 204 no_content' do get :proxy, params: environment_params - expect(json_response['status']).to eq('processing') - expect(json_response['message']).to eq('Not ready yet. Try again later.') + expect(json_response['status']).to eq(_('processing')) + expect(json_response['message']).to eq(_('Not ready yet. Try again later.')) expect(response).to have_gitlab_http_status(:no_content) end end diff --git a/spec/controllers/projects/issues_controller_spec.rb b/spec/controllers/projects/issues_controller_spec.rb index 29746bbd863..51d5a0d2144 100644 --- a/spec/controllers/projects/issues_controller_spec.rb +++ b/spec/controllers/projects/issues_controller_spec.rb @@ -170,7 +170,7 @@ describe Projects::IssuesController do it 'redirects to signin if not logged in' do get :new, params: { namespace_id: project.namespace, project_id: project } - expect(flash[:alert]).to eq 'You need to sign in or sign up before continuing.' + expect(flash[:alert]).to eq I18n.t('devise.failure.unauthenticated') expect(response).to redirect_to(new_user_session_path) end @@ -926,7 +926,7 @@ describe Projects::IssuesController do it 'sets a flash message' do post_issue(title: 'Hello') - expect(flash[:notice]).to eq('Resolved all discussions.') + expect(flash[:notice]).to eq(_('Resolved all discussions.')) end describe "resolving a single discussion" do @@ -940,7 +940,7 @@ describe Projects::IssuesController do end it 'sets a flash message that one discussion was resolved' do - expect(flash[:notice]).to eq('Resolved 1 discussion.') + expect(flash[:notice]).to eq(_('Resolved 1 discussion.')) end end end @@ -1314,7 +1314,7 @@ describe Projects::IssuesController do it "returns 302 for project members with developer role" do import_csv - expect(flash[:notice]).to include('Your issues are being imported') + expect(flash[:notice]).to eq(_("Your issues are being imported. Once finished, you'll get a confirmation email.")) expect(response).to redirect_to(project_issues_path(project)) end @@ -1325,7 +1325,7 @@ describe Projects::IssuesController do import_csv - expect(flash[:alert]).to include('File upload error.') + expect(flash[:alert]).to include(_('File upload error.')) expect(response).to redirect_to(project_issues_path(project)) end end diff --git a/spec/controllers/projects/pipeline_schedules_controller_spec.rb b/spec/controllers/projects/pipeline_schedules_controller_spec.rb index 63e2c8a339c..60b802f1cab 100644 --- a/spec/controllers/projects/pipeline_schedules_controller_spec.rb +++ b/spec/controllers/projects/pipeline_schedules_controller_spec.rb @@ -416,7 +416,7 @@ describe Projects::PipelineSchedulesController do end expect(flash.to_a.size).to eq(2) - expect(flash[:alert]).to eq 'You cannot play this scheduled pipeline at the moment. Please wait a minute.' + expect(flash[:alert]).to eq _('You cannot play this scheduled pipeline at the moment. Please wait a minute.') expect(response).to have_gitlab_http_status(302) end end diff --git a/spec/controllers/projects/raw_controller_spec.rb b/spec/controllers/projects/raw_controller_spec.rb index ebc22043891..bdf1c1a84d3 100644 --- a/spec/controllers/projects/raw_controller_spec.rb +++ b/spec/controllers/projects/raw_controller_spec.rb @@ -59,7 +59,7 @@ describe Projects::RawController do it 'prevents from accessing the raw file' do execute_raw_requests(requests: 6, project: project, file_path: file_path) - expect(flash[:alert]).to eq('You cannot access the raw file. Please wait a minute.') + expect(flash[:alert]).to eq(_('You cannot access the raw file. Please wait a minute.')) expect(response).to have_gitlab_http_status(429) end @@ -109,7 +109,7 @@ describe Projects::RawController do execute_raw_requests(requests: 3, project: project, file_path: modified_path) - expect(flash[:alert]).to eq('You cannot access the raw file. Please wait a minute.') + expect(flash[:alert]).to eq(_('You cannot access the raw file. Please wait a minute.')) expect(response).to have_gitlab_http_status(429) end end @@ -137,7 +137,7 @@ describe Projects::RawController do # Accessing downcase version of readme execute_raw_requests(requests: 6, project: project, file_path: file_path) - expect(flash[:alert]).to eq('You cannot access the raw file. Please wait a minute.') + expect(flash[:alert]).to eq(_('You cannot access the raw file. Please wait a minute.')) expect(response).to have_gitlab_http_status(429) # Accessing upcase version of readme diff --git a/spec/controllers/projects/uploads_controller_spec.rb b/spec/controllers/projects/uploads_controller_spec.rb index 661ed9840b1..cd6a9886f72 100644 --- a/spec/controllers/projects/uploads_controller_spec.rb +++ b/spec/controllers/projects/uploads_controller_spec.rb @@ -35,7 +35,7 @@ describe Projects::UploadsController do post_authorize expect(response).to have_gitlab_http_status(500) - expect(response.body).to eq('Error uploading file') + expect(response.body).to eq(_('Error uploading file')) end end diff --git a/spec/controllers/projects/wikis_controller_spec.rb b/spec/controllers/projects/wikis_controller_spec.rb index f46da908218..3100aa2cb96 100644 --- a/spec/controllers/projects/wikis_controller_spec.rb +++ b/spec/controllers/projects/wikis_controller_spec.rb @@ -114,7 +114,7 @@ describe Projects::WikisController do subject expect(response).to have_http_status(:ok) - expect(flash[:notice]).to eq('The content of this page is not encoded in UTF-8. Edits can only be made via the Git repository.') + expect(flash[:notice]).to eq(_('The content of this page is not encoded in UTF-8. Edits can only be made via the Git repository.')) end end end @@ -205,7 +205,7 @@ describe Projects::WikisController do subject expect(response).to have_http_status(:ok) - expect(response.body).to include('Edit Page') + expect(response.body).to include(s_('Wiki|Edit Page')) end end end diff --git a/spec/controllers/projects_controller_spec.rb b/spec/controllers/projects_controller_spec.rb index a1f9b98dc2c..5259c612bbd 100644 --- a/spec/controllers/projects_controller_spec.rb +++ b/spec/controllers/projects_controller_spec.rb @@ -506,7 +506,7 @@ describe ProjectsController do expect { update_project path: 'renamed_path' } .not_to change { project.reload.path } - expect(controller).to set_flash.now[:alert].to(/container registry tags/) + expect(controller).to set_flash.now[:alert].to(s_('UpdateProject|Cannot rename project because it contains container registry tags!')) expect(response).to have_gitlab_http_status(200) end end @@ -645,7 +645,7 @@ describe ProjectsController do expect(project.namespace).to eq(old_namespace) expect(response).to have_gitlab_http_status(200) - expect(flash[:alert]).to eq 'Please select a new namespace for your project.' + expect(flash[:alert]).to eq s_('TransferProject|Please select a new namespace for your project.') end end end @@ -797,7 +797,7 @@ describe ProjectsController do format: :js) expect(forked_project.reload.forked?).to be_falsey - expect(flash[:notice]).to eq('The fork relationship has been removed.') + expect(flash[:notice]).to eq(s_('The fork relationship has been removed.')) expect(response).to render_template(:remove_fork) end end diff --git a/spec/controllers/registrations_controller_spec.rb b/spec/controllers/registrations_controller_spec.rb index c5cfdd32619..da36148ba85 100644 --- a/spec/controllers/registrations_controller_spec.rb +++ b/spec/controllers/registrations_controller_spec.rb @@ -136,13 +136,13 @@ describe RegistrationsController do post(:create, params: user_params) expect(response).to render_template(:new) - expect(flash[:alert]).to include 'There was an error with the reCAPTCHA. Please solve the reCAPTCHA again.' + expect(flash[:alert]).to eq(_('There was an error with the reCAPTCHA. Please solve the reCAPTCHA again.')) end it 'redirects to the dashboard when the recaptcha is solved' do post(:create, params: user_params) - expect(flash[:notice]).to include 'Welcome! You have signed up successfully.' + expect(flash[:notice]).to eq(I18n.t('devise.registrations.signed_up')) end it 'does not require reCAPTCHA if disabled by feature flag' do @@ -152,7 +152,7 @@ describe RegistrationsController do expect(controller).not_to receive(:verify_recaptcha) expect(flash[:alert]).to be_nil - expect(flash[:notice]).to include 'Welcome! You have signed up successfully.' + expect(flash[:notice]).to eq(I18n.t('devise.registrations.signed_up')) end end @@ -220,7 +220,7 @@ describe RegistrationsController do expect(Gitlab::AuthLogger).to receive(:error).with(auth_log_attributes).once expect { post(:create, params: user_params, session: session_params) }.not_to change(User, :count) expect(response).to redirect_to(new_user_session_path) - expect(flash[:alert]).to include 'That was a bit too quick! Please resubmit.' + expect(flash[:alert]).to eq(I18n.t('invisible_captcha.timestamp_error_message')) end end end @@ -236,7 +236,7 @@ describe RegistrationsController do expect(Gitlab::AuthLogger).to receive(:error).with(auth_log_attributes).once expect { post(:create, params: user_params, session: session_params) }.not_to change(User, :count) expect(response).to redirect_to(new_user_session_path) - expect(flash[:alert]).to include 'That was a bit too quick! Please resubmit.' + expect(flash[:alert]).to eq(I18n.t('invisible_captcha.timestamp_error_message')) end end end @@ -251,7 +251,7 @@ describe RegistrationsController do it 'redirects back with a notice when the checkbox was not checked' do post :create, params: user_params - expect(flash[:alert]).to match /you must accept our terms/i + expect(flash[:alert]).to eq(_('You must accept our Terms of Service and privacy policy in order to register an account')) end it 'creates the user with agreement when terms are accepted' do @@ -322,15 +322,15 @@ describe RegistrationsController do end def expect_password_failure - expect_failure('Invalid password') + expect_failure(s_('Profiles|Invalid password')) end def expect_username_failure - expect_failure('Invalid username') + expect_failure(s_('Profiles|Invalid username')) end def expect_success - expect(flash[:notice]).to eq 'Account scheduled for removal.' + expect(flash[:notice]).to eq s_('Profiles|Account scheduled for removal.') expect(response.status).to eq(303) expect(response).to redirect_to new_user_session_path end diff --git a/spec/helpers/issuables_helper_spec.rb b/spec/helpers/issuables_helper_spec.rb index 57ea5416989..9249c625135 100644 --- a/spec/helpers/issuables_helper_spec.rb +++ b/spec/helpers/issuables_helper_spec.rb @@ -49,7 +49,7 @@ describe IssuablesHelper do let(:label2_entity) { LabelEntity.represent(label2).as_json } it 'returns label text with no labels' do - expect(issuable_labels_tooltip([])).to eq("Labels") + expect(issuable_labels_tooltip([])).to eq(_('Labels')) end it 'returns label text with labels within max limit' do diff --git a/spec/helpers/labels_helper_spec.rb b/spec/helpers/labels_helper_spec.rb index a715390ecae..3238743ee26 100644 --- a/spec/helpers/labels_helper_spec.rb +++ b/spec/helpers/labels_helper_spec.rb @@ -131,7 +131,7 @@ describe LabelsHelper do context 'with a group as subject' do it 'returns "Create group label"' do - expect(create_label_title(group)).to eq 'Create group label' + expect(create_label_title(group)).to eq _('Create group label') end end @@ -139,13 +139,13 @@ describe LabelsHelper do set(:project) { create(:project, namespace: group) } it 'returns "Create project label"' do - expect(create_label_title(project)).to eq 'Create project label' + expect(create_label_title(project)).to eq _('Create project label') end end context 'with no subject' do it 'returns "Create new label"' do - expect(create_label_title(nil)).to eq 'Create new label' + expect(create_label_title(nil)).to eq _('Create new label') end end end @@ -155,7 +155,7 @@ describe LabelsHelper do context 'with a group as subject' do it 'returns "Manage group labels"' do - expect(manage_labels_title(group)).to eq 'Manage group labels' + expect(manage_labels_title(group)).to eq _('Manage group labels') end end @@ -163,13 +163,13 @@ describe LabelsHelper do set(:project) { create(:project, namespace: group) } it 'returns "Manage project labels"' do - expect(manage_labels_title(project)).to eq 'Manage project labels' + expect(manage_labels_title(project)).to eq _('Manage project labels') end end context 'with no subject' do it 'returns "Manage labels"' do - expect(manage_labels_title(nil)).to eq 'Manage labels' + expect(manage_labels_title(nil)).to eq _('Manage labels') end end end @@ -179,7 +179,7 @@ describe LabelsHelper do context 'with a group as subject' do it 'returns "View group labels"' do - expect(view_labels_title(group)).to eq 'View group labels' + expect(view_labels_title(group)).to eq _('View group labels') end end @@ -187,13 +187,13 @@ describe LabelsHelper do set(:project) { create(:project, namespace: group) } it 'returns "View project labels"' do - expect(view_labels_title(project)).to eq 'View project labels' + expect(view_labels_title(project)).to eq _('View project labels') end end context 'with no subject' do it 'returns "View labels"' do - expect(view_labels_title(nil)).to eq 'View labels' + expect(view_labels_title(nil)).to eq _('View labels') end end end diff --git a/spec/helpers/visibility_level_helper_spec.rb b/spec/helpers/visibility_level_helper_spec.rb index 1a176cfe965..df338fac228 100644 --- a/spec/helpers/visibility_level_helper_spec.rb +++ b/spec/helpers/visibility_level_helper_spec.rb @@ -59,29 +59,29 @@ describe VisibilityLevelHelper do describe "#project_visibility_level_description" do it "describes private projects" do expect(project_visibility_level_description(Gitlab::VisibilityLevel::PRIVATE)) - .to eq "Project access must be granted explicitly to each user." + .to eq _('Project access must be granted explicitly to each user.') end it "describes public projects" do expect(project_visibility_level_description(Gitlab::VisibilityLevel::PUBLIC)) - .to eq "The project can be accessed without any authentication." + .to eq _('The project can be accessed without any authentication.') end end describe "#snippet_visibility_level_description" do it 'describes visibility only for me' do expect(snippet_visibility_level_description(Gitlab::VisibilityLevel::PRIVATE, personal_snippet)) - .to eq "The snippet is visible only to me." + .to eq _('The snippet is visible only to me.') end it 'describes visibility for project members' do expect(snippet_visibility_level_description(Gitlab::VisibilityLevel::PRIVATE, project_snippet)) - .to eq "The snippet is visible only to project members." + .to eq _('The snippet is visible only to project members.') end it 'defaults to personal snippet' do expect(snippet_visibility_level_description(Gitlab::VisibilityLevel::PRIVATE)) - .to eq "The snippet is visible only to me." + .to eq _('The snippet is visible only to me.') end end diff --git a/spec/javascripts/diffs/store/actions_spec.js b/spec/javascripts/diffs/store/actions_spec.js index 163d530a2b6..c716053b288 100644 --- a/spec/javascripts/diffs/store/actions_spec.js +++ b/spec/javascripts/diffs/store/actions_spec.js @@ -5,6 +5,7 @@ import { DIFF_VIEW_COOKIE_NAME, INLINE_DIFF_VIEW_TYPE, PARALLEL_DIFF_VIEW_TYPE, + DIFFS_PER_PAGE, } from '~/diffs/constants'; import actions, { setBaseConfig, @@ -144,10 +145,11 @@ describe('DiffsStoreActions', () => { }); describe('fetchDiffFilesBatch', () => { - it('should fetch batch diff files', done => { + // eslint-disable-next-line jasmine/no-focused-tests + fit('should fetch batch diff files', done => { const endpointBatch = '/fetch/diffs_batch'; - const batch1 = `${endpointBatch}?per_page=10`; - const batch2 = `${endpointBatch}?per_page=10&page=2`; + const batch1 = `${endpointBatch}?per_page=${DIFFS_PER_PAGE}`; + const batch2 = `${endpointBatch}?per_page=${DIFFS_PER_PAGE}&page=2`; const mock = new MockAdapter(axios); const res1 = { diff_files: [], pagination: { next_page: 2 } }; const res2 = { diff_files: [], pagination: {} }; diff --git a/spec/lib/api/helpers/related_resources_helpers_spec.rb b/spec/lib/api/helpers/related_resources_helpers_spec.rb index fb26cc417e8..eeeb22abd10 100644 --- a/spec/lib/api/helpers/related_resources_helpers_spec.rb +++ b/spec/lib/api/helpers/related_resources_helpers_spec.rb @@ -43,6 +43,7 @@ describe API::Helpers::RelatedResourcesHelpers do describe '#expose_url' do let(:path) { '/api/v4/awesome_endpoint' } + subject(:url) { helpers.expose_url(path) } def stub_default_url_options(protocol: 'http', host: 'example.com', port: nil, script_name: '') diff --git a/spec/lib/backup/repository_spec.rb b/spec/lib/backup/repository_spec.rb index 82ae535e100..32e718d4b3b 100644 --- a/spec/lib/backup/repository_spec.rb +++ b/spec/lib/backup/repository_spec.rb @@ -5,6 +5,7 @@ require 'spec_helper' describe Backup::Repository do let(:progress) { StringIO.new } let!(:project) { create(:project, :wiki_repo) } + subject { described_class.new(progress) } before do diff --git a/spec/lib/backup/uploads_spec.rb b/spec/lib/backup/uploads_spec.rb index 55b69f29812..1f49baeff69 100644 --- a/spec/lib/backup/uploads_spec.rb +++ b/spec/lib/backup/uploads_spec.rb @@ -4,6 +4,7 @@ require 'spec_helper' describe Backup::Uploads do let(:progress) { StringIO.new } + subject(:backup) { described_class.new(progress) } describe '#initialize' do diff --git a/spec/lib/banzai/filter/relative_link_filter_spec.rb b/spec/lib/banzai/filter/relative_link_filter_spec.rb index 371c7a2347c..a17a645d4d0 100644 --- a/spec/lib/banzai/filter/relative_link_filter_spec.rb +++ b/spec/lib/banzai/filter/relative_link_filter_spec.rb @@ -96,21 +96,25 @@ describe Banzai::Filter::RelativeLinkFilter do context 'with a project_wiki' do let(:project_wiki) { double('ProjectWiki') } + include_examples :preserve_unchanged end context 'without a repository' do let(:project) { create(:project) } + include_examples :preserve_unchanged end context 'with an empty repository' do let(:project) { create(:project_empty_repo) } + include_examples :preserve_unchanged end context 'without project repository access' do let(:project) { create(:project, :repository, repository_access_level: ProjectFeature::PRIVATE) } + include_examples :preserve_unchanged end @@ -269,6 +273,7 @@ describe Banzai::Filter::RelativeLinkFilter do context 'when requested path is a file in the repo' do let(:requested_path) { 'doc/api/README.md' } + it 'rebuilds URL relative to the containing directory' do doc = filter(link('users.md')) expect(doc.at_css('a')['href']).to eq "/#{project_path}/blob/#{Addressable::URI.escape(ref)}/doc/api/users.md" @@ -277,6 +282,7 @@ describe Banzai::Filter::RelativeLinkFilter do context 'when requested path is a directory in the repo' do let(:requested_path) { 'doc/api/' } + it 'rebuilds URL relative to the directory' do doc = filter(link('users.md')) expect(doc.at_css('a')['href']).to eq "/#{project_path}/blob/#{Addressable::URI.escape(ref)}/doc/api/users.md" @@ -287,6 +293,7 @@ describe Banzai::Filter::RelativeLinkFilter do let(:ref) { '100%branch' } let(:commit) { project.commit('1b12f15a11fc6e62177bef08f47bc7b5ce50b141') } let(:requested_path) { 'foo/bar/' } + it 'correctly escapes the ref' do doc = filter(link('.gitkeep')) expect(doc.at_css('a')['href']).to eq "/#{project_path}/blob/#{Addressable::URI.escape(ref)}/foo/bar/.gitkeep" @@ -316,6 +323,7 @@ describe Banzai::Filter::RelativeLinkFilter do let(:ref) { 'master' } let(:commit) { project.commit('38008cb17ce1466d8fec2dfa6f6ab8dcfe5cf49e') } let(:requested_path) { 'with space/' } + it 'does not escape the space twice' do doc = filter(link('README.md')) expect(doc.at_css('a')['href']).to eq "/#{project_path}/blob/#{Addressable::URI.escape(ref)}/with%20space/README.md" @@ -328,7 +336,9 @@ describe Banzai::Filter::RelativeLinkFilter do end context 'with a valid ref' do - let(:commit) { nil } # force filter to use ref instead of commit + # force filter to use ref instead of commit + let(:commit) { nil } + include_examples :valid_repository end diff --git a/spec/lib/banzai/reference_parser/issue_parser_spec.rb b/spec/lib/banzai/reference_parser/issue_parser_spec.rb index a925d294b1b..ac321aca5e9 100644 --- a/spec/lib/banzai/reference_parser/issue_parser_spec.rb +++ b/spec/lib/banzai/reference_parser/issue_parser_spec.rb @@ -9,6 +9,7 @@ describe Banzai::ReferenceParser::IssueParser do let(:user) { create(:user) } let(:issue) { create(:issue, project: project) } let(:link) { empty_html_link } + subject { described_class.new(Banzai::RenderContext.new(project, user)) } describe '#nodes_visible_to_user' do diff --git a/spec/lib/banzai/reference_parser/snippet_parser_spec.rb b/spec/lib/banzai/reference_parser/snippet_parser_spec.rb index 05dc1cb4d2d..6581ed0d7c3 100644 --- a/spec/lib/banzai/reference_parser/snippet_parser_spec.rb +++ b/spec/lib/banzai/reference_parser/snippet_parser_spec.rb @@ -200,6 +200,7 @@ describe Banzai::ReferenceParser::SnippetParser do describe '#referenced_by' do let(:snippet) { create(:snippet, project: project) } + describe 'when the link has a data-snippet attribute' do context 'using an existing snippet ID' do it 'returns an Array of snippets' do diff --git a/spec/lib/banzai/reference_redactor_spec.rb b/spec/lib/banzai/reference_redactor_spec.rb index 9e1a389d2db..0dec6395fb3 100644 --- a/spec/lib/banzai/reference_redactor_spec.rb +++ b/spec/lib/banzai/reference_redactor_spec.rb @@ -36,6 +36,7 @@ describe Banzai::ReferenceRedactor do context 'when data-original attribute provided' do let(:original_content) { '<code>foo</code>' } + it 'replaces redacted reference with original content' do doc = Nokogiri::HTML.fragment("<a class='gfm' href='https://www.gitlab.com' data-reference-type='issue' data-original='#{original_content}'>bar</a>") redactor.redact([doc]) diff --git a/spec/lib/constraints/project_url_constrainer_spec.rb b/spec/lib/constraints/project_url_constrainer_spec.rb index ac3221ecab7..963e1d5b8e0 100644 --- a/spec/lib/constraints/project_url_constrainer_spec.rb +++ b/spec/lib/constraints/project_url_constrainer_spec.rb @@ -37,11 +37,13 @@ describe Constraints::ProjectUrlConstrainer do context 'and is a GET request' do let(:request) { build_request(namespace.full_path, old_project_path) } + it { expect(subject.matches?(request)).to be_truthy } end context 'and is NOT a GET request' do let(:request) { build_request(namespace.full_path, old_project_path, 'POST') } + it { expect(subject.matches?(request)).to be_falsey } end end diff --git a/spec/lib/constraints/user_url_constrainer_spec.rb b/spec/lib/constraints/user_url_constrainer_spec.rb index 15ef930420c..4f665def3bf 100644 --- a/spec/lib/constraints/user_url_constrainer_spec.rb +++ b/spec/lib/constraints/user_url_constrainer_spec.rb @@ -24,11 +24,13 @@ describe Constraints::UserUrlConstrainer do context 'and is a GET request' do let(:request) { build_request(redirect_route.path) } + it { expect(subject.matches?(request)).to be_truthy } end context 'and is NOT a GET request' do let(:request) { build_request(redirect_route.path, 'POST') } + it { expect(subject.matches?(request)).to be_falsey } end end diff --git a/spec/lib/gitlab/asciidoc_spec.rb b/spec/lib/gitlab/asciidoc_spec.rb index 415a6e62374..38ec04ebe81 100644 --- a/spec/lib/gitlab/asciidoc_spec.rb +++ b/spec/lib/gitlab/asciidoc_spec.rb @@ -451,6 +451,7 @@ module Gitlab context 'with path to a binary file' do let(:blob) { fake_blob(path: 'dk.png', binary: true) } + include_examples :invalid_include end @@ -500,6 +501,7 @@ module Gitlab context 'without a commit (only ref)' do let(:commit) { nil } + include_examples :valid_include end end @@ -511,6 +513,7 @@ module Gitlab context 'without a commit (only ref)' do let(:commit) { nil } + include_examples :valid_include end end diff --git a/spec/lib/gitlab/auth/o_auth/user_spec.rb b/spec/lib/gitlab/auth/o_auth/user_spec.rb index 3b490646b6e..c621c0aa935 100644 --- a/spec/lib/gitlab/auth/o_auth/user_spec.rb +++ b/spec/lib/gitlab/auth/o_auth/user_spec.rb @@ -253,6 +253,7 @@ describe Gitlab::Auth::OAuth::User do context "and LDAP user has an account already" do let!(:existing_user) { create(:omniauth_user, name: 'John Doe', email: 'john@example.com', extern_uid: dn, provider: 'ldapmain', username: 'john') } + it "adds the omniauth identity to the LDAP account" do allow(Gitlab::Auth::LDAP::Person).to receive(:find_by_uid).and_return(ldap_user) diff --git a/spec/lib/gitlab/auth_spec.rb b/spec/lib/gitlab/auth_spec.rb index 0a54a72abad..311cbd4dd7e 100644 --- a/spec/lib/gitlab/auth_spec.rb +++ b/spec/lib/gitlab/auth_spec.rb @@ -4,6 +4,7 @@ require 'spec_helper' describe Gitlab::Auth, :use_clean_rails_memory_store_caching do let(:gl_auth) { described_class } + set(:project) { create(:project) } describe 'constants' do diff --git a/spec/lib/gitlab/background_migration/backfill_project_fullpath_in_repo_config_spec.rb b/spec/lib/gitlab/background_migration/backfill_project_fullpath_in_repo_config_spec.rb index c66d7cd6148..5cad479ff05 100644 --- a/spec/lib/gitlab/background_migration/backfill_project_fullpath_in_repo_config_spec.rb +++ b/spec/lib/gitlab/background_migration/backfill_project_fullpath_in_repo_config_spec.rb @@ -10,6 +10,7 @@ describe Gitlab::BackgroundMigration::BackfillProjectFullpathInRepoConfig, :migr describe described_class::Storage::HashedProject do let(:project) { double(id: 555) } + subject(:project_storage) { described_class.new(project) } it 'has the correct disk_path' do @@ -19,6 +20,7 @@ describe Gitlab::BackgroundMigration::BackfillProjectFullpathInRepoConfig, :migr describe described_class::Storage::LegacyProject do let(:project) { double(full_path: 'this/is/the/full/path') } + subject(:project_storage) { described_class.new(project) } it 'has the correct disk_path' do @@ -28,6 +30,7 @@ describe Gitlab::BackgroundMigration::BackfillProjectFullpathInRepoConfig, :migr describe described_class::Project do let(:project_record) { projects.create!(namespace_id: subgroup.id, name: 'baz', path: 'baz') } + subject(:project) { described_class.find(project_record.id) } describe '#full_path' do diff --git a/spec/lib/gitlab/branch_push_merge_commit_analyzer_spec.rb b/spec/lib/gitlab/branch_push_merge_commit_analyzer_spec.rb index 1e969542975..a27f14cd621 100644 --- a/spec/lib/gitlab/branch_push_merge_commit_analyzer_spec.rb +++ b/spec/lib/gitlab/branch_push_merge_commit_analyzer_spec.rb @@ -49,6 +49,7 @@ describe Gitlab::BranchPushMergeCommitAnalyzer do context 'when relevant_commit_ids is provided' do let(:relevant_commit_id) { '8a994512e8c8f0dfcf22bb16df6e876be7a61036' } + subject { described_class.new(commits, relevant_commit_ids: [relevant_commit_id]) } it 'returns correct merge commit' do diff --git a/spec/lib/gitlab/ci/build/artifacts/metadata/entry_spec.rb b/spec/lib/gitlab/ci/build/artifacts/metadata/entry_spec.rb index 73c3cad88bc..243c6f06324 100644 --- a/spec/lib/gitlab/ci/build/artifacts/metadata/entry_spec.rb +++ b/spec/lib/gitlab/ci/build/artifacts/metadata/entry_spec.rb @@ -152,6 +152,7 @@ describe Gitlab::Ci::Build::Artifacts::Metadata::Entry do describe '#blob' do let(:file_entry) { |example| path(example) } + subject { file_entry.blob } it 'returns a blob representing the entry data' do diff --git a/spec/lib/gitlab/ci/status/build/factory_spec.rb b/spec/lib/gitlab/ci/status/build/factory_spec.rb index de489fa4664..11be17bfc53 100644 --- a/spec/lib/gitlab/ci/status/build/factory_spec.rb +++ b/spec/lib/gitlab/ci/status/build/factory_spec.rb @@ -31,10 +31,10 @@ describe Gitlab::Ci::Status::Build::Factory do end it 'fabricates status with correct details' do - expect(status.text).to eq 'passed' + expect(status.text).to eq s_('CiStatusText|passed') expect(status.icon).to eq 'status_success' expect(status.favicon).to eq 'favicon_status_success' - expect(status.label).to eq 'passed' + expect(status.label).to eq s_('CiStatusLabel|passed') expect(status).to have_details expect(status).to have_action end @@ -58,10 +58,10 @@ describe Gitlab::Ci::Status::Build::Factory do end it 'fabricates status with correct details' do - expect(status.text).to eq 'passed' + expect(status.text).to eq s_('CiStatusText|passed') expect(status.icon).to eq 'status_success' expect(status.favicon).to eq 'favicon_status_success' - expect(status.label).to eq 'passed' + expect(status.label).to eq s_('CiStatusLabel|passed') expect(status).to have_details expect(status).to have_action end @@ -86,11 +86,11 @@ describe Gitlab::Ci::Status::Build::Factory do end it 'fabricates status with correct details' do - expect(status.text).to eq 'failed' + expect(status.text).to eq s_('CiStatusText|failed') expect(status.icon).to eq 'status_failed' expect(status.favicon).to eq 'favicon_status_failed' - expect(status.label).to eq 'failed' - expect(status.status_tooltip).to eq 'failed - (unknown failure)' + expect(status.label).to eq s_('CiStatusLabel|failed') + expect(status.status_tooltip).to eq "#{s_('CiStatusText|failed')} - (unknown failure)" expect(status).to have_details expect(status).to have_action end @@ -115,7 +115,7 @@ describe Gitlab::Ci::Status::Build::Factory do end it 'fabricates status with correct details' do - expect(status.text).to eq 'failed' + expect(status.text).to eq s_('CiStatusText|failed') expect(status.icon).to eq 'status_warning' expect(status.favicon).to eq 'favicon_status_failed' expect(status.label).to eq 'failed (allowed to fail)' @@ -144,10 +144,10 @@ describe Gitlab::Ci::Status::Build::Factory do end it 'fabricates status with correct details' do - expect(status.text).to eq 'failed' + expect(status.text).to eq s_('CiStatusText|failed') expect(status.icon).to eq 'status_failed' expect(status.favicon).to eq 'favicon_status_failed' - expect(status.label).to eq 'failed' + expect(status.label).to eq s_('CiStatusLabel|failed') expect(status).to have_details expect(status).to have_action expect(status.action_title).to include 'Retry' @@ -173,11 +173,11 @@ describe Gitlab::Ci::Status::Build::Factory do end it 'fabricates status with correct details' do - expect(status.text).to eq 'canceled' + expect(status.text).to eq s_('CiStatusText|canceled') expect(status.icon).to eq 'status_canceled' expect(status.favicon).to eq 'favicon_status_canceled' expect(status.illustration).to include(:image, :size, :title) - expect(status.label).to eq 'canceled' + expect(status.label).to eq s_('CiStatusLabel|canceled') expect(status).to have_details expect(status).to have_action end @@ -200,10 +200,10 @@ describe Gitlab::Ci::Status::Build::Factory do end it 'fabricates status with correct details' do - expect(status.text).to eq 'running' + expect(status.text).to eq s_('CiStatus|running') expect(status.icon).to eq 'status_running' expect(status.favicon).to eq 'favicon_status_running' - expect(status.label).to eq 'running' + expect(status.label).to eq s_('CiStatus|running') expect(status).to have_details expect(status).to have_action end @@ -226,11 +226,11 @@ describe Gitlab::Ci::Status::Build::Factory do end it 'fabricates status with correct details' do - expect(status.text).to eq 'pending' + expect(status.text).to eq s_('CiStatusText|pending') expect(status.icon).to eq 'status_pending' expect(status.favicon).to eq 'favicon_status_pending' expect(status.illustration).to include(:image, :size, :title, :content) - expect(status.label).to eq 'pending' + expect(status.label).to eq s_('CiStatusLabel|pending') expect(status).to have_details expect(status).to have_action end @@ -252,11 +252,11 @@ describe Gitlab::Ci::Status::Build::Factory do end it 'fabricates status with correct details' do - expect(status.text).to eq 'skipped' + expect(status.text).to eq s_('CiStatusText|skipped') expect(status.icon).to eq 'status_skipped' expect(status.favicon).to eq 'favicon_status_skipped' expect(status.illustration).to include(:image, :size, :title) - expect(status.label).to eq 'skipped' + expect(status.label).to eq s_('CiStatusLabel|skipped') expect(status).to have_details expect(status).not_to have_action end @@ -282,7 +282,7 @@ describe Gitlab::Ci::Status::Build::Factory do end it 'fabricates status with correct details' do - expect(status.text).to eq 'manual' + expect(status.text).to eq s_('CiStatusText|manual') expect(status.group).to eq 'manual' expect(status.icon).to eq 'status_manual' expect(status.favicon).to eq 'favicon_status_manual' @@ -339,7 +339,7 @@ describe Gitlab::Ci::Status::Build::Factory do end it 'fabricates status with correct details' do - expect(status.text).to eq 'manual' + expect(status.text).to eq s_('CiStatusText|manual') expect(status.group).to eq 'manual' expect(status.icon).to eq 'status_manual' expect(status.favicon).to eq 'favicon_status_manual' @@ -370,7 +370,7 @@ describe Gitlab::Ci::Status::Build::Factory do end it 'fabricates status with correct details' do - expect(status.text).to eq 'delayed' + expect(status.text).to eq s_('CiStatusText|delayed') expect(status.group).to eq 'scheduled' expect(status.icon).to eq 'status_scheduled' expect(status.favicon).to eq 'favicon_status_scheduled' diff --git a/spec/lib/gitlab/ci/status/pipeline/blocked_spec.rb b/spec/lib/gitlab/ci/status/pipeline/blocked_spec.rb index 876ba712d05..664915ba552 100644 --- a/spec/lib/gitlab/ci/status/pipeline/blocked_spec.rb +++ b/spec/lib/gitlab/ci/status/pipeline/blocked_spec.rb @@ -23,6 +23,7 @@ describe Gitlab::Ci::Status::Pipeline::Blocked do describe '.matches?' do let(:user) { double('user') } + subject { described_class.matches?(pipeline, user) } context 'when pipeline is blocked' do diff --git a/spec/lib/gitlab/ci/status/pipeline/delayed_spec.rb b/spec/lib/gitlab/ci/status/pipeline/delayed_spec.rb index 90b797965b3..aba403de712 100644 --- a/spec/lib/gitlab/ci/status/pipeline/delayed_spec.rb +++ b/spec/lib/gitlab/ci/status/pipeline/delayed_spec.rb @@ -23,6 +23,7 @@ describe Gitlab::Ci::Status::Pipeline::Delayed do describe '.matches?' do let(:user) { double('user') } + subject { described_class.matches?(pipeline, user) } context 'when pipeline is scheduled' do diff --git a/spec/lib/gitlab/ci/trace/section_parser_spec.rb b/spec/lib/gitlab/ci/trace/section_parser_spec.rb index 5e2efe083be..6e8504a1584 100644 --- a/spec/lib/gitlab/ci/trace/section_parser_spec.rb +++ b/spec/lib/gitlab/ci/trace/section_parser_spec.rb @@ -21,6 +21,7 @@ describe Gitlab::Ci::Trace::SectionParser do end let(:lines) { build_lines('') } + subject { described_class.new(lines) } describe '#sections' do diff --git a/spec/lib/gitlab/ci/yaml_processor_spec.rb b/spec/lib/gitlab/ci/yaml_processor_spec.rb index fc57341b5bc..6083aac44f5 100644 --- a/spec/lib/gitlab/ci/yaml_processor_spec.rb +++ b/spec/lib/gitlab/ci/yaml_processor_spec.rb @@ -1723,6 +1723,7 @@ module Gitlab describe "Hidden jobs" do let(:config_processor) { Gitlab::Ci::YamlProcessor.new(config) } + subject { config_processor.stage_builds_attributes("test") } shared_examples 'hidden_job_handling' do @@ -1767,6 +1768,7 @@ module Gitlab describe "YAML Alias/Anchor" do let(:config_processor) { Gitlab::Ci::YamlProcessor.new(config) } + subject { config_processor.stage_builds_attributes("build") } shared_examples 'job_templates_handling' do diff --git a/spec/lib/gitlab/cleanup/orphan_job_artifact_files_spec.rb b/spec/lib/gitlab/cleanup/orphan_job_artifact_files_spec.rb index fc9792e16d7..75ef75fccc9 100644 --- a/spec/lib/gitlab/cleanup/orphan_job_artifact_files_spec.rb +++ b/spec/lib/gitlab/cleanup/orphan_job_artifact_files_spec.rb @@ -4,6 +4,7 @@ require 'spec_helper' describe Gitlab::Cleanup::OrphanJobArtifactFiles do let(:null_logger) { Logger.new('/dev/null') } + subject(:cleanup) { described_class.new(logger: null_logger) } before do diff --git a/spec/lib/gitlab/database/rename_reserved_paths_migration/v1/rename_base_spec.rb b/spec/lib/gitlab/database/rename_reserved_paths_migration/v1/rename_base_spec.rb index 612c418e8bb..7b8437e4874 100644 --- a/spec/lib/gitlab/database/rename_reserved_paths_migration/v1/rename_base_spec.rb +++ b/spec/lib/gitlab/database/rename_reserved_paths_migration/v1/rename_base_spec.rb @@ -83,6 +83,7 @@ describe Gitlab::Database::RenameReservedPathsMigration::V1::RenameBase, :delete describe '#rename_path_for_routable' do context 'for namespaces' do let(:namespace) { create(:namespace, path: 'the-path') } + it "renames namespaces called the-path" do subject.rename_path_for_routable(migration_namespace(namespace)) @@ -159,6 +160,7 @@ describe Gitlab::Database::RenameReservedPathsMigration::V1::RenameBase, :delete describe '#perform_rename' do describe 'for namespaces' do let(:namespace) { create(:namespace, path: 'the-path') } + it 'renames the path' do subject.perform_rename(migration_namespace(namespace), 'the-path', 'renamed') diff --git a/spec/lib/gitlab/database/rename_reserved_paths_migration/v1/rename_namespaces_spec.rb b/spec/lib/gitlab/database/rename_reserved_paths_migration/v1/rename_namespaces_spec.rb index 8c4d7e323fa..46fc48ab3fc 100644 --- a/spec/lib/gitlab/database/rename_reserved_paths_migration/v1/rename_namespaces_spec.rb +++ b/spec/lib/gitlab/database/rename_reserved_paths_migration/v1/rename_namespaces_spec.rb @@ -95,6 +95,7 @@ describe Gitlab::Database::RenameReservedPathsMigration::V1::RenameNamespaces, : describe '#move_repositories' do let(:namespace) { create(:group, name: 'hello-group') } + it 'moves a project for a namespace' do create(:project, :repository, :legacy_storage, namespace: namespace, path: 'hello-project') expected_path = File.join(TestEnv.repos_path, 'bye-group', 'hello-project.git') diff --git a/spec/lib/gitlab/diff/diff_refs_spec.rb b/spec/lib/gitlab/diff/diff_refs_spec.rb index e12b46c15ad..33a7cf5ae12 100644 --- a/spec/lib/gitlab/diff/diff_refs_spec.rb +++ b/spec/lib/gitlab/diff/diff_refs_spec.rb @@ -7,6 +7,7 @@ describe Gitlab::Diff::DiffRefs do describe '#==' do let(:commit) { project.commit('1a0b36b3cdad1d2ee32457c102a8c0b7056fa863') } + subject { commit.diff_refs } context 'when shas are missing' do @@ -63,6 +64,7 @@ describe Gitlab::Diff::DiffRefs do describe '#compare_in' do context 'with diff refs for the initial commit' do let(:commit) { project.commit('1a0b36b3cdad1d2ee32457c102a8c0b7056fa863') } + subject { commit.diff_refs } it 'returns an appropriate comparison' do @@ -74,6 +76,7 @@ describe Gitlab::Diff::DiffRefs do context 'with diff refs for a commit' do let(:commit) { project.commit('6f6d7e7ed97bb5f0054f2b1df789b39ca89b6ff9') } + subject { commit.diff_refs } it 'returns an appropriate comparison' do diff --git a/spec/lib/gitlab/diff/line_mapper_spec.rb b/spec/lib/gitlab/diff/line_mapper_spec.rb index 1739bcd14a8..6a86f885c3b 100644 --- a/spec/lib/gitlab/diff/line_mapper_spec.rb +++ b/spec/lib/gitlab/diff/line_mapper_spec.rb @@ -11,6 +11,7 @@ describe Gitlab::Diff::LineMapper do let(:diffs) { commit.raw_diffs } let(:diff) { diffs.first } let(:diff_file) { Gitlab::Diff::File.new(diff, diff_refs: commit.diff_refs, repository: repository) } + subject { described_class.new(diff_file) } describe '#old_to_new' do diff --git a/spec/lib/gitlab/diff/parallel_diff_spec.rb b/spec/lib/gitlab/diff/parallel_diff_spec.rb index 7540da71086..d275bf2c223 100644 --- a/spec/lib/gitlab/diff/parallel_diff_spec.rb +++ b/spec/lib/gitlab/diff/parallel_diff_spec.rb @@ -11,6 +11,7 @@ describe Gitlab::Diff::ParallelDiff do let(:diffs) { commit.raw_diffs } let(:diff) { diffs.first } let(:diff_file) { Gitlab::Diff::File.new(diff, diff_refs: commit.diff_refs, repository: repository) } + subject { described_class.new(diff_file) } describe '#parallelize' do diff --git a/spec/lib/gitlab/email/handler/create_merge_request_handler_spec.rb b/spec/lib/gitlab/email/handler/create_merge_request_handler_spec.rb index 50e425f2bc1..9f5413f9607 100644 --- a/spec/lib/gitlab/email/handler/create_merge_request_handler_spec.rb +++ b/spec/lib/gitlab/email/handler/create_merge_request_handler_spec.rb @@ -191,6 +191,7 @@ describe Gitlab::Email::Handler::CreateMergeRequestHandler do describe '#patch_attachments' do let(:email_raw) { email_fixture('emails/merge_request_multiple_patches.eml') } let(:mail) { Mail::Message.new(email_raw) } + subject(:handler) { described_class.new(mail, mail_key) } it 'orders attachments ending in `.patch` by name' do diff --git a/spec/lib/gitlab/external_authorization/client_spec.rb b/spec/lib/gitlab/external_authorization/client_spec.rb index a17d933e3bb..e28a155a47f 100644 --- a/spec/lib/gitlab/external_authorization/client_spec.rb +++ b/spec/lib/gitlab/external_authorization/client_spec.rb @@ -5,6 +5,7 @@ require 'spec_helper' describe Gitlab::ExternalAuthorization::Client do let(:user) { build(:user, email: 'dummy_user@example.com') } let(:dummy_url) { 'https://dummy.net/' } + subject(:client) { described_class.new(user, 'dummy_label') } before do diff --git a/spec/lib/gitlab/external_authorization/response_spec.rb b/spec/lib/gitlab/external_authorization/response_spec.rb index e1f6e9ac1fa..5ce3325ef77 100644 --- a/spec/lib/gitlab/external_authorization/response_spec.rb +++ b/spec/lib/gitlab/external_authorization/response_spec.rb @@ -4,6 +4,7 @@ require 'spec_helper' describe Gitlab::ExternalAuthorization::Response do let(:excon_response) { double } + subject(:response) { described_class.new(excon_response) } describe '#valid?' do diff --git a/spec/lib/gitlab/file_finder_spec.rb b/spec/lib/gitlab/file_finder_spec.rb index 7ea9d43c9f7..6cc5141a6fe 100644 --- a/spec/lib/gitlab/file_finder_spec.rb +++ b/spec/lib/gitlab/file_finder_spec.rb @@ -5,6 +5,7 @@ require 'spec_helper' describe Gitlab::FileFinder do describe '#find' do let(:project) { create(:project, :public, :repository) } + subject { described_class.new(project, project.default_branch) } it_behaves_like 'file finder' do diff --git a/spec/lib/gitlab/gfm/reference_rewriter_spec.rb b/spec/lib/gitlab/gfm/reference_rewriter_spec.rb index 026fd1fedde..d16f34af325 100644 --- a/spec/lib/gitlab/gfm/reference_rewriter_spec.rb +++ b/spec/lib/gitlab/gfm/reference_rewriter_spec.rb @@ -54,11 +54,13 @@ describe Gitlab::Gfm::ReferenceRewriter do context 'code' do let(:text) { "#1, but not `[#1]`" } + it { is_expected.to eq "#{issue_first.to_reference(new_project)}, but not `[#1]`" } end context 'code reverse' do let(:text) { "not `#1`, but #1" } + it { is_expected.to eq "not `#1`, but #{issue_first.to_reference(new_project)}" } end @@ -74,11 +76,13 @@ describe Gitlab::Gfm::ReferenceRewriter do context 'label referenced by id' do let(:text) { '#1 and ~123' } + it { is_expected.to eq %Q{#{old_project_ref}#1 and #{old_project_ref}~123} } end context 'label referenced by text' do let(:text) { '#1 and ~"test"' } + it { is_expected.to eq %Q{#{old_project_ref}#1 and #{old_project_ref}~123} } end end @@ -93,11 +97,13 @@ describe Gitlab::Gfm::ReferenceRewriter do context 'label referenced by id' do let(:text) { '#1 and ~321' } + it { is_expected.to eq %Q{#{old_project_ref}#1 and #{old_project_ref}~321} } end context 'label referenced by text' do let(:text) { '#1 and ~"group label"' } + it { is_expected.to eq %Q{#{old_project_ref}#1 and #{old_project_ref}~321} } end end diff --git a/spec/lib/gitlab/git/commit_spec.rb b/spec/lib/gitlab/git/commit_spec.rb index 63f443e19d2..7ec655eb113 100644 --- a/spec/lib/gitlab/git/commit_spec.rb +++ b/spec/lib/gitlab/git/commit_spec.rb @@ -542,6 +542,7 @@ describe Gitlab::Git::Commit, :seed_helper do skip 'move this test to gitaly-ruby' do describe '#init_from_rugged' do let(:gitlab_commit) { described_class.new(repository, rugged_commit) } + subject { gitlab_commit } describe '#id' do @@ -553,6 +554,7 @@ describe Gitlab::Git::Commit, :seed_helper do describe '#init_from_hash' do let(:commit) { described_class.new(repository, sample_commit_hash) } + subject { commit } describe '#id' do @@ -608,6 +610,7 @@ describe Gitlab::Git::Commit, :seed_helper do describe '#to_hash' do let(:hash) { commit.to_hash } + subject { hash } it { is_expected.to be_kind_of Hash } @@ -629,6 +632,7 @@ describe Gitlab::Git::Commit, :seed_helper do describe '#ref_names' do let(:commit) { described_class.find(repository, 'master') } + subject { commit.ref_names(repository) } it 'has 2 element' do diff --git a/spec/lib/gitlab/git/diff_spec.rb b/spec/lib/gitlab/git/diff_spec.rb index 456d6af7bd8..ac606da5cc1 100644 --- a/spec/lib/gitlab/git/diff_spec.rb +++ b/spec/lib/gitlab/git/diff_spec.rb @@ -149,6 +149,7 @@ EOT describe '.between' do let(:diffs) { described_class.between(repository, 'feature', 'master') } + subject { diffs } it { is_expected.to be_kind_of Gitlab::Git::DiffCollection } diff --git a/spec/lib/gitlab/git/hook_env_spec.rb b/spec/lib/gitlab/git/hook_env_spec.rb index ca6a4ad42a3..22b016cee3e 100644 --- a/spec/lib/gitlab/git/hook_env_spec.rb +++ b/spec/lib/gitlab/git/hook_env_spec.rb @@ -57,6 +57,7 @@ describe Gitlab::Git::HookEnv do using RSpec::Parameterized::TableSyntax let(:key) { 'GIT_OBJECT_DIRECTORY_RELATIVE' } + subject { described_class.to_env_hash(gl_repository) } where(:input, :output) do diff --git a/spec/lib/gitlab/git/merge_base_spec.rb b/spec/lib/gitlab/git/merge_base_spec.rb index dbb4e3d0b3e..fa95a1664ea 100644 --- a/spec/lib/gitlab/git/merge_base_spec.rb +++ b/spec/lib/gitlab/git/merge_base_spec.rb @@ -5,6 +5,7 @@ require 'spec_helper' describe Gitlab::Git::MergeBase do set(:project) { create(:project, :repository) } let(:repository) { project.repository } + subject(:merge_base) { described_class.new(repository, refs) } shared_context 'existing refs with a merge base', :existing_refs do diff --git a/spec/lib/gitlab/git/remote_repository_spec.rb b/spec/lib/gitlab/git/remote_repository_spec.rb index 556cc692231..b53eee293f0 100644 --- a/spec/lib/gitlab/git/remote_repository_spec.rb +++ b/spec/lib/gitlab/git/remote_repository_spec.rb @@ -4,6 +4,7 @@ require 'spec_helper' describe Gitlab::Git::RemoteRepository, :seed_helper do let(:repository) { Gitlab::Git::Repository.new('default', TEST_REPO_PATH, '', 'group/project') } + subject { described_class.new(repository) } describe '#empty?' do diff --git a/spec/lib/gitlab/git/repository_spec.rb b/spec/lib/gitlab/git/repository_spec.rb index 20a74af7a45..6854d514dcc 100644 --- a/spec/lib/gitlab/git/repository_spec.rb +++ b/spec/lib/gitlab/git/repository_spec.rb @@ -212,6 +212,7 @@ describe Gitlab::Git::Repository, :seed_helper do describe '#ref_names' do let(:ref_names) { repository.ref_names } + subject { ref_names } it { is_expected.to be_kind_of Array } diff --git a/spec/lib/gitlab/git/user_spec.rb b/spec/lib/gitlab/git/user_spec.rb index 277b1c48355..6761413320a 100644 --- a/spec/lib/gitlab/git/user_spec.rb +++ b/spec/lib/gitlab/git/user_spec.rb @@ -26,6 +26,7 @@ describe Gitlab::Git::User do describe '.from_gitlab' do context 'when no commit_email has been set' do let(:user) { build(:user, email: 'alice@example.com', commit_email: nil) } + subject { described_class.from_gitlab(user) } it { expect(subject).to eq(described_class.new(user.username, user.name, user.email, 'user-')) } @@ -33,6 +34,7 @@ describe Gitlab::Git::User do context 'when commit_email has been set' do let(:user) { build(:user, email: 'alice@example.com', commit_email: 'bob@example.com') } + subject { described_class.from_gitlab(user) } it { expect(subject).to eq(described_class.new(user.username, user.name, user.commit_email, 'user-')) } diff --git a/spec/lib/gitlab/gitaly_client/commit_service_spec.rb b/spec/lib/gitlab/gitaly_client/commit_service_spec.rb index 1abdabe17bb..820578dfc6e 100644 --- a/spec/lib/gitlab/gitaly_client/commit_service_spec.rb +++ b/spec/lib/gitlab/gitaly_client/commit_service_spec.rb @@ -188,6 +188,7 @@ describe Gitlab::GitalyClient::CommitService do describe '#find_commit' do let(:revision) { Gitlab::Git::EMPTY_TREE_ID } + it 'sends an RPC request' do request = Gitaly::FindCommitRequest.new( repository: repository_message, revision: revision diff --git a/spec/lib/gitlab/gitaly_client/ref_service_spec.rb b/spec/lib/gitlab/gitaly_client/ref_service_spec.rb index 2b4fe2ea5c0..d4a7f6e6df9 100644 --- a/spec/lib/gitlab/gitaly_client/ref_service_spec.rb +++ b/spec/lib/gitlab/gitaly_client/ref_service_spec.rb @@ -22,6 +22,7 @@ describe Gitlab::GitalyClient::RefService do describe '#remote_branches' do let(:remote_name) { 'my_remote' } + subject { client.remote_branches(remote_name) } it 'sends a find_all_remote_branches message' do diff --git a/spec/lib/gitlab/google_code_import/client_spec.rb b/spec/lib/gitlab/google_code_import/client_spec.rb index bd63cabecd6..2e929a62ebc 100644 --- a/spec/lib/gitlab/google_code_import/client_spec.rb +++ b/spec/lib/gitlab/google_code_import/client_spec.rb @@ -4,6 +4,7 @@ require "spec_helper" describe Gitlab::GoogleCodeImport::Client do let(:raw_data) { JSON.parse(fixture_file("GoogleCodeProjectHosting.json")) } + subject { described_class.new(raw_data) } describe "#valid?" do diff --git a/spec/lib/gitlab/graphql/authorize/authorize_field_service_spec.rb b/spec/lib/gitlab/graphql/authorize/authorize_field_service_spec.rb index aada9285b31..98659dbed57 100644 --- a/spec/lib/gitlab/graphql/authorize/authorize_field_service_spec.rb +++ b/spec/lib/gitlab/graphql/authorize/authorize_field_service_spec.rb @@ -25,6 +25,7 @@ describe Gitlab::Graphql::Authorize::AuthorizeFieldService do end let(:current_user) { double(:current_user) } + subject(:service) { described_class.new(field) } describe '#authorized_resolve' do @@ -34,6 +35,7 @@ describe Gitlab::Graphql::Authorize::AuthorizeFieldService do let(:schema) { GraphQL::Schema.define(query: query_type, mutation: nil)} let(:query_context) { OpenStruct.new(schema: schema) } let(:context) { GraphQL::Query::Context.new(query: OpenStruct.new(schema: schema, context: query_context), values: { current_user: current_user }, object: nil) } + subject(:resolved) { service.authorized_resolve.call(presented_type, {}, context) } context 'scalar types' do diff --git a/spec/lib/gitlab/graphql/authorize/authorize_resource_spec.rb b/spec/lib/gitlab/graphql/authorize/authorize_resource_spec.rb index 8f02b979598..67cb064b966 100644 --- a/spec/lib/gitlab/graphql/authorize/authorize_resource_spec.rb +++ b/spec/lib/gitlab/graphql/authorize/authorize_resource_spec.rb @@ -27,6 +27,7 @@ describe Gitlab::Graphql::Authorize::AuthorizeResource do let(:user) { build(:user) } let(:project) { build(:project) } + subject(:loading_resource) { fake_class.new(user, project) } context 'when the user is allowed to perform the action' do diff --git a/spec/lib/gitlab/graphql/connections/filterable_array_connection_spec.rb b/spec/lib/gitlab/graphql/connections/filterable_array_connection_spec.rb index 1fda84f777e..20e87daa0d6 100644 --- a/spec/lib/gitlab/graphql/connections/filterable_array_connection_spec.rb +++ b/spec/lib/gitlab/graphql/connections/filterable_array_connection_spec.rb @@ -6,6 +6,7 @@ describe Gitlab::Graphql::Connections::FilterableArrayConnection do let(:callback) { proc { |nodes| nodes } } let(:all_nodes) { Gitlab::Graphql::FilterableArray.new(callback, 1, 2, 3, 4, 5) } let(:arguments) { {} } + subject(:connection) do described_class.new(all_nodes, arguments, max_page_size: 3) end diff --git a/spec/lib/gitlab/graphql/connections/keyset/connection_spec.rb b/spec/lib/gitlab/graphql/connections/keyset/connection_spec.rb index 36955019863..bd0fcbbdeb2 100644 --- a/spec/lib/gitlab/graphql/connections/keyset/connection_spec.rb +++ b/spec/lib/gitlab/graphql/connections/keyset/connection_spec.rb @@ -5,6 +5,7 @@ require 'spec_helper' describe Gitlab::Graphql::Connections::Keyset::Connection do let(:nodes) { Project.all.order(id: :asc) } let(:arguments) { {} } + subject(:connection) do described_class.new(nodes, arguments, max_page_size: 3) end diff --git a/spec/lib/gitlab/hook_data/base_builder_spec.rb b/spec/lib/gitlab/hook_data/base_builder_spec.rb index ce8610a2108..4c3fd854c09 100644 --- a/spec/lib/gitlab/hook_data/base_builder_spec.rb +++ b/spec/lib/gitlab/hook_data/base_builder_spec.rb @@ -15,6 +15,7 @@ describe Gitlab::HookData::BaseBuilder do context 'with an upload prefix specified' do let(:project_with_path) { double(full_path: 'baz/bar') } let(:object_with_project) { double(project: project_with_path) } + subject { subclass.new(object_with_project) } where do diff --git a/spec/lib/gitlab/i18n/translation_entry_spec.rb b/spec/lib/gitlab/i18n/translation_entry_spec.rb index 3f0b922cc51..880da38052e 100644 --- a/spec/lib/gitlab/i18n/translation_entry_spec.rb +++ b/spec/lib/gitlab/i18n/translation_entry_spec.rb @@ -136,6 +136,7 @@ describe Gitlab::I18n::TranslationEntry do describe '#contains_unescaped_chars' do let(:data) { { msgid: '' } } let(:entry) { described_class.new(data, 2) } + it 'is true when the msgid is an array' do string = '「100%確定」' diff --git a/spec/lib/gitlab/import_export/lfs_restorer_spec.rb b/spec/lib/gitlab/import_export/lfs_restorer_spec.rb index 75d6da48f33..a932dc3ee4e 100644 --- a/spec/lib/gitlab/import_export/lfs_restorer_spec.rb +++ b/spec/lib/gitlab/import_export/lfs_restorer_spec.rb @@ -9,6 +9,7 @@ describe Gitlab::ImportExport::LfsRestorer do let(:project) { create(:project) } let(:shared) { project.import_export_shared } let(:saver) { Gitlab::ImportExport::LfsSaver.new(project: project, shared: shared) } + subject(:restorer) { described_class.new(project: project, shared: shared) } before do diff --git a/spec/lib/gitlab/import_export/saver_spec.rb b/spec/lib/gitlab/import_export/saver_spec.rb index 279d99dc820..450ae2a2083 100644 --- a/spec/lib/gitlab/import_export/saver_spec.rb +++ b/spec/lib/gitlab/import_export/saver_spec.rb @@ -7,6 +7,7 @@ describe Gitlab::ImportExport::Saver do let!(:project) { create(:project, :public, name: 'project') } let(:export_path) { "#{Dir.tmpdir}/project_tree_saver_spec" } let(:shared) { project.import_export_shared } + subject { described_class.new(exportable: project, shared: shared) } before do diff --git a/spec/lib/gitlab/import_export/shared_spec.rb b/spec/lib/gitlab/import_export/shared_spec.rb index 2b94610a074..8d522252e2d 100644 --- a/spec/lib/gitlab/import_export/shared_spec.rb +++ b/spec/lib/gitlab/import_export/shared_spec.rb @@ -5,6 +5,7 @@ require 'fileutils' describe Gitlab::ImportExport::Shared do let(:project) { build(:project) } + subject { project.import_export_shared } context 'with a repository on disk' do diff --git a/spec/lib/gitlab/json_cache_spec.rb b/spec/lib/gitlab/json_cache_spec.rb index 3bb67600ec9..9d986abb8dd 100644 --- a/spec/lib/gitlab/json_cache_spec.rb +++ b/spec/lib/gitlab/json_cache_spec.rb @@ -7,6 +7,7 @@ describe Gitlab::JsonCache do let(:namespace) { 'geo' } let(:key) { 'foo' } let(:expanded_key) { "#{namespace}:#{key}:#{Gitlab::VERSION}:#{Rails.version}" } + set(:broadcast_message) { create(:broadcast_message) } subject(:cache) { described_class.new(namespace: namespace, backend: backend) } diff --git a/spec/lib/gitlab/kubernetes/config_map_spec.rb b/spec/lib/gitlab/kubernetes/config_map_spec.rb index 64f97379926..0203772e069 100644 --- a/spec/lib/gitlab/kubernetes/config_map_spec.rb +++ b/spec/lib/gitlab/kubernetes/config_map_spec.rb @@ -18,6 +18,7 @@ describe Gitlab::Kubernetes::ConfigMap do describe '#generate' do let(:resource) { ::Kubeclient::Resource.new(metadata: metadata, data: application.files) } + subject { config_map.generate } it 'builds a Kubeclient Resource' do diff --git a/spec/lib/gitlab/kubernetes/namespace_spec.rb b/spec/lib/gitlab/kubernetes/namespace_spec.rb index 6dbb34c2930..16634cc48e6 100644 --- a/spec/lib/gitlab/kubernetes/namespace_spec.rb +++ b/spec/lib/gitlab/kubernetes/namespace_spec.rb @@ -5,6 +5,7 @@ require 'spec_helper' describe Gitlab::Kubernetes::Namespace do let(:name) { 'a_namespace' } let(:client) { double('kubernetes client') } + subject { described_class.new(name, client) } it { expect(subject.name).to eq(name) } diff --git a/spec/lib/gitlab/kubernetes_spec.rb b/spec/lib/gitlab/kubernetes_spec.rb index 31bfd20449d..40c3e7d0b3c 100644 --- a/spec/lib/gitlab/kubernetes_spec.rb +++ b/spec/lib/gitlab/kubernetes_spec.rb @@ -27,6 +27,7 @@ describe Gitlab::Kubernetes do context 'with a path prefix in the API URL' do let(:api_url) { 'https://example.com/prefix/' } + it { expect(result.path).to eq('/prefix/api/v1/namespaces/default/pods/pod1/exec') } end diff --git a/spec/lib/gitlab/legacy_github_import/importer_spec.rb b/spec/lib/gitlab/legacy_github_import/importer_spec.rb index b54f30947aa..c6ee0a3c094 100644 --- a/spec/lib/gitlab/legacy_github_import/importer_spec.rb +++ b/spec/lib/gitlab/legacy_github_import/importer_spec.rb @@ -265,6 +265,7 @@ describe Gitlab::LegacyGithubImport::Importer do context 'when importing a GitHub project' do let(:api_root) { 'https://api.github.com' } let(:repo_root) { 'https://github.com' } + subject { described_class.new(project) } it_behaves_like 'Gitlab::LegacyGithubImport::Importer#execute' @@ -287,6 +288,7 @@ describe Gitlab::LegacyGithubImport::Importer do context 'when importing a Gitea project' do let(:api_root) { 'https://try.gitea.io/api/v1' } let(:repo_root) { 'https://try.gitea.io' } + subject { described_class.new(project) } before do 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 9fa72b3cd90..f5d71888ac9 100644 --- a/spec/lib/gitlab/legacy_github_import/milestone_formatter_spec.rb +++ b/spec/lib/gitlab/legacy_github_import/milestone_formatter_spec.rb @@ -89,6 +89,7 @@ describe Gitlab::LegacyGithubImport::MilestoneFormatter do context 'when importing a Gitea project' do let(:iid_attr) { :id } + before do project.update(import_type: 'gitea') end diff --git a/spec/lib/gitlab/lets_encrypt/client_spec.rb b/spec/lib/gitlab/lets_encrypt/client_spec.rb index cbb862cb0c9..e86de04b5cf 100644 --- a/spec/lib/gitlab/lets_encrypt/client_spec.rb +++ b/spec/lib/gitlab/lets_encrypt/client_spec.rb @@ -86,6 +86,7 @@ describe ::Gitlab::LetsEncrypt::Client do describe '#load_order' do let(:url) { 'https://example.com/order' } + subject { client.load_order(url) } before do @@ -102,6 +103,7 @@ describe ::Gitlab::LetsEncrypt::Client do describe '#load_challenge' do let(:url) { 'https://example.com/challenge' } + subject { client.load_challenge(url) } before do diff --git a/spec/lib/gitlab/markdown_cache/active_record/extension_spec.rb b/spec/lib/gitlab/markdown_cache/active_record/extension_spec.rb index 6d89d22bd0e..5b6c769d6eb 100644 --- a/spec/lib/gitlab/markdown_cache/active_record/extension_spec.rb +++ b/spec/lib/gitlab/markdown_cache/active_record/extension_spec.rb @@ -126,6 +126,7 @@ describe Gitlab::MarkdownCache::ActiveRecord::Extension do describe '#cached_html_up_to_date?' do let(:thing) { klass.create(title: updated_markdown, title_html: html, cached_markdown_version: nil) } + subject { thing.cached_html_up_to_date?(:title) } it 'returns false if markdown has been changed but html has not' do diff --git a/spec/lib/gitlab/metrics/requests_rack_middleware_spec.rb b/spec/lib/gitlab/metrics/requests_rack_middleware_spec.rb index 335670278c4..1fc6fdcf622 100644 --- a/spec/lib/gitlab/metrics/requests_rack_middleware_spec.rb +++ b/spec/lib/gitlab/metrics/requests_rack_middleware_spec.rb @@ -4,6 +4,7 @@ require 'spec_helper' describe Gitlab::Metrics::RequestsRackMiddleware do let(:app) { double('app') } + subject { described_class.new(app) } describe '#call' do diff --git a/spec/lib/gitlab/metrics/samplers/unicorn_sampler_spec.rb b/spec/lib/gitlab/metrics/samplers/unicorn_sampler_spec.rb index cdfd95e3885..a64aae73d43 100644 --- a/spec/lib/gitlab/metrics/samplers/unicorn_sampler_spec.rb +++ b/spec/lib/gitlab/metrics/samplers/unicorn_sampler_spec.rb @@ -52,6 +52,7 @@ describe Gitlab::Metrics::Samplers::UnicornSampler do context 'unicorn listens on tcp sockets' do let(:tcp_socket_address) { '0.0.0.0:8080' } let(:tcp_sockets) { [tcp_socket_address] } + before do allow(unicorn).to receive(:listener_names).and_return(tcp_sockets) end diff --git a/spec/lib/gitlab/pagination/keyset_spec.rb b/spec/lib/gitlab/pagination/keyset_spec.rb index 755c422c46a..5c2576d7b45 100644 --- a/spec/lib/gitlab/pagination/keyset_spec.rb +++ b/spec/lib/gitlab/pagination/keyset_spec.rb @@ -49,6 +49,7 @@ describe Gitlab::Pagination::Keyset do context 'with other order-by columns' do let(:order_by) { { created_at: :desc, id: :desc } } + it 'returns false for Project' do expect(subject.available?(request_context, Project.all)).to be_falsey end diff --git a/spec/lib/gitlab/phabricator_import/cache/map_spec.rb b/spec/lib/gitlab/phabricator_import/cache/map_spec.rb index b6629fad453..14a5d40d445 100644 --- a/spec/lib/gitlab/phabricator_import/cache/map_spec.rb +++ b/spec/lib/gitlab/phabricator_import/cache/map_spec.rb @@ -5,6 +5,7 @@ require 'spec_helper' describe Gitlab::PhabricatorImport::Cache::Map, :clean_gitlab_redis_cache do set(:project) { create(:project) } let(:redis) { Gitlab::Redis::Cache } + subject(:map) { described_class.new(project) } describe '#get_gitlab_model' do diff --git a/spec/lib/gitlab/phabricator_import/importer_spec.rb b/spec/lib/gitlab/phabricator_import/importer_spec.rb index 99a6e4dad6b..2715b785379 100644 --- a/spec/lib/gitlab/phabricator_import/importer_spec.rb +++ b/spec/lib/gitlab/phabricator_import/importer_spec.rb @@ -11,6 +11,7 @@ describe Gitlab::PhabricatorImport::Importer do describe '#execute' do let(:project) { create(:project, :import_scheduled) } + subject(:importer) { described_class.new(project) } it 'sets a custom jid that will be kept up to date' do diff --git a/spec/lib/gitlab/phabricator_import/project_creator_spec.rb b/spec/lib/gitlab/phabricator_import/project_creator_spec.rb index fd17284eea2..0b6a71290ed 100644 --- a/spec/lib/gitlab/phabricator_import/project_creator_spec.rb +++ b/spec/lib/gitlab/phabricator_import/project_creator_spec.rb @@ -8,6 +8,7 @@ describe Gitlab::PhabricatorImport::ProjectCreator do phabricator_server_url: 'http://phab.example.com', api_token: 'the-token' } end + subject(:creator) { described_class.new(user, params) } describe '#execute' do diff --git a/spec/lib/gitlab/phabricator_import/user_finder_spec.rb b/spec/lib/gitlab/phabricator_import/user_finder_spec.rb index 918ff28c8f5..14a00deeb16 100644 --- a/spec/lib/gitlab/phabricator_import/user_finder_spec.rb +++ b/spec/lib/gitlab/phabricator_import/user_finder_spec.rb @@ -4,6 +4,7 @@ require 'spec_helper' describe Gitlab::PhabricatorImport::UserFinder, :clean_gitlab_redis_cache do let(:project) { create(:project, namespace: create(:group)) } + subject(:finder) { described_class.new(project, ['first-phid', 'second-phid']) } before do diff --git a/spec/lib/gitlab/project_search_results_spec.rb b/spec/lib/gitlab/project_search_results_spec.rb index 99078f19361..6f4844d4543 100644 --- a/spec/lib/gitlab/project_search_results_spec.rb +++ b/spec/lib/gitlab/project_search_results_spec.rb @@ -53,6 +53,7 @@ describe Gitlab::ProjectSearchResults do context "when #{entity_type} is disabled" do let(:project) { disabled_project } + it "hides #{blob_kind} from members" do project.add_reporter(user) diff --git a/spec/lib/gitlab/prometheus/queries/deployment_query_spec.rb b/spec/lib/gitlab/prometheus/queries/deployment_query_spec.rb index 0ad2de218fe..d82b7665f85 100644 --- a/spec/lib/gitlab/prometheus/queries/deployment_query_spec.rb +++ b/spec/lib/gitlab/prometheus/queries/deployment_query_spec.rb @@ -5,8 +5,8 @@ require 'spec_helper' describe Gitlab::Prometheus::Queries::DeploymentQuery do let(:environment) { create(:environment, slug: 'environment-slug') } let(:deployment) { create(:deployment, environment: environment) } - let(:client) { double('prometheus_client') } + subject { described_class.new(client) } around do |example| diff --git a/spec/lib/gitlab/prometheus/queries/knative_invocation_query_spec.rb b/spec/lib/gitlab/prometheus/queries/knative_invocation_query_spec.rb index 6361893c53c..0936d895453 100644 --- a/spec/lib/gitlab/prometheus/queries/knative_invocation_query_spec.rb +++ b/spec/lib/gitlab/prometheus/queries/knative_invocation_query_spec.rb @@ -7,8 +7,8 @@ describe Gitlab::Prometheus::Queries::KnativeInvocationQuery do let(:project) { create(:project) } let(:serverless_func) { Serverless::Function.new(project, 'test-name', 'test-ns') } - let(:client) { double('prometheus_client') } + subject { described_class.new(client) } context 'verify queries' do diff --git a/spec/lib/gitlab/prometheus_client_spec.rb b/spec/lib/gitlab/prometheus_client_spec.rb index 86a1c14ed3f..4f9315e28e9 100644 --- a/spec/lib/gitlab/prometheus_client_spec.rb +++ b/spec/lib/gitlab/prometheus_client_spec.rb @@ -327,6 +327,7 @@ describe Gitlab::PrometheusClient do context "without response code" do let(:response_error) { Gitlab::HTTP::ResponseError } + it 'raises PrometheusClient::Error' do expect { subject.proxy('query', { query: prometheus_query }) }.to( raise_error(Gitlab::PrometheusClient::Error, 'Network connection error') diff --git a/spec/lib/gitlab/quick_actions/substitution_definition_spec.rb b/spec/lib/gitlab/quick_actions/substitution_definition_spec.rb index e4f25bc35a9..d0bb032f776 100644 --- a/spec/lib/gitlab/quick_actions/substitution_definition_spec.rb +++ b/spec/lib/gitlab/quick_actions/substitution_definition_spec.rb @@ -9,6 +9,7 @@ Hello! Let's do this! /sub_name I like this stuff EOF end + subject do described_class.new(:sub_name, action_block: proc { |text| "#{text} foo" }) end diff --git a/spec/lib/gitlab/slash_commands/command_spec.rb b/spec/lib/gitlab/slash_commands/command_spec.rb index 5a8c721a634..73b93589fac 100644 --- a/spec/lib/gitlab/slash_commands/command_spec.rb +++ b/spec/lib/gitlab/slash_commands/command_spec.rb @@ -113,11 +113,13 @@ describe Gitlab::SlashCommands::Command do context 'IssueMove is triggered' do let(:params) { { text: 'issue move #78291 to gitlab/gitlab-ci' } } + it { is_expected.to eq(Gitlab::SlashCommands::IssueMove) } end context 'IssueComment is triggered' do let(:params) { { text: "issue comment #503\ncomment body" } } + it { is_expected.to eq(Gitlab::SlashCommands::IssueComment) } end end diff --git a/spec/lib/gitlab/slash_commands/issue_search_spec.rb b/spec/lib/gitlab/slash_commands/issue_search_spec.rb index b766a9a1361..a142c8e4c92 100644 --- a/spec/lib/gitlab/slash_commands/issue_search_spec.rb +++ b/spec/lib/gitlab/slash_commands/issue_search_spec.rb @@ -42,6 +42,7 @@ describe Gitlab::SlashCommands::IssueSearch do describe 'self.match' do let(:query) { "my search keywords" } + it 'matches the query' do match = described_class.match("issue search #{query}") diff --git a/spec/lib/gitlab/slash_commands/presenters/issue_comment_spec.rb b/spec/lib/gitlab/slash_commands/presenters/issue_comment_spec.rb index b5ef417cb93..3741563a744 100644 --- a/spec/lib/gitlab/slash_commands/presenters/issue_comment_spec.rb +++ b/spec/lib/gitlab/slash_commands/presenters/issue_comment_spec.rb @@ -10,6 +10,7 @@ describe Gitlab::SlashCommands::Presenters::IssueComment do describe '#present' do let(:attachment) { subject[:attachments].first } + subject { described_class.new(note).present } it { is_expected.to be_a(Hash) } diff --git a/spec/lib/gitlab/workhorse_spec.rb b/spec/lib/gitlab/workhorse_spec.rb index 88bc5034da5..89381057f6b 100644 --- a/spec/lib/gitlab/workhorse_spec.rb +++ b/spec/lib/gitlab/workhorse_spec.rb @@ -116,6 +116,7 @@ describe Gitlab::Workhorse do describe '.send_git_patch' do let(:diff_refs) { double(base_sha: "base", head_sha: "head") } + subject { described_class.send_git_patch(repository, diff_refs) } it 'sets the header correctly' do @@ -178,6 +179,7 @@ describe Gitlab::Workhorse do describe '.send_git_diff' do let(:diff_refs) { double(base_sha: "base", head_sha: "head") } + subject { described_class.send_git_diff(repository, diff_refs) } it 'sets the header correctly' do diff --git a/spec/lib/json_web_token/rsa_token_spec.rb b/spec/lib/json_web_token/rsa_token_spec.rb index a127c787e28..62fddbb97c7 100644 --- a/spec/lib/json_web_token/rsa_token_spec.rb +++ b/spec/lib/json_web_token/rsa_token_spec.rb @@ -41,6 +41,7 @@ describe JSONWebToken::RSAToken do context 'for invalid key to raise an exception' do let(:new_key) { OpenSSL::PKey::RSA.generate(512) } + subject { JWT.decode(rsa_encoded, new_key, true, { algorithm: 'RS256' }) } it { expect {subject}.to raise_error(JWT::DecodeError) } diff --git a/spec/models/ci/legacy_stage_spec.rb b/spec/models/ci/legacy_stage_spec.rb index 477f4036218..f503fc10c08 100644 --- a/spec/models/ci/legacy_stage_spec.rb +++ b/spec/models/ci/legacy_stage_spec.rb @@ -135,7 +135,7 @@ describe Ci::LegacyStage do let!(:stage_build) { create_job(:ci_build, status: :created) } it 'returns detailed status for created stage' do - expect(subject.text).to eq 'created' + expect(subject.text).to eq s_('CiStatusText|created') end end @@ -143,7 +143,7 @@ describe Ci::LegacyStage do let!(:stage_build) { create_job(:ci_build, status: :pending) } it 'returns detailed status for pending stage' do - expect(subject.text).to eq 'pending' + expect(subject.text).to eq s_('CiStatusText|pending') end end @@ -151,7 +151,7 @@ describe Ci::LegacyStage do let!(:stage_build) { create_job(:ci_build, status: :running) } it 'returns detailed status for running stage' do - expect(subject.text).to eq 'running' + expect(subject.text).to eq s_('CiStatus|running') end end @@ -159,7 +159,7 @@ describe Ci::LegacyStage do let!(:stage_build) { create_job(:ci_build, status: :success) } it 'returns detailed status for successful stage' do - expect(subject.text).to eq 'passed' + expect(subject.text).to eq s_('CiStatusText|passed') end end @@ -167,7 +167,7 @@ describe Ci::LegacyStage do let!(:stage_build) { create_job(:ci_build, status: :failed) } it 'returns detailed status for failed stage' do - expect(subject.text).to eq 'failed' + expect(subject.text).to eq s_('CiStatusText|failed') end end @@ -175,7 +175,7 @@ describe Ci::LegacyStage do let!(:stage_build) { create_job(:ci_build, status: :canceled) } it 'returns detailed status for canceled stage' do - expect(subject.text).to eq 'canceled' + expect(subject.text).to eq s_('CiStatusText|canceled') end end @@ -183,7 +183,7 @@ describe Ci::LegacyStage do let!(:stage_build) { create_job(:ci_build, status: :skipped) } it 'returns detailed status for skipped stage' do - expect(subject.text).to eq 'skipped' + expect(subject.text).to eq s_('CiStatusText|skipped') end end end diff --git a/spec/models/ci/pipeline_spec.rb b/spec/models/ci/pipeline_spec.rb index 3fa6dcc47a6..b60e240d596 100644 --- a/spec/models/ci/pipeline_spec.rb +++ b/spec/models/ci/pipeline_spec.rb @@ -1894,7 +1894,7 @@ describe Ci::Pipeline, :mailer do let(:pipeline) { create(:ci_pipeline, status: :created) } it 'returns detailed status for created pipeline' do - expect(subject.text).to eq 'created' + expect(subject.text).to eq s_('CiStatusText|created') end end @@ -1902,7 +1902,7 @@ describe Ci::Pipeline, :mailer do let(:pipeline) { create(:ci_pipeline, status: :pending) } it 'returns detailed status for pending pipeline' do - expect(subject.text).to eq 'pending' + expect(subject.text).to eq s_('CiStatusText|pending') end end @@ -1910,7 +1910,7 @@ describe Ci::Pipeline, :mailer do let(:pipeline) { create(:ci_pipeline, status: :running) } it 'returns detailed status for running pipeline' do - expect(subject.text).to eq 'running' + expect(subject.text).to eq s_('CiStatus|running') end end @@ -1918,7 +1918,7 @@ describe Ci::Pipeline, :mailer do let(:pipeline) { create(:ci_pipeline, status: :success) } it 'returns detailed status for successful pipeline' do - expect(subject.text).to eq 'passed' + expect(subject.text).to eq s_('CiStatusText|passed') end end @@ -1926,7 +1926,7 @@ describe Ci::Pipeline, :mailer do let(:pipeline) { create(:ci_pipeline, status: :failed) } it 'returns detailed status for failed pipeline' do - expect(subject.text).to eq 'failed' + expect(subject.text).to eq s_('CiStatusText|failed') end end @@ -1934,7 +1934,7 @@ describe Ci::Pipeline, :mailer do let(:pipeline) { create(:ci_pipeline, status: :canceled) } it 'returns detailed status for canceled pipeline' do - expect(subject.text).to eq 'canceled' + expect(subject.text).to eq s_('CiStatusText|canceled') end end @@ -1942,7 +1942,7 @@ describe Ci::Pipeline, :mailer do let(:pipeline) { create(:ci_pipeline, status: :skipped) } it 'returns detailed status for skipped pipeline' do - expect(subject.text).to eq 'skipped' + expect(subject.text).to eq s_('CiStatusText|skipped') end end @@ -1950,7 +1950,7 @@ describe Ci::Pipeline, :mailer do let(:pipeline) { create(:ci_pipeline, status: :manual) } it 'returns detailed status for blocked pipeline' do - expect(subject.text).to eq 'blocked' + expect(subject.text).to eq s_('CiStatusText|blocked') end end @@ -1962,7 +1962,7 @@ describe Ci::Pipeline, :mailer do end it 'retruns detailed status for successful pipeline with warnings' do - expect(subject.label).to eq 'passed with warnings' + expect(subject.label).to eq(s_('CiStatusLabel|passed with warnings')) end end end diff --git a/spec/models/ci/stage_spec.rb b/spec/models/ci/stage_spec.rb index 8827509edda..c997f1ef405 100644 --- a/spec/models/ci/stage_spec.rb +++ b/spec/models/ci/stage_spec.rb @@ -65,7 +65,7 @@ describe Ci::Stage, :models do it 'updates stage status correctly' do expect { stage.update_status } .to change { stage.reload.status } - .to 'running' + .to eq 'running' end end @@ -89,7 +89,7 @@ describe Ci::Stage, :models do it 'updates status to skipped' do expect { stage.update_status } .to change { stage.reload.status } - .to 'skipped' + .to eq 'skipped' end end @@ -109,7 +109,7 @@ describe Ci::Stage, :models do it 'updates status to skipped' do expect { stage.update_status } .to change { stage.reload.status } - .to 'skipped' + .to eq('skipped') end end @@ -171,7 +171,7 @@ describe Ci::Stage, :models do end it 'has a correct label' do - expect(subject.label).to eq label.to_s + expect(subject.label).to eq(label.to_s) end end @@ -187,7 +187,7 @@ describe Ci::Stage, :models do end it 'is passed with warnings' do - expect(subject.label).to eq 'passed with warnings' + expect(subject.label).to eq s_('CiStatusLabel|passed with warnings') end end end diff --git a/spec/models/clusters/cluster_spec.rb b/spec/models/clusters/cluster_spec.rb index 6aa643b122e..01abaea7399 100644 --- a/spec/models/clusters/cluster_spec.rb +++ b/spec/models/clusters/cluster_spec.rb @@ -674,7 +674,8 @@ describe Clusters::Cluster, :use_clean_rails_memory_store_caching do describe '#kubernetes_namespace_for' do let(:cluster) { create(:cluster, :group) } - let(:environment) { create(:environment) } + let(:environment) { create(:environment, last_deployable: build) } + let(:build) { create(:ci_build) } subject { cluster.kubernetes_namespace_for(environment) } @@ -682,16 +683,15 @@ describe Clusters::Cluster, :use_clean_rails_memory_store_caching do expect(Clusters::KubernetesNamespaceFinder).to receive(:new) .with(cluster, project: environment.project, environment_name: environment.name) .and_return(double(execute: persisted_namespace)) - end - - context 'a persisted namespace exists' do - let(:persisted_namespace) { create(:cluster_kubernetes_namespace) } - it { is_expected.to eq persisted_namespace.namespace } + allow(build).to receive(:expanded_kubernetes_namespace) + .and_return(ci_configured_namespace) end - context 'no persisted namespace exists' do + context 'no persisted namespace exists and namespace is not specified in CI template' do let(:persisted_namespace) { nil } + let(:ci_configured_namespace) { nil } + let(:namespace_generator) { double } let(:default_namespace) { 'a-default-namespace' } @@ -706,6 +706,27 @@ describe Clusters::Cluster, :use_clean_rails_memory_store_caching do it { is_expected.to eq default_namespace } end + + context 'persisted namespace exists' do + let(:persisted_namespace) { create(:cluster_kubernetes_namespace) } + let(:ci_configured_namespace) { nil } + + it { is_expected.to eq persisted_namespace.namespace } + end + + context 'namespace is specified in CI template' do + let(:persisted_namespace) { nil } + let(:ci_configured_namespace) { 'ci-configured-namespace' } + + it { is_expected.to eq ci_configured_namespace } + end + + context 'persisted namespace exists and namespace is also specifed in CI template' do + let(:persisted_namespace) { create(:cluster_kubernetes_namespace) } + let(:ci_configured_namespace) { 'ci-configured-namespace' } + + it { is_expected.to eq persisted_namespace.namespace } + end end describe '#predefined_variables' do diff --git a/spec/models/project_services/jira_service_spec.rb b/spec/models/project_services/jira_service_spec.rb index a6dd95437e3..8c14089fff2 100644 --- a/spec/models/project_services/jira_service_spec.rb +++ b/spec/models/project_services/jira_service_spec.rb @@ -344,7 +344,7 @@ describe JiraService do it 'returns default values' do expect(service.title).to eq('Jira') - expect(service.description).to eq('Jira issue tracker') + expect(service.description).to eq(s_('JiraService|Jira issue tracker')) end end end @@ -606,7 +606,7 @@ describe JiraService do service = create(:jira_service) expect(service.title).to eq('Jira') - expect(service.description).to eq('Jira issue tracker') + expect(service.description).to eq(s_('JiraService|Jira issue tracker')) end end diff --git a/spec/models/project_services/youtrack_service_spec.rb b/spec/models/project_services/youtrack_service_spec.rb index 19d4cb95315..dcc40d8f343 100644 --- a/spec/models/project_services/youtrack_service_spec.rb +++ b/spec/models/project_services/youtrack_service_spec.rb @@ -79,7 +79,7 @@ describe YoutrackService do it 'returns default values' do expect(service.title).to eq('YouTrack') - expect(service.description).to eq('YouTrack issue tracker') + expect(service.description).to eq(s_('IssueTracker|YouTrack issue tracker')) end end end diff --git a/spec/models/project_spec.rb b/spec/models/project_spec.rb index feb06f4ffc9..e5c30e4ca46 100644 --- a/spec/models/project_spec.rb +++ b/spec/models/project_spec.rb @@ -244,7 +244,7 @@ describe Project do new_project = build_stubbed(:project, namespace_id: project.namespace_id, path: "#{project.path}.wiki") expect(new_project).not_to be_valid - expect(new_project.errors[:name].first).to eq('has already been taken') + expect(new_project.errors[:name].first).to eq(_('has already been taken')) end end @@ -254,7 +254,7 @@ describe Project do new_project = build_stubbed(:project, namespace_id: project_with_wiki_suffix.namespace_id, path: 'foo') expect(new_project).not_to be_valid - expect(new_project.errors[:name].first).to eq('has already been taken') + expect(new_project.errors[:name].first).to eq(_('has already been taken')) end end end @@ -385,7 +385,7 @@ describe Project do end it 'contains errors related to the project being deleted' do - expect(new_project.errors.full_messages.first).to eq('The project is still being deleted. Please try again later.') + expect(new_project.errors.full_messages.first).to eq(_('The project is still being deleted. Please try again later.')) end end @@ -2270,7 +2270,7 @@ describe Project do it 'returns the right human import status' do project = create(:project, :import_started) - expect(project.human_import_status_name).to eq('started') + expect(project.human_import_status_name).to eq(_('started')) end end @@ -3282,6 +3282,54 @@ describe Project do it { expect(project.parent_changed?).to be_truthy } end + describe '#default_merge_request_target' do + context 'when forked from a more visible project' do + it 'returns the more restrictive project' do + project = create(:project, :public) + forked = fork_project(project) + forked.visibility = Gitlab::VisibilityLevel::PRIVATE + forked.save! + + expect(project.visibility).to eq 'public' + expect(forked.visibility).to eq 'private' + + expect(forked.default_merge_request_target).to eq(forked) + end + end + + context 'when forked from a project with disabled merge requests' do + it 'returns the current project' do + project = create(:project, :merge_requests_disabled) + forked = fork_project(project) + + expect(forked.forked_from_project).to receive(:merge_requests_enabled?) + .and_call_original + + expect(forked.default_merge_request_target).to eq(forked) + end + end + + context 'when forked from a project with enabled merge requests' do + it 'returns the source project' do + project = create(:project, :public) + forked = fork_project(project) + + expect(project.visibility).to eq 'public' + expect(forked.visibility).to eq 'public' + + expect(forked.default_merge_request_target).to eq(project) + end + end + + context 'when not forked' do + it 'returns the current project' do + project = build_stubbed(:project) + + expect(project.default_merge_request_target).to eq(project) + end + end + end + def enable_lfs allow(Gitlab.config.lfs).to receive(:enabled).and_return(true) end diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index 9e8aa6a95e8..49991dbd2d4 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -142,7 +142,7 @@ describe User, :do_not_mock_admin_mode do expect(user.namespace).to receive(:any_project_has_container_registry_tags?).and_return(true) user.username = 'new_path' expect(user).to be_invalid - expect(user.errors.messages[:username].first).to match('cannot be changed if a personal project has container registry tags') + expect(user.errors.messages[:username].first).to eq(_('cannot be changed if a personal project has container registry tags.')) end end @@ -3214,7 +3214,7 @@ describe User, :do_not_mock_admin_mode do it 'causes the user save to fail' do expect(user.update(username: new_username)).to be_falsey - expect(user.namespace.errors.messages[:path].first).to eq('has already been taken') + expect(user.namespace.errors.messages[:path].first).to eq(_('has already been taken')) end it 'adds the namespace errors to the user' do diff --git a/spec/requests/api/files_spec.rb b/spec/requests/api/files_spec.rb index 378441220c7..f1e1b8df8ee 100644 --- a/spec/requests/api/files_spec.rb +++ b/spec/requests/api/files_spec.rb @@ -636,7 +636,7 @@ describe API::Files do put api(route(file_path), user), params: params_with_stale_id expect(response).to have_gitlab_http_status(400) - expect(json_response['message']).to eq('You are attempting to update a file that has changed since you started editing it.') + expect(json_response['message']).to eq(_('You are attempting to update a file that has changed since you started editing it.')) end it "updates existing file in project repo with accepts correct last commit id" do diff --git a/spec/requests/api/group_clusters_spec.rb b/spec/requests/api/group_clusters_spec.rb index 97465647a87..14027db01c4 100644 --- a/spec/requests/api/group_clusters_spec.rb +++ b/spec/requests/api/group_clusters_spec.rb @@ -261,7 +261,7 @@ describe API::GroupClusters do it 'responds with 400' do expect(response).to have_gitlab_http_status(400) - expect(json_response['message']['base'].first).to include('Instance does not support multiple Kubernetes clusters') + expect(json_response['message']['base'].first).to eq(_('Instance does not support multiple Kubernetes clusters')) end end @@ -372,7 +372,7 @@ describe API::GroupClusters do end it 'returns validation error' do - expect(json_response['message']['platform_kubernetes.base'].first).to eq('Cannot modify managed Kubernetes cluster') + expect(json_response['message']['platform_kubernetes.base'].first).to eq(_('Cannot modify managed Kubernetes cluster')) end end diff --git a/spec/requests/api/issues/post_projects_issues_spec.rb b/spec/requests/api/issues/post_projects_issues_spec.rb index 3a55b437ead..e9f678d164e 100644 --- a/spec/requests/api/issues/post_projects_issues_spec.rb +++ b/spec/requests/api/issues/post_projects_issues_spec.rb @@ -453,7 +453,7 @@ describe API::Issues do params: { to_project_id: project.id } expect(response).to have_gitlab_http_status(400) - expect(json_response['message']).to eq('Cannot move issue to project it originates from!') + expect(json_response['message']).to eq(s_('MoveIssue|Cannot move issue to project it originates from!')) end end @@ -463,7 +463,7 @@ describe API::Issues do params: { to_project_id: target_project2.id } expect(response).to have_gitlab_http_status(400) - expect(json_response['message']).to eq('Cannot move issue due to insufficient permissions!') + expect(json_response['message']).to eq(s_('MoveIssue|Cannot move issue due to insufficient permissions!')) end end diff --git a/spec/requests/api/project_clusters_spec.rb b/spec/requests/api/project_clusters_spec.rb index 04e59238877..f3d005322f2 100644 --- a/spec/requests/api/project_clusters_spec.rb +++ b/spec/requests/api/project_clusters_spec.rb @@ -260,7 +260,7 @@ describe API::ProjectClusters do it 'responds with 400' do expect(response).to have_gitlab_http_status(400) - expect(json_response['message']['base'].first).to eq('Instance does not support multiple Kubernetes clusters') + expect(json_response['message']['base'].first).to eq(_('Instance does not support multiple Kubernetes clusters')) end end @@ -376,7 +376,7 @@ describe API::ProjectClusters do end it 'returns validation error' do - expect(json_response['message']['platform_kubernetes.base'].first).to eq('Cannot modify managed Kubernetes cluster') + expect(json_response['message']['platform_kubernetes.base'].first).to eq(_('Cannot modify managed Kubernetes cluster')) end end diff --git a/spec/serializers/job_entity_spec.rb b/spec/serializers/job_entity_spec.rb index 4b2d4701334..60843f1a599 100644 --- a/spec/serializers/job_entity_spec.rb +++ b/spec/serializers/job_entity_spec.rb @@ -153,11 +153,11 @@ describe JobEntity do end it 'states that it failed' do - expect(subject[:status][:label]).to eq('failed') + expect(subject[:status][:label]).to eq(s_('CiStatusLabel|failed')) end it 'indicates the failure reason on tooltip' do - expect(subject[:status][:tooltip]).to eq('failed - (API failure)') + expect(subject[:status][:tooltip]).to eq("#{s_('CiStatusLabel|failed')} - (API failure)") end it 'includes a callout message with a verbose output' do @@ -181,7 +181,7 @@ describe JobEntity do end it 'indicates the failure reason on tooltip' do - expect(subject[:status][:tooltip]).to eq('failed - (API failure) (allowed to fail)') + expect(subject[:status][:tooltip]).to eq("#{s_('CiStatusLabel|failed')} - (API failure) (allowed to fail)") end it 'includes a callout message with a verbose output' do diff --git a/spec/serializers/stage_entity_spec.rb b/spec/serializers/stage_entity_spec.rb index 58573df31e7..fb08d6994ae 100644 --- a/spec/serializers/stage_entity_spec.rb +++ b/spec/serializers/stage_entity_spec.rb @@ -29,7 +29,7 @@ describe StageEntity do it 'contains detailed status' do expect(subject[:status]).to include :text, :label, :group, :icon, :tooltip - expect(subject[:status][:label]).to eq 'passed' + expect(subject[:status][:label]).to eq s_('CiStatusLabel|passed') end it 'contains valid name' do @@ -47,7 +47,7 @@ describe StageEntity do end it 'contains stage title' do - expect(subject[:title]).to eq 'test: passed' + expect(subject[:title]).to eq "test: #{s_('CiStatusLabel|passed')}" end it 'does not contain play_details info' do diff --git a/spec/services/award_emojis/add_service_spec.rb b/spec/services/award_emojis/add_service_spec.rb index 037db39ba80..8364e662735 100644 --- a/spec/services/award_emojis/add_service_spec.rb +++ b/spec/services/award_emojis/add_service_spec.rb @@ -7,6 +7,7 @@ describe AwardEmojis::AddService do set(:project) { create(:project) } set(:awardable) { create(:note, project: project) } let(:name) { 'thumbsup' } + subject(:service) { described_class.new(awardable, name, user) } describe '#execute' do diff --git a/spec/services/award_emojis/destroy_service_spec.rb b/spec/services/award_emojis/destroy_service_spec.rb index c4a7d5ec20e..6d54c037464 100644 --- a/spec/services/award_emojis/destroy_service_spec.rb +++ b/spec/services/award_emojis/destroy_service_spec.rb @@ -10,6 +10,7 @@ describe AwardEmojis::DestroyService do let!(:award_from_other_user) do create(:award_emoji, name: name, awardable: awardable, user: create(:user)) end + subject(:service) { described_class.new(awardable, name, user) } describe '#execute' do diff --git a/spec/services/award_emojis/toggle_service_spec.rb b/spec/services/award_emojis/toggle_service_spec.rb index 972a1d5fc06..a8d110d04f7 100644 --- a/spec/services/award_emojis/toggle_service_spec.rb +++ b/spec/services/award_emojis/toggle_service_spec.rb @@ -7,6 +7,7 @@ describe AwardEmojis::ToggleService do set(:project) { create(:project, :public) } set(:awardable) { create(:note, project: project) } let(:name) { 'thumbsup' } + subject(:service) { described_class.new(awardable, name, user) } describe '#execute' do diff --git a/spec/services/branches/create_service_spec.rb b/spec/services/branches/create_service_spec.rb index 444491ed6f3..b0629c5e25a 100644 --- a/spec/services/branches/create_service_spec.rb +++ b/spec/services/branches/create_service_spec.rb @@ -4,6 +4,7 @@ require 'spec_helper' describe Branches::CreateService do let(:user) { create(:user) } + subject(:service) { described_class.new(project, user) } describe '#execute' do diff --git a/spec/services/branches/delete_service_spec.rb b/spec/services/branches/delete_service_spec.rb index b4848978a6f..2219416d94d 100644 --- a/spec/services/branches/delete_service_spec.rb +++ b/spec/services/branches/delete_service_spec.rb @@ -6,6 +6,7 @@ describe Branches::DeleteService do let(:project) { create(:project, :repository) } let(:repository) { project.repository } let(:user) { create(:user) } + subject(:service) { described_class.new(project, user) } shared_examples 'a deleted branch' do |branch_name| diff --git a/spec/services/branches/validate_new_service_spec.rb b/spec/services/branches/validate_new_service_spec.rb index 460f28b5844..6d5078d3ccb 100644 --- a/spec/services/branches/validate_new_service_spec.rb +++ b/spec/services/branches/validate_new_service_spec.rb @@ -4,6 +4,7 @@ require 'spec_helper' describe Branches::ValidateNewService do let(:project) { create(:project, :repository) } + subject(:service) { described_class.new(project) } describe '#execute' do diff --git a/spec/services/clusters/applications/check_installation_progress_service_spec.rb b/spec/services/clusters/applications/check_installation_progress_service_spec.rb index 02fd4b63c89..335397ee9f5 100644 --- a/spec/services/clusters/applications/check_installation_progress_service_spec.rb +++ b/spec/services/clusters/applications/check_installation_progress_service_spec.rb @@ -76,6 +76,7 @@ describe Clusters::Applications::CheckInstallationProgressService, '#execute' do context 'when installation POD succeeded' do let(:phase) { Gitlab::Kubernetes::Pod::SUCCEEDED } + before do expect(service).to receive(:pod_phase).once.and_return(phase) end @@ -137,6 +138,7 @@ describe Clusters::Applications::CheckInstallationProgressService, '#execute' do context 'when installation POD succeeded' do let(:phase) { Gitlab::Kubernetes::Pod::SUCCEEDED } + before do expect(service).to receive(:pod_phase).once.and_return(phase) end diff --git a/spec/services/clusters/applications/check_uninstall_progress_service_spec.rb b/spec/services/clusters/applications/check_uninstall_progress_service_spec.rb index 68ad0208226..a70b94a6fd6 100644 --- a/spec/services/clusters/applications/check_uninstall_progress_service_spec.rb +++ b/spec/services/clusters/applications/check_uninstall_progress_service_spec.rb @@ -46,6 +46,7 @@ describe Clusters::Applications::CheckUninstallProgressService do context 'when installation POD succeeded' do let(:phase) { Gitlab::Kubernetes::Pod::SUCCEEDED } + before do expect_any_instance_of(Gitlab::Kubernetes::Helm::Api) .to receive(:delete_pod!) diff --git a/spec/services/clusters/applications/patch_service_spec.rb b/spec/services/clusters/applications/patch_service_spec.rb index 3ebe0540837..c6d0fee43c4 100644 --- a/spec/services/clusters/applications/patch_service_spec.rb +++ b/spec/services/clusters/applications/patch_service_spec.rb @@ -51,7 +51,7 @@ describe Clusters::Applications::PatchService do service.execute expect(application).to be_update_errored - expect(application.status_reason).to match('Kubernetes error: 500') + expect(application.status_reason).to eq(_('Kubernetes error: %{error_code}') % { error_code: 500 }) end end @@ -73,7 +73,7 @@ describe Clusters::Applications::PatchService do service.execute expect(application).to be_update_errored - expect(application.status_reason).to eq('Failed to update.') + expect(application.status_reason).to eq(_('Failed to update.')) end end end diff --git a/spec/services/clusters/applications/upgrade_service_spec.rb b/spec/services/clusters/applications/upgrade_service_spec.rb index a80b1d9127c..48fa79eeb97 100644 --- a/spec/services/clusters/applications/upgrade_service_spec.rb +++ b/spec/services/clusters/applications/upgrade_service_spec.rb @@ -51,7 +51,7 @@ describe Clusters::Applications::UpgradeService do service.execute expect(application).to be_update_errored - expect(application.status_reason).to match('Kubernetes error: 500') + expect(application.status_reason).to eq(_('Kubernetes error: %{error_code}') % { error_code: 500 }) end end @@ -73,7 +73,7 @@ describe Clusters::Applications::UpgradeService do service.execute expect(application).to be_update_errored - expect(application.status_reason).to eq('Failed to upgrade.') + expect(application.status_reason).to eq(_('Failed to upgrade.')) end end end diff --git a/spec/services/clusters/kubernetes/fetch_kubernetes_token_service_spec.rb b/spec/services/clusters/kubernetes/fetch_kubernetes_token_service_spec.rb index 145528616ee..fa4b6e497e5 100644 --- a/spec/services/clusters/kubernetes/fetch_kubernetes_token_service_spec.rb +++ b/spec/services/clusters/kubernetes/fetch_kubernetes_token_service_spec.rb @@ -26,6 +26,7 @@ describe Clusters::Kubernetes::FetchKubernetesTokenService do context 'when params correct' do let(:decoded_token) { 'xxx.token.xxx' } let(:token) { Base64.encode64(decoded_token) } + context 'when the secret exists' do before do stub_kubeclient_get_secret( diff --git a/spec/services/compare_service_spec.rb b/spec/services/compare_service_spec.rb index fadd43635a6..f6d8eb348d0 100644 --- a/spec/services/compare_service_spec.rb +++ b/spec/services/compare_service_spec.rb @@ -28,6 +28,7 @@ describe CompareService do context 'compare with source branch that does not exist' do let(:service) { described_class.new(project, 'non-existent-branch') } + subject { service.execute(project, 'non-existent-ref') } it { expect(subject).to be_nil } diff --git a/spec/services/groups/create_service_spec.rb b/spec/services/groups/create_service_spec.rb index 0f9f20de586..5cde9a3ed45 100644 --- a/spec/services/groups/create_service_spec.rb +++ b/spec/services/groups/create_service_spec.rb @@ -60,7 +60,7 @@ describe Groups::CreateService, '#execute' do it 'does not save group and returns an error' do is_expected.not_to be_persisted - expect(subject.errors[:parent_id].first).to eq('You don’t have permission to create a subgroup in this group.') + expect(subject.errors[:parent_id].first).to eq(s_('CreateGroup|You don’t have permission to create a subgroup in this group.')) expect(subject.parent_id).to be_nil end end diff --git a/spec/services/issues/move_service_spec.rb b/spec/services/issues/move_service_spec.rb index 7483688d631..e39af7bbb72 100644 --- a/spec/services/issues/move_service_spec.rb +++ b/spec/services/issues/move_service_spec.rb @@ -191,6 +191,7 @@ describe Issues::MoveService do context 'issue is not persisted' do include_context 'user can move issue' let(:old_issue) { build(:issue, project: old_project, author: author) } + it { expect { move }.to raise_error(StandardError, /permissions/) } end end diff --git a/spec/services/issues/update_service_spec.rb b/spec/services/issues/update_service_spec.rb index b8a0e118479..64bca770d5b 100644 --- a/spec/services/issues/update_service_spec.rb +++ b/spec/services/issues/update_service_spec.rb @@ -151,6 +151,7 @@ describe Issues::UpdateService, :mailer do context 'when current user cannot admin issues in the project' do let(:guest) { create(:user) } + before do project.add_guest(guest) end diff --git a/spec/services/lfs/unlock_file_service_spec.rb b/spec/services/lfs/unlock_file_service_spec.rb index 8e36617c0d6..1334b074e84 100644 --- a/spec/services/lfs/unlock_file_service_spec.rb +++ b/spec/services/lfs/unlock_file_service_spec.rb @@ -18,7 +18,7 @@ describe Lfs::UnlockFileService do expect(result[:status]).to eq(:error) expect(result[:http_status]).to eq(403) - expect(result[:message]).to eq('You have no permissions') + expect(result[:message]).to eq(_('You have no permissions')) end end @@ -29,6 +29,7 @@ describe Lfs::UnlockFileService do context 'when lock does not exists' do let(:params) { { id: 123 } } + it "doesn't succeed" do result = subject.execute @@ -82,7 +83,7 @@ describe Lfs::UnlockFileService do result = subject.execute expect(result[:status]).to eq(:error) - expect(result[:message]).to match(/You must have maintainer access/) + expect(result[:message]).to eq(_('You must have maintainer access to force delete a lock')) expect(result[:http_status]).to eq(403) end end diff --git a/spec/services/merge_requests/get_urls_service_spec.rb b/spec/services/merge_requests/get_urls_service_spec.rb index 9e7a5260ca4..dcb8c8080a1 100644 --- a/spec/services/merge_requests/get_urls_service_spec.rb +++ b/spec/services/merge_requests/get_urls_service_spec.rb @@ -47,6 +47,7 @@ describe MergeRequests::GetUrlsService do context 'pushing to default branch' do let(:changes) { default_branch_changes } + it_behaves_like 'no_merge_request_url' end @@ -62,28 +63,33 @@ describe MergeRequests::GetUrlsService do context 'pushing one completely new branch' do let(:changes) { new_branch_changes } + it_behaves_like 'new_merge_request_link' end context 'pushing to existing branch but no merge request' do let(:changes) { existing_branch_changes } + it_behaves_like 'new_merge_request_link' end context 'pushing to deleted branch' do let(:changes) { deleted_branch_changes } + it_behaves_like 'no_merge_request_url' end context 'pushing to existing branch and merge request opened' do let!(:merge_request) { create(:merge_request, source_project: project, source_branch: source_branch) } let(:changes) { existing_branch_changes } + it_behaves_like 'show_merge_request_url' end context 'pushing to existing branch and merge request is reopened' do let!(:merge_request) { create(:merge_request, :opened, source_project: project, source_branch: source_branch) } let(:changes) { existing_branch_changes } + it_behaves_like 'show_merge_request_url' end @@ -105,12 +111,14 @@ describe MergeRequests::GetUrlsService do context 'pushing to existing branch and merge request is closed' do let!(:merge_request) { create(:merge_request, :closed, source_project: project, source_branch: source_branch) } let(:changes) { existing_branch_changes } + it_behaves_like 'new_merge_request_link' end context 'pushing to existing branch and merge request is merged' do let!(:merge_request) { create(:merge_request, :merged, source_project: project, source_branch: source_branch) } let(:changes) { existing_branch_changes } + it_behaves_like 'new_merge_request_link' end diff --git a/spec/services/merge_requests/refresh_service_spec.rb b/spec/services/merge_requests/refresh_service_spec.rb index 9e69f179da9..1ba216e8ff1 100644 --- a/spec/services/merge_requests/refresh_service_spec.rb +++ b/spec/services/merge_requests/refresh_service_spec.rb @@ -608,6 +608,7 @@ describe MergeRequests::RefreshService do context 'marking the merge request as work in progress' do let(:refresh_service) { service.new(@project, @user) } + before do allow(refresh_service).to receive(:execute_hooks) end diff --git a/spec/services/merge_requests/resolved_discussion_notification_service_spec.rb b/spec/services/merge_requests/resolved_discussion_notification_service_spec.rb index dc2bd5bf3d0..29896db58ac 100644 --- a/spec/services/merge_requests/resolved_discussion_notification_service_spec.rb +++ b/spec/services/merge_requests/resolved_discussion_notification_service_spec.rb @@ -6,6 +6,7 @@ describe MergeRequests::ResolvedDiscussionNotificationService do let(:merge_request) { create(:merge_request) } let(:user) { create(:user) } let(:project) { merge_request.project } + subject { described_class.new(project, user) } describe "#execute" do diff --git a/spec/services/notification_service_spec.rb b/spec/services/notification_service_spec.rb index c088cb376b3..b80f75c70e6 100644 --- a/spec/services/notification_service_spec.rb +++ b/spec/services/notification_service_spec.rb @@ -154,6 +154,7 @@ describe NotificationService, :mailer do describe '#async' do let(:async) { notification.async } + set(:key) { create(:personal_key) } it 'returns an Async object with the correct parent' do diff --git a/spec/services/projects/container_repository/delete_tags_service_spec.rb b/spec/services/projects/container_repository/delete_tags_service_spec.rb index 1cfe3582e56..7ceb02c9cf8 100644 --- a/spec/services/projects/container_repository/delete_tags_service_spec.rb +++ b/spec/services/projects/container_repository/delete_tags_service_spec.rb @@ -26,6 +26,7 @@ describe Projects::ContainerRepository::DeleteTagsService do describe '#execute' do let(:tags) { %w[A] } + subject { service.execute(repository) } context 'without permissions' do diff --git a/spec/services/projects/forks_count_service_spec.rb b/spec/services/projects/forks_count_service_spec.rb index 1b44782468a..21a75eafc7a 100644 --- a/spec/services/projects/forks_count_service_spec.rb +++ b/spec/services/projects/forks_count_service_spec.rb @@ -4,6 +4,7 @@ require 'spec_helper' describe Projects::ForksCountService, :use_clean_rails_memory_store_caching do let(:project) { build(:project) } + subject { described_class.new(project) } it_behaves_like 'a counter caching service' diff --git a/spec/services/projects/open_issues_count_service_spec.rb b/spec/services/projects/open_issues_count_service_spec.rb index 593a4df1f8f..04f1353c499 100644 --- a/spec/services/projects/open_issues_count_service_spec.rb +++ b/spec/services/projects/open_issues_count_service_spec.rb @@ -4,6 +4,7 @@ require 'spec_helper' describe Projects::OpenIssuesCountService, :use_clean_rails_memory_store_caching do let(:project) { create(:project) } + subject { described_class.new(project) } it_behaves_like 'a counter caching service' diff --git a/spec/services/prometheus/adapter_service_spec.rb b/spec/services/prometheus/adapter_service_spec.rb index 5e972a966eb..52e035e1f70 100644 --- a/spec/services/prometheus/adapter_service_spec.rb +++ b/spec/services/prometheus/adapter_service_spec.rb @@ -4,6 +4,7 @@ require 'spec_helper' describe Prometheus::AdapterService do let(:project) { create(:project) } + subject { described_class.new(project) } describe '#prometheus_adapter' do diff --git a/spec/services/quick_actions/interpret_service_spec.rb b/spec/services/quick_actions/interpret_service_spec.rb index 788f83cc233..b105e1e40ce 100644 --- a/spec/services/quick_actions/interpret_service_spec.rb +++ b/spec/services/quick_actions/interpret_service_spec.rb @@ -570,7 +570,7 @@ describe QuickActions::InterpretService do it 'returns move issue failure message when the referenced issue is not found' do _, _, message = service.execute('/move invalid', issue) - expect(message).to eq("Failed to move this issue because target project doesn't exist.") + expect(message).to eq(_("Failed to move this issue because target project doesn't exist.")) end end @@ -1125,7 +1125,7 @@ describe QuickActions::InterpretService do _, _, message = service.execute('/due invalid date', issue) - expect(message).to eq('Failed to set due date because the date format is invalid.') + expect(message).to eq(_('Failed to set due date because the date format is invalid.')) end it_behaves_like 'due command' do @@ -1251,12 +1251,12 @@ describe QuickActions::InterpretService do let(:issuable) { issue } end - it_behaves_like 'empty command', 'Failed to mark this issue as a duplicate because referenced issue was not found.' do + it_behaves_like 'empty command', _('Failed to mark this issue as a duplicate because referenced issue was not found.') do let(:content) { "/duplicate imaginary#1234" } let(:issuable) { issue } end - it_behaves_like 'empty command', 'Failed to mark this issue as a duplicate because referenced issue was not found.' do + it_behaves_like 'empty command', _('Failed to mark this issue as a duplicate because referenced issue was not found.') do let(:other_project) { create(:project, :private) } let(:issue_duplicate) { create(:issue, project: other_project) } @@ -1321,7 +1321,7 @@ describe QuickActions::InterpretService do let(:issuable) { issue } end - it_behaves_like 'empty command', 'Failed to mark this issue as a duplicate because referenced issue was not found.' do + it_behaves_like 'empty command', _('Failed to mark this issue as a duplicate because referenced issue was not found.') do let(:content) { '/duplicate #{issue.to_reference}' } let(:issuable) { issue } end @@ -1370,6 +1370,7 @@ describe QuickActions::InterpretService do context 'if issuable is a Commit' do let(:content) { '/award :100:' } let(:issuable) { commit } + it_behaves_like 'empty command' end end @@ -1497,23 +1498,27 @@ describe QuickActions::InterpretService do context 'if the given label does not exist' do let(:issuable) { issue } let(:content) { '/board_move ~"Fake Label"' } + it_behaves_like 'empty command', 'Failed to move this issue because label was not found.' end context 'if multiple labels are given' do let(:issuable) { issue } let(:content) { %{/board_move ~"#{inreview.title}" ~"#{todo.title}"} } + it_behaves_like 'empty command', 'Failed to move this issue because only a single label can be provided.' end context 'if the given label is not a list on the board' do let(:issuable) { issue } let(:content) { %{/board_move ~"#{bug.title}"} } + it_behaves_like 'empty command', 'Failed to move this issue because label was not found.' end context 'if issuable is not an Issue' do let(:issuable) { merge_request } + it_behaves_like 'empty command' end end @@ -1695,7 +1700,7 @@ describe QuickActions::InterpretService do merge_request.update!(label_ids: [bug.id]) _, explanations = service.explain(content, merge_request) - expect(explanations).to eq(['Removes all labels.']) + expect(explanations).to eq([_('Removes all labels.')]) end end @@ -1856,13 +1861,13 @@ describe QuickActions::InterpretService do it 'uses the default branch name' do _, explanations = service.explain(content, issue) - expect(explanations).to eq(['Creates a branch and a merge request to resolve this issue.']) + expect(explanations).to eq([_('Creates a branch and a merge request to resolve this issue.')]) end it 'returns the execution message using the default branch name' do _, _, message = service.execute(content, issue) - expect(message).to eq('Created a branch and a merge request to resolve this issue.') + expect(message).to eq(_('Created a branch and a merge request to resolve this issue.')) end end diff --git a/spec/services/search/group_service_spec.rb b/spec/services/search/group_service_spec.rb index aac2f3fe4cb..cfb672753b8 100644 --- a/spec/services/search/group_service_spec.rb +++ b/spec/services/search/group_service_spec.rb @@ -20,6 +20,7 @@ describe Search::GroupService do let!(:project3) { create(:project, :internal, namespace: nested_group.parent, name: "Outer #{term}") } let(:results) { described_class.new(user, search_group, search: term).execute } + subject { results.objects('projects') } context 'in parent group' do diff --git a/spec/services/system_note_service_spec.rb b/spec/services/system_note_service_spec.rb index e2ed7581ad4..bb457217b3f 100644 --- a/spec/services/system_note_service_spec.rb +++ b/spec/services/system_note_service_spec.rb @@ -348,7 +348,7 @@ describe SystemNoteService do it "blocks cross reference when #{type.underscore}_events is false" do jira_tracker.update("#{type}_events" => false) - expect(cross_reference(type)).to eq("Events for #{type.pluralize.humanize.downcase} are disabled.") + expect(cross_reference(type)).to eq(s_('JiraService|Events for %{noteable_model_name} are disabled.') % { noteable_model_name: type.pluralize.humanize.downcase }) end it "creates cross reference when #{type.underscore}_events is true" do diff --git a/spec/services/system_notes/issuables_service_spec.rb b/spec/services/system_notes/issuables_service_spec.rb index ba484d95c9c..c2f627c681b 100644 --- a/spec/services/system_notes/issuables_service_spec.rb +++ b/spec/services/system_notes/issuables_service_spec.rb @@ -618,6 +618,7 @@ describe ::SystemNotes::IssuablesService do context 'when notable is an ExternalIssue' do let(:noteable) { ExternalIssue.new('EXT-1234', project) } + it 'is truthy' do mentioner = noteable.dup expect(service.cross_reference_disallowed?(mentioner)) diff --git a/spec/services/todo_service_spec.rb b/spec/services/todo_service_spec.rb index 0d7e17ad52c..9b92590cb63 100644 --- a/spec/services/todo_service_spec.rb +++ b/spec/services/todo_service_spec.rb @@ -441,6 +441,7 @@ describe TodoService do context 'leaving a note on a commit in a public project' do let(:project) { create(:project, :repository, :public) } + it 'creates a todo for each valid mentioned user' do expected_todo = base_commit_todo_attrs.merge( action: Todo::MENTIONED, diff --git a/spec/services/users/keys_count_service_spec.rb b/spec/services/users/keys_count_service_spec.rb index 6b7493f343f..83af051e728 100644 --- a/spec/services/users/keys_count_service_spec.rb +++ b/spec/services/users/keys_count_service_spec.rb @@ -4,6 +4,7 @@ require 'spec_helper' describe Users::KeysCountService, :use_clean_rails_memory_store_caching do let(:user) { create(:user) } + subject { described_class.new(user) } it_behaves_like 'a counter caching service' diff --git a/spec/services/users/repair_ldap_blocked_service_spec.rb b/spec/services/users/repair_ldap_blocked_service_spec.rb index 0205b40bc97..bf80cc79d62 100644 --- a/spec/services/users/repair_ldap_blocked_service_spec.rb +++ b/spec/services/users/repair_ldap_blocked_service_spec.rb @@ -5,6 +5,7 @@ require 'spec_helper' describe Users::RepairLdapBlockedService do let(:user) { create(:omniauth_user, provider: 'ldapmain', state: 'ldap_blocked') } let(:identity) { user.ldap_identity } + subject(:service) { described_class.new(user) } describe '#execute' do diff --git a/spec/services/users/set_status_service_spec.rb b/spec/services/users/set_status_service_spec.rb index 7c26be48345..554f5e9dc5e 100644 --- a/spec/services/users/set_status_service_spec.rb +++ b/spec/services/users/set_status_service_spec.rb @@ -4,6 +4,7 @@ require 'spec_helper' describe Users::SetStatusService do let(:current_user) { create(:user) } + subject(:service) { described_class.new(current_user, params) } describe '#execute' do diff --git a/spec/services/wikis/create_attachment_service_spec.rb b/spec/services/wikis/create_attachment_service_spec.rb index f5899f292c8..7a73a0a555f 100644 --- a/spec/services/wikis/create_attachment_service_spec.rb +++ b/spec/services/wikis/create_attachment_service_spec.rb @@ -174,6 +174,7 @@ describe Wikis::CreateAttachmentService do describe '#execute' do let(:wiki) { project.wiki } + subject(:service_execute) { service.execute[:result] } context 'creates branch if it does not exists' do diff --git a/spec/support/shared_examples/policies/project_policy_shared_examples.rb b/spec/support/shared_examples/policies/project_policy_shared_examples.rb index 13b7ade658b..37f8bc14e20 100644 --- a/spec/support/shared_examples/policies/project_policy_shared_examples.rb +++ b/spec/support/shared_examples/policies/project_policy_shared_examples.rb @@ -4,7 +4,7 @@ RSpec.shared_examples 'archived project policies' do let(:feature_write_abilities) do described_class::READONLY_FEATURES_WHEN_ARCHIVED.flat_map do |feature| described_class.create_update_admin_destroy(feature) - end + additional_reporter_permissions + additional_maintainer_permissions + end + additional_maintainer_permissions end let(:other_write_abilities) do @@ -18,6 +18,7 @@ RSpec.shared_examples 'archived project policies' do resolve_note award_emoji admin_tag + admin_issue_link ] end |