diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-12-02 03:07:06 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-12-02 03:07:06 +0300 |
commit | b26eec8cbcf32085079eee0e196456eccefc993f (patch) | |
tree | 822f69aeec23b0b3512583b2221000a8035241f7 /spec | |
parent | 61666f277a484725307ae2b34697b13a300b2129 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec')
-rw-r--r-- | spec/controllers/projects/merge_requests/conflicts_controller_spec.rb | 14 | ||||
-rw-r--r-- | spec/finders/personal_access_tokens_finder_spec.rb | 475 | ||||
-rw-r--r-- | spec/frontend/ci/reports/codequality_report/components/codequality_issue_body_spec.js (renamed from spec/frontend/reports/codequality_report/components/codequality_issue_body_spec.js) | 4 | ||||
-rw-r--r-- | spec/frontend/ci/reports/codequality_report/mock_data.js (renamed from spec/frontend/reports/codequality_report/mock_data.js) | 0 | ||||
-rw-r--r-- | spec/frontend/ci/reports/codequality_report/store/actions_spec.js (renamed from spec/frontend/reports/codequality_report/store/actions_spec.js) | 8 | ||||
-rw-r--r-- | spec/frontend/ci/reports/codequality_report/store/getters_spec.js (renamed from spec/frontend/reports/codequality_report/store/getters_spec.js) | 6 | ||||
-rw-r--r-- | spec/frontend/ci/reports/codequality_report/store/mutations_spec.js (renamed from spec/frontend/reports/codequality_report/store/mutations_spec.js) | 6 | ||||
-rw-r--r-- | spec/frontend/ci/reports/codequality_report/store/utils/codequality_parser_spec.js (renamed from spec/frontend/reports/codequality_report/store/utils/codequality_parser_spec.js) | 4 | ||||
-rw-r--r-- | spec/frontend/ci/reports/components/__snapshots__/grouped_issues_list_spec.js.snap (renamed from spec/frontend/reports/components/__snapshots__/grouped_issues_list_spec.js.snap) | 0 | ||||
-rw-r--r-- | spec/frontend/ci/reports/components/__snapshots__/issue_status_icon_spec.js.snap (renamed from spec/frontend/reports/components/__snapshots__/issue_status_icon_spec.js.snap) | 0 | ||||
-rw-r--r-- | spec/frontend/ci/reports/components/grouped_issues_list_spec.js (renamed from spec/frontend/reports/components/grouped_issues_list_spec.js) | 4 | ||||
-rw-r--r-- | spec/frontend/ci/reports/components/issue_status_icon_spec.js (renamed from spec/frontend/reports/components/issue_status_icon_spec.js) | 4 | ||||
-rw-r--r-- | spec/frontend/ci/reports/components/report_item_spec.js (renamed from spec/frontend/reports/components/report_item_spec.js) | 8 | ||||
-rw-r--r-- | spec/frontend/ci/reports/components/report_link_spec.js (renamed from spec/frontend/reports/components/report_link_spec.js) | 4 | ||||
-rw-r--r-- | spec/frontend/ci/reports/components/report_section_spec.js (renamed from spec/frontend/reports/components/report_section_spec.js) | 4 | ||||
-rw-r--r-- | spec/frontend/ci/reports/components/summary_row_spec.js (renamed from spec/frontend/reports/components/summary_row_spec.js) | 2 | ||||
-rw-r--r-- | spec/frontend/ci/reports/mock_data/mock_data.js (renamed from spec/frontend/reports/mock_data/mock_data.js) | 0 | ||||
-rw-r--r-- | spec/frontend/ci/reports/mock_data/new_and_fixed_failures_report.json (renamed from spec/frontend/reports/mock_data/new_and_fixed_failures_report.json) | 23 | ||||
-rw-r--r-- | spec/frontend/ci/reports/mock_data/new_errors_report.json (renamed from spec/frontend/reports/mock_data/new_errors_report.json) | 23 | ||||
-rw-r--r-- | spec/frontend/ci/reports/mock_data/new_failures_report.json (renamed from spec/frontend/reports/mock_data/new_failures_report.json) | 23 | ||||
-rw-r--r-- | spec/frontend/ci/reports/mock_data/new_failures_with_null_files_report.json (renamed from spec/frontend/reports/mock_data/new_failures_with_null_files_report.json) | 23 | ||||
-rw-r--r-- | spec/frontend/ci/reports/mock_data/no_failures_report.json (renamed from spec/frontend/reports/mock_data/no_failures_report.json) | 23 | ||||
-rw-r--r-- | spec/frontend/ci/reports/mock_data/recent_failures_report.json (renamed from spec/frontend/reports/mock_data/recent_failures_report.json) | 26 | ||||
-rw-r--r-- | spec/frontend/ci/reports/mock_data/resolved_failures.json (renamed from spec/frontend/reports/mock_data/resolved_failures.json) | 25 | ||||
-rw-r--r-- | spec/frontend/diffs/components/diff_code_quality_spec.js | 2 | ||||
-rw-r--r-- | spec/frontend/vue_merge_request_widget/extensions/test_report/index_spec.js | 16 | ||||
-rw-r--r-- | spec/lib/gitlab/audit/type/definition_spec.rb | 6 | ||||
-rw-r--r-- | spec/support/import_export/export_file_helper.rb | 4 | ||||
-rw-r--r-- | spec/support/shared_examples/finders/snippet_visibility_shared_examples.rb | 4 | ||||
-rw-r--r-- | spec/support/shared_examples/metrics/active_record_subscriber_shared_examples.rb | 4 |
30 files changed, 409 insertions, 336 deletions
diff --git a/spec/controllers/projects/merge_requests/conflicts_controller_spec.rb b/spec/controllers/projects/merge_requests/conflicts_controller_spec.rb index 366a1e587ab..311af26abf6 100644 --- a/spec/controllers/projects/merge_requests/conflicts_controller_spec.rb +++ b/spec/controllers/projects/merge_requests/conflicts_controller_spec.rb @@ -105,15 +105,13 @@ RSpec.describe Projects::MergeRequests::ConflictsController do if section['conflict'] expect(line['type']).to be_in(%w(old new)) expect(line.values_at('old_line', 'new_line')).to contain_exactly(nil, a_kind_of(Integer)) + elsif line['type'].nil? + expect(line['old_line']).not_to eq(nil) + expect(line['new_line']).not_to eq(nil) else - if line['type'].nil? - expect(line['old_line']).not_to eq(nil) - expect(line['new_line']).not_to eq(nil) - else - expect(line['type']).to eq('match') - expect(line['old_line']).to eq(nil) - expect(line['new_line']).to eq(nil) - end + expect(line['type']).to eq('match') + expect(line['old_line']).to eq(nil) + expect(line['new_line']).to eq(nil) end end end diff --git a/spec/finders/personal_access_tokens_finder_spec.rb b/spec/finders/personal_access_tokens_finder_spec.rb index 21380cb6632..bcd5aef84f9 100644 --- a/spec/finders/personal_access_tokens_finder_spec.rb +++ b/spec/finders/personal_access_tokens_finder_spec.rb @@ -2,359 +2,320 @@ require 'spec_helper' -RSpec.describe PersonalAccessTokensFinder do - def finder(options = {}, current_user = nil) - described_class.new(options, current_user) - end - - describe '# searches PATs' do - using RSpec::Parameterized::TableSyntax +RSpec.describe PersonalAccessTokensFinder, :enable_admin_mode do + using RSpec::Parameterized::TableSyntax - let_it_be(:time_token) do - create(:personal_access_token, created_at: DateTime.new(2022, 01, 02), - last_used_at: DateTime.new(2022, 01, 02)) + describe '#execute' do + let(:admin) { create(:admin) } + let(:user) { create(:user) } + let(:other_user) { create(:user) } + let(:project_bot) { create(:user, :project_bot) } + + let!(:tokens) do + { + active: create(:personal_access_token, user: user, name: 'my_pat_1'), + active_other: create(:personal_access_token, user: other_user, name: 'my_pat_2'), + expired: create(:personal_access_token, :expired, user: user), + revoked: create(:personal_access_token, :revoked, user: user), + active_impersonation: create(:personal_access_token, :impersonation, user: user), + expired_impersonation: create(:personal_access_token, :expired, :impersonation, user: user), + revoked_impersonation: create(:personal_access_token, :revoked, :impersonation, user: user), + bot: create(:personal_access_token, user: project_bot) + } end - let_it_be(:name_token) { create(:personal_access_token, name: 'test_1') } - - let_it_be(:impersonated_token) do - create(:personal_access_token, :impersonation, - created_at: DateTime.new(2022, 01, 02), - last_used_at: DateTime.new(2022, 01, 02), - name: 'imp_token' - ) - end + let(:params) { {} } + let(:current_user) { admin } - shared_examples 'finding tokens by user and options' do - subject { finder(option, user).execute } + subject { described_class.new(params, current_user).execute } - it 'finds exactly' do - subject + describe 'by current user' do + context 'with no user' do + let(:current_user) { nil } - is_expected.to contain_exactly(*result) + it 'returns all tokens' do + is_expected.to match_array(tokens.values) + end end - end - context 'by' do - where(:option, :user, :result) do - { created_before: DateTime.new(2022, 01, 03) } | create(:admin) | lazy { [time_token, impersonated_token] } - { created_after: DateTime.new(2022, 01, 01) } | create(:admin) | lazy { [time_token, name_token, impersonated_token] } - { last_used_before: DateTime.new(2022, 01, 03) } | create(:admin) | lazy { [time_token, impersonated_token] } - { last_used_before: DateTime.new(2022, 01, 03) } | create(:admin) | lazy { [time_token, impersonated_token] } - { impersonation: true } | create(:admin) | lazy { [impersonated_token] } - { search: 'test' } | create(:admin) | lazy { [name_token] } - end + context 'with admin' do + let(:current_user) { admin } - with_them do - it_behaves_like 'finding tokens by user and options' - end - end - end - - describe '#execute' do - let(:user) { create(:user) } - let(:params) { {} } - let(:current_user) { nil } - let!(:active_personal_access_token) { create(:personal_access_token, user: user) } - let!(:expired_personal_access_token) { create(:personal_access_token, :expired, user: user) } - let!(:revoked_personal_access_token) { create(:personal_access_token, :revoked, user: user) } - let!(:active_impersonation_token) { create(:personal_access_token, :impersonation, user: user) } - let!(:expired_impersonation_token) { create(:personal_access_token, :expired, :impersonation, user: user) } - let!(:revoked_impersonation_token) { create(:personal_access_token, :revoked, :impersonation, user: user) } - let!(:project_bot) { create(:user, :project_bot) } - let!(:project_member) { create(:project_member, user: project_bot) } - let!(:project_access_token) { create(:personal_access_token, user: project_bot) } - - subject { finder(params, current_user).execute } - - context 'when current_user is defined' do - let(:current_user) { create(:admin) } - let(:params) { { user: user } } - - context 'current_user is allowed to read PATs' do - it do - is_expected.to contain_exactly(active_personal_access_token, active_impersonation_token, - revoked_personal_access_token, expired_personal_access_token, - revoked_impersonation_token, expired_impersonation_token) + context 'when admin mode setting is disabled', :do_not_mock_admin_mode_setting do + it 'returns all tokens' do + is_expected.to match_array(tokens.values) + end end - end - context 'current_user is not allowed to read PATs' do - let(:current_user) { create(:user) } + context 'when admin mode setting is enabled' do + context 'when in admin mode', :enable_admin_mode do + it 'returns all tokens' do + is_expected.to match_array(tokens.values) + end + end + + context 'when not in admin mode' do + before do + allow_next_instance_of(Gitlab::Auth::CurrentUserMode) do |current_user_mode| + allow(current_user_mode).to receive(:admin_mode?).and_return(false) + end + end - it { is_expected.to be_empty } + it 'returns no tokens' do + is_expected.to be_empty + end + end + end end - context 'when user param is not set' do - let(:params) { {} } + context 'when user can read user personal access tokens' do + let(:params) { { user: user } } + let(:current_user) { user } - it do - is_expected.to contain_exactly(active_personal_access_token, active_impersonation_token, - revoked_personal_access_token, expired_personal_access_token, - revoked_impersonation_token, expired_impersonation_token, project_access_token) + it 'returns tokens of user' do + is_expected.to contain_exactly(*user.personal_access_tokens) end + end - context 'when current_user is not an administrator' do - let(:current_user) { create(:user) } + context 'when user can not read user personal access tokens' do + let(:params) { { user: other_user } } + let(:current_user) { user } - it { is_expected.to be_empty } + it 'returns no tokens' do + is_expected.to be_empty end end end - describe 'without user' do - it do - is_expected.to contain_exactly(active_personal_access_token, active_impersonation_token, - revoked_personal_access_token, expired_personal_access_token, - revoked_impersonation_token, expired_impersonation_token, project_access_token) + describe 'by user' do + where(:by_user, :expected_tokens) do + nil | tokens.keys + ref(:user) | [:active, :expired, :revoked, :active_impersonation, :expired_impersonation, :revoked_impersonation] + ref(:other_user) | [:active_other] + ref(:admin) | [] end - describe 'with users' do - let(:user2) { create(:user) } - - before do - create(:personal_access_token, user: user2) - create(:personal_access_token, :expired, user: user2) - create(:personal_access_token, :revoked, user: user2) - create(:personal_access_token, :impersonation, user: user2) - create(:personal_access_token, :expired, :impersonation, user: user2) - create(:personal_access_token, :revoked, :impersonation, user: user2) + with_them do + let(:params) { { user: by_user } } - params[:users] = [user] + it 'returns tokens by user' do + is_expected.to match_array(tokens.values_at(*expected_tokens)) end - - it { - is_expected.to contain_exactly(active_personal_access_token, active_impersonation_token, - revoked_personal_access_token, expired_personal_access_token, - revoked_impersonation_token, expired_impersonation_token) - } end + end - describe 'with sort order' do - before do - params[:sort] = 'id_asc' - end - - it 'sorts records as per the specified sort order' do - expect(subject).to match_array(PersonalAccessToken.all.order(id: :asc)) - end + describe 'by users' do + where(:by_users, :expected_tokens) do + nil | tokens.keys + lazy { [user] } | [:active, :expired, :revoked, :active_impersonation, :expired_impersonation, :revoked_impersonation] + lazy { [other_user] } | [:active_other] + lazy { [user, other_user] } | [:active, :active_other, :expired, :revoked, :active_impersonation, :expired_impersonation, :revoked_impersonation] + [] | [] # rubocop:disable Lint/BinaryOperatorWithIdenticalOperands end - describe 'without impersonation' do - before do - params[:impersonation] = false - end - - it { is_expected.to contain_exactly(active_personal_access_token, revoked_personal_access_token, expired_personal_access_token, project_access_token) } - - describe 'with active state' do - before do - params[:state] = 'active' - end - - it { is_expected.to contain_exactly(active_personal_access_token, project_access_token) } - end - - describe 'with inactive state' do - before do - params[:state] = 'inactive' - end + with_them do + let(:params) { { users: by_users } } - it { is_expected.to contain_exactly(revoked_personal_access_token, expired_personal_access_token) } + it 'returns tokens by users' do + is_expected.to match_array(tokens.values_at(*expected_tokens)) end end + end - describe 'with impersonation' do - before do - params[:impersonation] = true - end - - it { is_expected.to contain_exactly(active_impersonation_token, revoked_impersonation_token, expired_impersonation_token) } - - describe 'with active state' do - before do - params[:state] = 'active' - end - - it { is_expected.to contain_exactly(active_impersonation_token) } - end + describe 'by impersonation' do + where(:by_impersonation, :expected_tokens) do + nil | tokens.keys + true | [:active_impersonation, :expired_impersonation, :revoked_impersonation] + false | [:active, :active_other, :expired, :revoked, :bot] + 'other' | tokens.keys + end - describe 'with inactive state' do - before do - params[:state] = 'inactive' - end + with_them do + let(:params) { { impersonation: by_impersonation } } - it { is_expected.to contain_exactly(revoked_impersonation_token, expired_impersonation_token) } + it 'returns tokens by impersonation' do + is_expected.to match_array(tokens.values_at(*expected_tokens)) end end + end - describe 'with active state' do - before do - params[:state] = 'active' - end - - it { is_expected.to contain_exactly(active_personal_access_token, active_impersonation_token, project_access_token) } + describe 'by state' do + where(:by_state, :expected_tokens) do + nil | tokens.keys + 'active' | [:active, :active_other, :active_impersonation, :bot] + 'inactive' | [:expired, :revoked, :expired_impersonation, :revoked_impersonation] + 'other' | tokens.keys end - describe 'with inactive state' do - before do - params[:state] = 'inactive' - end + with_them do + let(:params) { { state: by_state } } - it do - is_expected.to contain_exactly(expired_personal_access_token, revoked_personal_access_token, - expired_impersonation_token, revoked_impersonation_token) + it 'returns tokens by state' do + is_expected.to match_array(tokens.values_at(*expected_tokens)) end end + end - describe 'with id' do - subject { finder(params).find_by_id(active_personal_access_token.id) } - - it { is_expected.to eq(active_personal_access_token) } + describe 'by owner type' do + where(:by_owner_type, :expected_tokens) do + nil | tokens.keys + 'human' | [:active, :active_other, :expired, :revoked, :active_impersonation, :expired_impersonation, :revoked_impersonation] + 'other' | tokens.keys + end - describe 'with impersonation' do - before do - params[:impersonation] = true - end + with_them do + let(:params) { { owner_type: by_owner_type } } - it { is_expected.to be_nil } + it 'returns tokens by owner type' do + is_expected.to match_array(tokens.values_at(*expected_tokens)) end end + end - describe 'with token' do - subject { finder(params).find_by_token(active_personal_access_token.token) } - - it { is_expected.to eq(active_personal_access_token) } + describe 'by revoked state' do + where(:by_revoked_state, :expected_tokens) do + nil | [:active, :active_other, :expired, :active_impersonation, :expired_impersonation, :bot] + true | [:revoked, :revoked_impersonation] + false | [:active, :active_other, :expired, :active_impersonation, :expired_impersonation, :bot] + end - describe 'with impersonation' do - before do - params[:impersonation] = true - end + with_them do + let(:params) { { revoked: by_revoked_state } } - it { is_expected.to be_nil } + it 'returns tokens by revoked state' do + is_expected.to match_array(tokens.values_at(*expected_tokens)) end end end - describe 'with user' do - let(:user2) { create(:user) } - let!(:other_user_active_personal_access_token) { create(:personal_access_token, user: user2) } - let!(:other_user_expired_personal_access_token) { create(:personal_access_token, :expired, user: user2) } - let!(:other_user_revoked_personal_access_token) { create(:personal_access_token, :revoked, user: user2) } - let!(:other_user_active_impersonation_token) { create(:personal_access_token, :impersonation, user: user2) } - let!(:other_user_expired_impersonation_token) { create(:personal_access_token, :expired, :impersonation, user: user2) } - let!(:other_user_revoked_impersonation_token) { create(:personal_access_token, :revoked, :impersonation, user: user2) } - + describe 'by created date' do before do - params[:user] = user - end - - it do - is_expected.to contain_exactly(active_personal_access_token, active_impersonation_token, - revoked_personal_access_token, expired_personal_access_token, - revoked_impersonation_token, expired_impersonation_token) + tokens[:active_other].update!(created_at: 5.days.ago) end - describe 'filtering human tokens' do - before do - params[:owner_type] = 'human' + describe 'by created before' do + where(:by_created_before, :expected_tokens) do + 6.days.ago | [] + 2.days.ago | [:active_other] + 2.days.from_now | tokens.keys end - it { is_expected.not_to include(project_access_token) } + with_them do + let(:params) { { created_before: by_created_before } } + + it 'returns tokens by created before' do + is_expected.to match_array(tokens.values_at(*expected_tokens)) + end + end end - describe 'without impersonation' do - before do - params[:impersonation] = false + describe 'by created after' do + where(:by_created_after, :expected_tokens) do + 6.days.ago | tokens.keys + 2.days.ago | [:active, :expired, :revoked, :active_impersonation, :expired_impersonation, :revoked_impersonation, :bot] + 2.days.from_now | [] end - it { is_expected.to contain_exactly(active_personal_access_token, revoked_personal_access_token, expired_personal_access_token) } + with_them do + let(:params) { { created_after: by_created_after } } - describe 'with active state' do - before do - params[:state] = 'active' + it 'returns tokens by created before' do + is_expected.to match_array(tokens.values_at(*expected_tokens)) end - - it { is_expected.to contain_exactly(active_personal_access_token) } end + end + end - describe 'with inactive state' do - before do - params[:state] = 'inactive' - end - - it { is_expected.to contain_exactly(revoked_personal_access_token, expired_personal_access_token) } - end + describe 'by last used date' do + before do + PersonalAccessToken.update_all(last_used_at: Time.now) + tokens[:active_other].update!(last_used_at: 5.days.ago) end - describe 'with impersonation' do - before do - params[:impersonation] = true + describe 'by last used before' do + where(:by_last_used_before, :expected_tokens) do + 6.days.ago | [] + 2.days.ago | [:active_other] + 2.days.from_now | tokens.keys end - it { is_expected.to contain_exactly(active_impersonation_token, revoked_impersonation_token, expired_impersonation_token) } + with_them do + let(:params) { { last_used_before: by_last_used_before } } - describe 'with active state' do - before do - params[:state] = 'active' + it 'returns tokens by last used before' do + is_expected.to match_array(tokens.values_at(*expected_tokens)) end + end + end - it { is_expected.to contain_exactly(active_impersonation_token) } + describe 'by last used after' do + where(:by_last_used_after, :expected_tokens) do + 6.days.ago | tokens.keys + 2.days.ago | [:active, :expired, :revoked, :active_impersonation, :expired_impersonation, :revoked_impersonation, :bot] + 2.days.from_now | [] end - describe 'with inactive state' do - before do - params[:state] = 'inactive' - end + with_them do + let(:params) { { last_used_after: by_last_used_after } } - it { is_expected.to contain_exactly(revoked_impersonation_token, expired_impersonation_token) } + it 'returns tokens by last used after' do + is_expected.to match_array(tokens.values_at(*expected_tokens)) + end end end + end - describe 'with active state' do - before do - params[:state] = 'active' - end - - it { is_expected.to contain_exactly(active_personal_access_token, active_impersonation_token) } + describe 'by search' do + where(:by_search, :expected_tokens) do + nil | tokens.keys + 'my_pat' | [:active, :active_other] + 'other' | [] end - describe 'with inactive state' do - before do - params[:state] = 'inactive' - end + with_them do + let(:params) { { search: by_search } } - it do - is_expected.to contain_exactly(expired_personal_access_token, revoked_personal_access_token, - expired_impersonation_token, revoked_impersonation_token) + it 'returns tokens by search' do + is_expected.to match_array(tokens.values_at(*expected_tokens)) end end + end - describe 'with id' do - subject { finder(params).find_by_id(active_personal_access_token.id) } - - it { is_expected.to eq(active_personal_access_token) } + describe 'sort' do + where(:sort, :expected_tokens) do + nil | tokens.keys + 'id_asc' | [:active, :active_other, :expired, :revoked, :active_impersonation, :expired_impersonation, :revoked_impersonation, :bot] + 'id_desc' | [:bot, :revoked_impersonation, :expired_impersonation, :active_impersonation, :revoked, :expired, :active_other, :active] + 'other' | tokens.keys + end - describe 'with impersonation' do - before do - params[:impersonation] = true - end + with_them do + let(:params) { { sort: sort } } - it { is_expected.to be_nil } + it 'returns ordered tokens' do + expect(subject.map(&:id)).to eq(tokens.values_at(*expected_tokens).map(&:id)) end end + end - describe 'with token' do - subject { finder(params).find_by_token(active_personal_access_token.token) } + describe 'delegates' do + subject { described_class.new(params, current_user) } - it { is_expected.to eq(active_personal_access_token) } + describe '#find_by_id' do + it 'returns token by id' do + expect(subject.find_by_id(tokens[:active].id)).to eq(tokens[:active]) + end + end - describe 'with impersonation' do - before do - params[:impersonation] = true - end + describe '#find_by_token' do + it 'returns token by token' do + expect(subject.find_by_token(tokens[:active].token)).to eq(tokens[:active]) + end + end - it { is_expected.to be_nil } + describe '#find' do + it 'returns token by id' do + expect(subject.find(tokens[:active].id)).to eq(tokens[:active]) end end end diff --git a/spec/frontend/reports/codequality_report/components/codequality_issue_body_spec.js b/spec/frontend/ci/reports/codequality_report/components/codequality_issue_body_spec.js index c32b52d9e77..5ca4b25da9b 100644 --- a/spec/frontend/reports/codequality_report/components/codequality_issue_body_spec.js +++ b/spec/frontend/ci/reports/codequality_report/components/codequality_issue_body_spec.js @@ -1,8 +1,8 @@ import { GlIcon } from '@gitlab/ui'; import { shallowMount } from '@vue/test-utils'; import { extendedWrapper } from 'helpers/vue_test_utils_helper'; -import component from '~/reports/codequality_report/components/codequality_issue_body.vue'; -import { STATUS_FAILED, STATUS_NEUTRAL, STATUS_SUCCESS } from '~/reports/constants'; +import component from '~/ci/reports/codequality_report/components/codequality_issue_body.vue'; +import { STATUS_FAILED, STATUS_NEUTRAL, STATUS_SUCCESS } from '~/ci/reports/constants'; describe('code quality issue body issue body', () => { let wrapper; diff --git a/spec/frontend/reports/codequality_report/mock_data.js b/spec/frontend/ci/reports/codequality_report/mock_data.js index 2c994116db6..2c994116db6 100644 --- a/spec/frontend/reports/codequality_report/mock_data.js +++ b/spec/frontend/ci/reports/codequality_report/mock_data.js diff --git a/spec/frontend/reports/codequality_report/store/actions_spec.js b/spec/frontend/ci/reports/codequality_report/store/actions_spec.js index 1878b9f44b2..88628210793 100644 --- a/spec/frontend/reports/codequality_report/store/actions_spec.js +++ b/spec/frontend/ci/reports/codequality_report/store/actions_spec.js @@ -2,10 +2,10 @@ import MockAdapter from 'axios-mock-adapter'; import testAction from 'helpers/vuex_action_helper'; import { TEST_HOST } from 'spec/test_constants'; import axios from '~/lib/utils/axios_utils'; -import createStore from '~/reports/codequality_report/store'; -import * as actions from '~/reports/codequality_report/store/actions'; -import * as types from '~/reports/codequality_report/store/mutation_types'; -import { STATUS_NOT_FOUND } from '~/reports/constants'; +import createStore from '~/ci/reports/codequality_report/store'; +import * as actions from '~/ci/reports/codequality_report/store/actions'; +import * as types from '~/ci/reports/codequality_report/store/mutation_types'; +import { STATUS_NOT_FOUND } from '~/ci/reports/constants'; import { reportIssues, parsedReportIssues } from '../mock_data'; const pollInterval = 123; diff --git a/spec/frontend/reports/codequality_report/store/getters_spec.js b/spec/frontend/ci/reports/codequality_report/store/getters_spec.js index 646903390ff..f4505204f67 100644 --- a/spec/frontend/reports/codequality_report/store/getters_spec.js +++ b/spec/frontend/ci/reports/codequality_report/store/getters_spec.js @@ -1,6 +1,6 @@ -import createStore from '~/reports/codequality_report/store'; -import * as getters from '~/reports/codequality_report/store/getters'; -import { LOADING, ERROR, SUCCESS, STATUS_NOT_FOUND } from '~/reports/constants'; +import createStore from '~/ci/reports/codequality_report/store'; +import * as getters from '~/ci/reports/codequality_report/store/getters'; +import { LOADING, ERROR, SUCCESS, STATUS_NOT_FOUND } from '~/ci/reports/constants'; describe('Codequality reports store getters', () => { let localState; diff --git a/spec/frontend/reports/codequality_report/store/mutations_spec.js b/spec/frontend/ci/reports/codequality_report/store/mutations_spec.js index 6e14cd7438b..22ff86b1040 100644 --- a/spec/frontend/reports/codequality_report/store/mutations_spec.js +++ b/spec/frontend/ci/reports/codequality_report/store/mutations_spec.js @@ -1,6 +1,6 @@ -import createStore from '~/reports/codequality_report/store'; -import mutations from '~/reports/codequality_report/store/mutations'; -import { STATUS_NOT_FOUND } from '~/reports/constants'; +import createStore from '~/ci/reports/codequality_report/store'; +import mutations from '~/ci/reports/codequality_report/store/mutations'; +import { STATUS_NOT_FOUND } from '~/ci/reports/constants'; describe('Codequality Reports mutations', () => { let localState; diff --git a/spec/frontend/reports/codequality_report/store/utils/codequality_parser_spec.js b/spec/frontend/ci/reports/codequality_report/store/utils/codequality_parser_spec.js index 5b77a2c74be..f7d82d2b662 100644 --- a/spec/frontend/reports/codequality_report/store/utils/codequality_parser_spec.js +++ b/spec/frontend/ci/reports/codequality_report/store/utils/codequality_parser_spec.js @@ -1,5 +1,5 @@ -import { reportIssues, parsedReportIssues } from 'jest/reports/codequality_report/mock_data'; -import { parseCodeclimateMetrics } from '~/reports/codequality_report/store/utils/codequality_parser'; +import { reportIssues, parsedReportIssues } from 'jest/ci/reports/codequality_report/mock_data'; +import { parseCodeclimateMetrics } from '~/ci/reports/codequality_report/store/utils/codequality_parser'; describe('Codequality report store utils', () => { let result; diff --git a/spec/frontend/reports/components/__snapshots__/grouped_issues_list_spec.js.snap b/spec/frontend/ci/reports/components/__snapshots__/grouped_issues_list_spec.js.snap index 311a67a3e31..311a67a3e31 100644 --- a/spec/frontend/reports/components/__snapshots__/grouped_issues_list_spec.js.snap +++ b/spec/frontend/ci/reports/components/__snapshots__/grouped_issues_list_spec.js.snap diff --git a/spec/frontend/reports/components/__snapshots__/issue_status_icon_spec.js.snap b/spec/frontend/ci/reports/components/__snapshots__/issue_status_icon_spec.js.snap index b5a4cb42463..b5a4cb42463 100644 --- a/spec/frontend/reports/components/__snapshots__/issue_status_icon_spec.js.snap +++ b/spec/frontend/ci/reports/components/__snapshots__/issue_status_icon_spec.js.snap diff --git a/spec/frontend/reports/components/grouped_issues_list_spec.js b/spec/frontend/ci/reports/components/grouped_issues_list_spec.js index cacbde590d6..3e4adfc7794 100644 --- a/spec/frontend/reports/components/grouped_issues_list_spec.js +++ b/spec/frontend/ci/reports/components/grouped_issues_list_spec.js @@ -1,6 +1,6 @@ import { shallowMount } from '@vue/test-utils'; -import GroupedIssuesList from '~/reports/components/grouped_issues_list.vue'; -import ReportItem from '~/reports/components/report_item.vue'; +import GroupedIssuesList from '~/ci/reports/components/grouped_issues_list.vue'; +import ReportItem from '~/ci/reports/components/report_item.vue'; import SmartVirtualList from '~/vue_shared/components/smart_virtual_list.vue'; describe('Grouped Issues List', () => { diff --git a/spec/frontend/reports/components/issue_status_icon_spec.js b/spec/frontend/ci/reports/components/issue_status_icon_spec.js index 8706f2f8d83..fb13d4407e2 100644 --- a/spec/frontend/reports/components/issue_status_icon_spec.js +++ b/spec/frontend/ci/reports/components/issue_status_icon_spec.js @@ -1,6 +1,6 @@ import { shallowMount } from '@vue/test-utils'; -import ReportItem from '~/reports/components/issue_status_icon.vue'; -import { STATUS_FAILED, STATUS_NEUTRAL, STATUS_SUCCESS } from '~/reports/constants'; +import ReportItem from '~/ci/reports/components/issue_status_icon.vue'; +import { STATUS_FAILED, STATUS_NEUTRAL, STATUS_SUCCESS } from '~/ci/reports/constants'; describe('IssueStatusIcon', () => { let wrapper; diff --git a/spec/frontend/reports/components/report_item_spec.js b/spec/frontend/ci/reports/components/report_item_spec.js index 60c7e5f2b44..d835d549531 100644 --- a/spec/frontend/reports/components/report_item_spec.js +++ b/spec/frontend/ci/reports/components/report_item_spec.js @@ -1,8 +1,8 @@ import { shallowMount } from '@vue/test-utils'; -import { componentNames } from '~/reports/components/issue_body'; -import IssueStatusIcon from '~/reports/components/issue_status_icon.vue'; -import ReportItem from '~/reports/components/report_item.vue'; -import { STATUS_SUCCESS } from '~/reports/constants'; +import { componentNames } from '~/ci/reports/components/issue_body'; +import IssueStatusIcon from '~/ci/reports/components/issue_status_icon.vue'; +import ReportItem from '~/ci/reports/components/report_item.vue'; +import { STATUS_SUCCESS } from '~/ci/reports/constants'; describe('ReportItem', () => { describe('showReportSectionStatusIcon', () => { diff --git a/spec/frontend/reports/components/report_link_spec.js b/spec/frontend/ci/reports/components/report_link_spec.js index 2ed0617a598..ba541ba0303 100644 --- a/spec/frontend/reports/components/report_link_spec.js +++ b/spec/frontend/ci/reports/components/report_link_spec.js @@ -1,7 +1,7 @@ import { shallowMount } from '@vue/test-utils'; -import ReportLink from '~/reports/components/report_link.vue'; +import ReportLink from '~/ci/reports/components/report_link.vue'; -describe('app/assets/javascripts/reports/components/report_link.vue', () => { +describe('app/assets/javascripts/ci/reports/components/report_link.vue', () => { let wrapper; afterEach(() => { diff --git a/spec/frontend/reports/components/report_section_spec.js b/spec/frontend/ci/reports/components/report_section_spec.js index cc35b99a199..f032b210184 100644 --- a/spec/frontend/reports/components/report_section_spec.js +++ b/spec/frontend/ci/reports/components/report_section_spec.js @@ -1,8 +1,8 @@ import { GlButton } from '@gitlab/ui'; import { mountExtended } from 'helpers/vue_test_utils_helper'; import HelpPopover from '~/vue_shared/components/help_popover.vue'; -import ReportItem from '~/reports/components/report_item.vue'; -import ReportSection from '~/reports/components/report_section.vue'; +import ReportItem from '~/ci/reports/components/report_item.vue'; +import ReportSection from '~/ci/reports/components/report_section.vue'; describe('ReportSection component', () => { let wrapper; diff --git a/spec/frontend/reports/components/summary_row_spec.js b/spec/frontend/ci/reports/components/summary_row_spec.js index 778660d9e44..fb2ae5371d5 100644 --- a/spec/frontend/reports/components/summary_row_spec.js +++ b/spec/frontend/ci/reports/components/summary_row_spec.js @@ -1,7 +1,7 @@ import { mount } from '@vue/test-utils'; import { extendedWrapper } from 'helpers/vue_test_utils_helper'; import HelpPopover from '~/vue_shared/components/help_popover.vue'; -import SummaryRow from '~/reports/components/summary_row.vue'; +import SummaryRow from '~/ci/reports/components/summary_row.vue'; describe('Summary row', () => { let wrapper; diff --git a/spec/frontend/reports/mock_data/mock_data.js b/spec/frontend/ci/reports/mock_data/mock_data.js index 2599b0ac365..2599b0ac365 100644 --- a/spec/frontend/reports/mock_data/mock_data.js +++ b/spec/frontend/ci/reports/mock_data/mock_data.js diff --git a/spec/frontend/reports/mock_data/new_and_fixed_failures_report.json b/spec/frontend/ci/reports/mock_data/new_and_fixed_failures_report.json index 6141e5433a6..9018ad5e4cf 100644 --- a/spec/frontend/reports/mock_data/new_and_fixed_failures_report.json +++ b/spec/frontend/ci/reports/mock_data/new_and_fixed_failures_report.json @@ -1,11 +1,21 @@ { "status": "failed", - "summary": { "total": 11, "resolved": 2, "errored": 0, "failed": 2 }, + "summary": { + "total": 11, + "resolved": 2, + "errored": 0, + "failed": 2 + }, "suites": [ { "name": "rspec:pg", "status": "failed", - "summary": { "total": 8, "resolved": 2, "errored": 0, "failed": 1 }, + "summary": { + "total": 8, + "resolved": 2, + "errored": 0, + "failed": 1 + }, "new_failures": [ { "status": "failed", @@ -36,7 +46,12 @@ { "name": "java ant", "status": "failed", - "summary": { "total": 3, "resolved": 0, "errored": 0, "failed": 1 }, + "summary": { + "total": 3, + "resolved": 0, + "errored": 0, + "failed": 1 + }, "new_failures": [], "resolved_failures": [], "existing_failures": [ @@ -52,4 +67,4 @@ "existing_errors": [] } ] -} +}
\ No newline at end of file diff --git a/spec/frontend/reports/mock_data/new_errors_report.json b/spec/frontend/ci/reports/mock_data/new_errors_report.json index 6573d23ee50..d3fb570c327 100644 --- a/spec/frontend/reports/mock_data/new_errors_report.json +++ b/spec/frontend/ci/reports/mock_data/new_errors_report.json @@ -1,9 +1,19 @@ { - "summary": { "total": 11, "resolved": 0, "errored": 2, "failed": 0 }, + "summary": { + "total": 11, + "resolved": 0, + "errored": 2, + "failed": 0 + }, "suites": [ { "name": "karma", - "summary": { "total": 3, "resolved": 0, "errored": 2, "failed": 0 }, + "summary": { + "total": 3, + "resolved": 0, + "errored": 2, + "failed": 0 + }, "new_failures": [], "resolved_failures": [], "existing_failures": [], @@ -26,7 +36,12 @@ }, { "name": "rspec:pg", - "summary": { "total": 8, "resolved": 0, "errored": 0, "failed": 0 }, + "summary": { + "total": 8, + "resolved": 0, + "errored": 0, + "failed": 0 + }, "new_failures": [], "resolved_failures": [], "existing_failures": [], @@ -35,4 +50,4 @@ "existing_errors": [] } ] -} +}
\ No newline at end of file diff --git a/spec/frontend/reports/mock_data/new_failures_report.json b/spec/frontend/ci/reports/mock_data/new_failures_report.json index 438f7c82788..03a875b7636 100644 --- a/spec/frontend/reports/mock_data/new_failures_report.json +++ b/spec/frontend/ci/reports/mock_data/new_failures_report.json @@ -1,9 +1,19 @@ { - "summary": { "total": 11, "resolved": 0, "errored": 0, "failed": 2 }, + "summary": { + "total": 11, + "resolved": 0, + "errored": 0, + "failed": 2 + }, "suites": [ { "name": "rspec:pg", - "summary": { "total": 8, "resolved": 0, "errored": 0, "failed": 2 }, + "summary": { + "total": 8, + "resolved": 0, + "errored": 0, + "failed": 2 + }, "new_failures": [ { "result": "failure", @@ -28,7 +38,12 @@ }, { "name": "java ant", - "summary": { "total": 3, "resolved": 0, "errored": 0, "failed": 0 }, + "summary": { + "total": 3, + "resolved": 0, + "errored": 0, + "failed": 0 + }, "new_failures": [], "resolved_failures": [], "existing_failures": [], @@ -37,4 +52,4 @@ "existing_errors": [] } ] -} +}
\ No newline at end of file diff --git a/spec/frontend/reports/mock_data/new_failures_with_null_files_report.json b/spec/frontend/ci/reports/mock_data/new_failures_with_null_files_report.json index 28ee7d194b9..00a35a3d0a7 100644 --- a/spec/frontend/reports/mock_data/new_failures_with_null_files_report.json +++ b/spec/frontend/ci/reports/mock_data/new_failures_with_null_files_report.json @@ -1,9 +1,19 @@ { - "summary": { "total": 11, "resolved": 0, "errored": 0, "failed": 2 }, + "summary": { + "total": 11, + "resolved": 0, + "errored": 0, + "failed": 2 + }, "suites": [ { "name": "rspec:pg", - "summary": { "total": 8, "resolved": 0, "errored": 0, "failed": 2 }, + "summary": { + "total": 8, + "resolved": 0, + "errored": 0, + "failed": 2 + }, "new_failures": [ { "result": "failure", @@ -28,7 +38,12 @@ }, { "name": "java ant", - "summary": { "total": 3, "resolved": 0, "errored": 0, "failed": 0 }, + "summary": { + "total": 3, + "resolved": 0, + "errored": 0, + "failed": 0 + }, "new_failures": [], "resolved_failures": [], "existing_failures": [], @@ -37,4 +52,4 @@ "existing_errors": [] } ] -} +}
\ No newline at end of file diff --git a/spec/frontend/reports/mock_data/no_failures_report.json b/spec/frontend/ci/reports/mock_data/no_failures_report.json index 7da9e0c6211..a48a206208d 100644 --- a/spec/frontend/reports/mock_data/no_failures_report.json +++ b/spec/frontend/ci/reports/mock_data/no_failures_report.json @@ -1,11 +1,21 @@ { "status": "success", - "summary": { "total": 11, "resolved": 0, "errored": 0, "failed": 0 }, + "summary": { + "total": 11, + "resolved": 0, + "errored": 0, + "failed": 0 + }, "suites": [ { "name": "rspec:pg", "status": "success", - "summary": { "total": 8, "resolved": 0, "errored": 0, "failed": 0 }, + "summary": { + "total": 8, + "resolved": 0, + "errored": 0, + "failed": 0 + }, "new_failures": [], "resolved_failures": [], "existing_failures": [], @@ -16,7 +26,12 @@ { "name": "java ant", "status": "success", - "summary": { "total": 3, "resolved": 0, "errored": 0, "failed": 0 }, + "summary": { + "total": 3, + "resolved": 0, + "errored": 0, + "failed": 0 + }, "new_failures": [], "resolved_failures": [], "existing_failures": [], @@ -25,4 +40,4 @@ "existing_errors": [] } ] -} +}
\ No newline at end of file diff --git a/spec/frontend/reports/mock_data/recent_failures_report.json b/spec/frontend/ci/reports/mock_data/recent_failures_report.json index c4a5fb78dcd..f4fc2d2e927 100644 --- a/spec/frontend/reports/mock_data/recent_failures_report.json +++ b/spec/frontend/ci/reports/mock_data/recent_failures_report.json @@ -1,9 +1,21 @@ { - "summary": { "total": 11, "resolved": 0, "errored": 0, "failed": 3, "recentlyFailed": 2 }, + "summary": { + "total": 11, + "resolved": 0, + "errored": 0, + "failed": 3, + "recentlyFailed": 2 + }, "suites": [ { "name": "rspec:pg", - "summary": { "total": 8, "resolved": 0, "errored": 0, "failed": 2, "recentlyFailed": 1 }, + "summary": { + "total": 8, + "resolved": 0, + "errored": 0, + "failed": 2, + "recentlyFailed": 1 + }, "new_failures": [ { "result": "failure", @@ -30,7 +42,13 @@ }, { "name": "java ant", - "summary": { "total": 3, "resolved": 0, "errored": 0, "failed": 1, "recentlyFailed": 1 }, + "summary": { + "total": 3, + "resolved": 0, + "errored": 0, + "failed": 1, + "recentlyFailed": 1 + }, "new_failures": [ { "result": "failure", @@ -49,4 +67,4 @@ "existing_errors": [] } ] -} +}
\ No newline at end of file diff --git a/spec/frontend/reports/mock_data/resolved_failures.json b/spec/frontend/ci/reports/mock_data/resolved_failures.json index 49de6aa840b..15012fb027d 100644 --- a/spec/frontend/reports/mock_data/resolved_failures.json +++ b/spec/frontend/ci/reports/mock_data/resolved_failures.json @@ -1,11 +1,21 @@ { "status": "success", - "summary": { "total": 11, "resolved": 4, "errored": 0, "failed": 0 }, + "summary": { + "total": 11, + "resolved": 4, + "errored": 0, + "failed": 0 + }, "suites": [ { "name": "rspec:pg", "status": "success", - "summary": { "total": 8, "resolved": 4, "errored": 0, "failed": 0 }, + "summary": { + "total": 8, + "resolved": 4, + "errored": 0, + "failed": 0 + }, "new_failures": [], "resolved_failures": [ { @@ -18,7 +28,7 @@ { "status": "success", "name": "Test#sum when a is 100 and b is 200 returns summary", - "execution_time": 7.6e-5, + "execution_time": 0.000076, "system_output": null, "stack_trace": null } @@ -46,7 +56,12 @@ { "name": "java ant", "status": "success", - "summary": { "total": 3, "resolved": 0, "errored": 0, "failed": 0 }, + "summary": { + "total": 3, + "resolved": 0, + "errored": 0, + "failed": 0 + }, "new_failures": [], "resolved_failures": [], "existing_failures": [], @@ -55,4 +70,4 @@ "existing_errors": [] } ] -} +}
\ No newline at end of file diff --git a/spec/frontend/diffs/components/diff_code_quality_spec.js b/spec/frontend/diffs/components/diff_code_quality_spec.js index 6232bbee8af..5fc5a57ee5b 100644 --- a/spec/frontend/diffs/components/diff_code_quality_spec.js +++ b/spec/frontend/diffs/components/diff_code_quality_spec.js @@ -1,7 +1,7 @@ import { GlIcon } from '@gitlab/ui'; import { mountExtended, shallowMountExtended } from 'helpers/vue_test_utils_helper'; import DiffCodeQuality from '~/diffs/components/diff_code_quality.vue'; -import { SEVERITY_CLASSES, SEVERITY_ICONS } from '~/reports/codequality_report/constants'; +import { SEVERITY_CLASSES, SEVERITY_ICONS } from '~/ci/reports/codequality_report/constants'; import { multipleFindingsArr } from '../mock_data/diff_code_quality'; let wrapper; diff --git a/spec/frontend/vue_merge_request_widget/extensions/test_report/index_spec.js b/spec/frontend/vue_merge_request_widget/extensions/test_report/index_spec.js index 05df66165dd..8f07adda805 100644 --- a/spec/frontend/vue_merge_request_widget/extensions/test_report/index_spec.js +++ b/spec/frontend/vue_merge_request_widget/extensions/test_report/index_spec.js @@ -11,14 +11,14 @@ import { registerExtension } from '~/vue_merge_request_widget/components/extensi import httpStatusCodes from '~/lib/utils/http_status'; import TestCaseDetails from '~/pipelines/components/test_reports/test_case_details.vue'; -import { failedReport } from 'jest/reports/mock_data/mock_data'; -import mixedResultsTestReports from 'jest/reports/mock_data/new_and_fixed_failures_report.json'; -import newErrorsTestReports from 'jest/reports/mock_data/new_errors_report.json'; -import newFailedTestReports from 'jest/reports/mock_data/new_failures_report.json'; -import newFailedTestWithNullFilesReport from 'jest/reports/mock_data/new_failures_with_null_files_report.json'; -import successTestReports from 'jest/reports/mock_data/no_failures_report.json'; -import resolvedFailures from 'jest/reports/mock_data/resolved_failures.json'; -import recentFailures from 'jest/reports/mock_data/recent_failures_report.json'; +import { failedReport } from 'jest/ci/reports/mock_data/mock_data'; +import mixedResultsTestReports from 'jest/ci/reports/mock_data/new_and_fixed_failures_report.json'; +import newErrorsTestReports from 'jest/ci/reports/mock_data/new_errors_report.json'; +import newFailedTestReports from 'jest/ci/reports/mock_data/new_failures_report.json'; +import newFailedTestWithNullFilesReport from 'jest/ci/reports/mock_data/new_failures_with_null_files_report.json'; +import successTestReports from 'jest/ci/reports/mock_data/no_failures_report.json'; +import resolvedFailures from 'jest/ci/reports/mock_data/resolved_failures.json'; +import recentFailures from 'jest/ci/reports/mock_data/recent_failures_report.json'; const reportWithParsingErrors = failedReport; reportWithParsingErrors.suites[0].suite_errors = { diff --git a/spec/lib/gitlab/audit/type/definition_spec.rb b/spec/lib/gitlab/audit/type/definition_spec.rb index b106f158924..bd3b90f12f0 100644 --- a/spec/lib/gitlab/audit/type/definition_spec.rb +++ b/spec/lib/gitlab/audit/type/definition_spec.rb @@ -204,6 +204,12 @@ RSpec.describe Gitlab::Audit::Type::Definition do end end + describe 'validate that all the YAML definitions matches the audit event type schema' do + it 'successfully loads all the YAML definitions' do + expect { described_class.definitions }.not_to raise_error + end + end + describe '.definitions' do let(:store1) { Dir.mktmpdir('path1') } diff --git a/spec/support/import_export/export_file_helper.rb b/spec/support/import_export/export_file_helper.rb index 3134e5c32a3..9a26f50903f 100644 --- a/spec/support/import_export/export_file_helper.rb +++ b/spec/support/import_export/export_file_helper.rb @@ -117,8 +117,8 @@ module ExportFileHelper # Check whether this is a hash attribute inside a model if model.is_a?(Symbol) return true if (safe_hashes[model] - parent.keys).empty? - else - return true if safe_model?(model, excluded_attributes, parent) + elsif safe_model?(model, excluded_attributes, parent) + return true end end diff --git a/spec/support/shared_examples/finders/snippet_visibility_shared_examples.rb b/spec/support/shared_examples/finders/snippet_visibility_shared_examples.rb index 601a53ed913..f00d6e776ec 100644 --- a/spec/support/shared_examples/finders/snippet_visibility_shared_examples.rb +++ b/spec/support/shared_examples/finders/snippet_visibility_shared_examples.rb @@ -237,8 +237,8 @@ RSpec.shared_examples 'snippet visibility' do if project.private? project.add_developer(external) unless member - else - member.delete if member + elsif member + member.delete end end end diff --git a/spec/support/shared_examples/metrics/active_record_subscriber_shared_examples.rb b/spec/support/shared_examples/metrics/active_record_subscriber_shared_examples.rb index ef4b08c7865..c07d1552ba2 100644 --- a/spec/support/shared_examples/metrics/active_record_subscriber_shared_examples.rb +++ b/spec/support/shared_examples/metrics/active_record_subscriber_shared_examples.rb @@ -129,8 +129,8 @@ RSpec.shared_examples 'record ActiveRecord metrics in a metrics transaction' do expect(transaction).to receive(:increment).with("gitlab_transaction_db_#{db_role}_wal_count_total".to_sym, 1, { db_config_name: db_config_name }) expect(transaction).to receive(:increment).with("gitlab_transaction_db_#{db_role}_wal_cached_count_total".to_sym, 1, { db_config_name: db_config_name }) if record_cached_query end - else - expect(transaction).not_to receive(:increment).with("gitlab_transaction_db_#{db_role}_wal_count_total".to_sym, 1, { db_config_name: db_config_name }) if db_role + elsif db_role + expect(transaction).not_to receive(:increment).with("gitlab_transaction_db_#{db_role}_wal_count_total".to_sym, 1, { db_config_name: db_config_name }) end subscriber.sql(event) |