diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-02-07 03:10:31 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-02-07 03:10:31 +0300 |
commit | 11438b1771abda3c216ca627bf5319684474889b (patch) | |
tree | a109ca98c2c8836152358b8699324e4261ecf6b2 /spec | |
parent | 09fd08f7e5db4514ce82223ab9a28ed8f823fb17 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec')
-rw-r--r-- | spec/controllers/admin/users_controller_spec.rb | 35 | ||||
-rw-r--r-- | spec/graphql/types/issue_type_spec.rb | 26 | ||||
-rw-r--r-- | spec/helpers/admin/user_actions_helper_spec.rb | 18 | ||||
-rw-r--r-- | spec/helpers/issues_helper_spec.rb | 16 | ||||
-rw-r--r-- | spec/models/issue_spec.rb | 10 | ||||
-rw-r--r-- | spec/support/helpers/trial_status_widget_test_helper.rb | 9 | ||||
-rw-r--r-- | spec/support/shared_examples/finders/issues_finder_shared_examples.rb | 96 | ||||
-rw-r--r-- | spec/support/shared_examples/integrations/integration_settings_form.rb | 14 |
8 files changed, 27 insertions, 197 deletions
diff --git a/spec/controllers/admin/users_controller_spec.rb b/spec/controllers/admin/users_controller_spec.rb index eecb803fb1a..63e68118066 100644 --- a/spec/controllers/admin/users_controller_spec.rb +++ b/spec/controllers/admin/users_controller_spec.rb @@ -481,37 +481,22 @@ RSpec.describe Admin::UsersController do end describe 'PUT ban/:id', :aggregate_failures do - context 'when ban_user_feature_flag is enabled' do - it 'bans user' do - put :ban, params: { id: user.username } - - expect(user.reload.banned?).to be_truthy - expect(flash[:notice]).to eq _('Successfully banned') - end - - context 'when unsuccessful' do - let(:user) { create(:user, :blocked) } + it 'bans user' do + put :ban, params: { id: user.username } - it 'does not ban user' do - put :ban, params: { id: user.username } - - user.reload - expect(user.banned?).to be_falsey - expect(flash[:alert]).to eq _('Error occurred. User was not banned') - end - end + expect(user.reload.banned?).to be_truthy + expect(flash[:notice]).to eq _('Successfully banned') end - context 'when ban_user_feature_flag is not enabled' do - before do - stub_feature_flags(ban_user_feature_flag: false) - end + context 'when unsuccessful' do + let(:user) { create(:user, :blocked) } - it 'does not ban user, renders 404' do + it 'does not ban user' do put :ban, params: { id: user.username } - expect(user.reload.banned?).to be_falsey - expect(response).to have_gitlab_http_status(:not_found) + user.reload + expect(user.banned?).to be_falsey + expect(flash[:alert]).to eq _('Error occurred. User was not banned') end end end diff --git a/spec/graphql/types/issue_type_spec.rb b/spec/graphql/types/issue_type_spec.rb index 498625dc642..7c6cf137a1e 100644 --- a/spec/graphql/types/issue_type_spec.rb +++ b/spec/graphql/types/issue_type_spec.rb @@ -228,29 +228,17 @@ RSpec.describe GitlabSchema.types['Issue'] do subject { GitlabSchema.execute(query, context: { current_user: admin }).as_json } - context 'when `ban_user_feature_flag` is enabled' do - context 'when issue is hidden' do - it 'returns `true`' do - expect(subject.dig('data', 'project', 'issue', 'hidden')).to eq(true) - end - end - - context 'when issue is visible' do - let(:issue) { visible_issue } - - it 'returns `false`' do - expect(subject.dig('data', 'project', 'issue', 'hidden')).to eq(false) - end + context 'when issue is hidden' do + it 'returns `true`' do + expect(subject.dig('data', 'project', 'issue', 'hidden')).to eq(true) end end - context 'when `ban_user_feature_flag` is disabled' do - before do - stub_feature_flags(ban_user_feature_flag: false) - end + context 'when issue is visible' do + let(:issue) { visible_issue } - it 'returns `nil`' do - expect(subject.dig('data', 'project', 'issue', 'hidden')).to be_nil + it 'returns `false`' do + expect(subject.dig('data', 'project', 'issue', 'hidden')).to eq(false) end end end diff --git a/spec/helpers/admin/user_actions_helper_spec.rb b/spec/helpers/admin/user_actions_helper_spec.rb index 3bc380fbc99..87d2308690c 100644 --- a/spec/helpers/admin/user_actions_helper_spec.rb +++ b/spec/helpers/admin/user_actions_helper_spec.rb @@ -114,23 +114,5 @@ RSpec.describe Admin::UserActionsHelper do it { is_expected.to match_array([]) } end - - context 'when `ban_user_feature_flag` is disabled' do - before do - stub_feature_flags(ban_user_feature_flag: false) - end - - context 'the user is a standard user' do - let_it_be(:user) { create(:user) } - - it { is_expected.not_to include("ban") } - end - - context 'the user is banned' do - let_it_be(:user) { create(:user, :banned) } - - it { is_expected.not_to include("unban") } - end - end end end diff --git a/spec/helpers/issues_helper_spec.rb b/spec/helpers/issues_helper_spec.rb index 1b642adb902..994a1ff4f75 100644 --- a/spec/helpers/issues_helper_spec.rb +++ b/spec/helpers/issues_helper_spec.rb @@ -478,20 +478,8 @@ RSpec.describe IssuesHelper do let_it_be(:banned_user) { build(:user, :banned) } let_it_be(:hidden_issue) { build(:issue, author: banned_user) } - context 'when `ban_user_feature_flag` feature flag is enabled' do - it 'returns `true`' do - expect(helper.issue_hidden?(hidden_issue)).to eq(true) - end - end - - context 'when `ban_user_feature_flag` feature flag is disabled' do - before do - stub_feature_flags(ban_user_feature_flag: false) - end - - it 'returns `false`' do - expect(helper.issue_hidden?(hidden_issue)).to eq(false) - end + it 'returns `true`' do + expect(helper.issue_hidden?(hidden_issue)).to eq(true) end end diff --git a/spec/models/issue_spec.rb b/spec/models/issue_spec.rb index fdb397932e0..3a42d5d4c3f 100644 --- a/spec/models/issue_spec.rb +++ b/spec/models/issue_spec.rb @@ -1465,16 +1465,6 @@ RSpec.describe Issue, feature_category: :project_management do it 'only returns without_hidden issues' do expect(described_class.without_hidden).to eq([public_issue]) end - - context 'when feature flag is disabled' do - before do - stub_feature_flags(ban_user_feature_flag: false) - end - - it 'returns public and hidden issues' do - expect(described_class.without_hidden).to contain_exactly(public_issue, hidden_issue) - end - end end describe '.by_project_id_and_iid' do diff --git a/spec/support/helpers/trial_status_widget_test_helper.rb b/spec/support/helpers/trial_status_widget_test_helper.rb deleted file mode 100644 index d75620d17ee..00000000000 --- a/spec/support/helpers/trial_status_widget_test_helper.rb +++ /dev/null @@ -1,9 +0,0 @@ -# frozen_string_literal: true - -module TrialStatusWidgetTestHelper - def purchase_href(group) - new_subscriptions_path(namespace_id: group.id, plan_id: 'ultimate-plan-id') - end -end - -TrialStatusWidgetTestHelper.prepend_mod diff --git a/spec/support/shared_examples/finders/issues_finder_shared_examples.rb b/spec/support/shared_examples/finders/issues_finder_shared_examples.rb index 08841c724b5..93f9e42241b 100644 --- a/spec/support/shared_examples/finders/issues_finder_shared_examples.rb +++ b/spec/support/shared_examples/finders/issues_finder_shared_examples.rb @@ -1256,28 +1256,12 @@ RSpec.shared_examples 'issues or work items finder' do |factory, execute_context subject { described_class.new(nil, params).with_confidentiality_access_check } it_behaves_like 'returns public, does not return hidden or confidential' - - context 'when feature flag is disabled' do - before do - stub_feature_flags(ban_user_feature_flag: false) - end - - it_behaves_like 'returns public and hidden, does not return confidential' - end end context 'for a user without project membership' do subject { described_class.new(user, params).with_confidentiality_access_check } it_behaves_like 'returns public, does not return hidden or confidential' - - context 'when feature flag is disabled' do - before do - stub_feature_flags(ban_user_feature_flag: false) - end - - it_behaves_like 'returns public and hidden, does not return confidential' - end end context 'for a guest user' do @@ -1288,28 +1272,12 @@ RSpec.shared_examples 'issues or work items finder' do |factory, execute_context end it_behaves_like 'returns public, does not return hidden or confidential' - - context 'when feature flag is disabled' do - before do - stub_feature_flags(ban_user_feature_flag: false) - end - - it_behaves_like 'returns public and hidden, does not return confidential' - end end context 'for a project member with access to view confidential items' do subject { described_class.new(authorized_user, params).with_confidentiality_access_check } it_behaves_like 'returns public and confidential, does not return hidden' - - context 'when feature flag is disabled' do - before do - stub_feature_flags(ban_user_feature_flag: false) - end - - it_behaves_like 'returns public, confidential, and hidden' - end end context 'for an admin' do @@ -1319,26 +1287,10 @@ RSpec.shared_examples 'issues or work items finder' do |factory, execute_context context 'when admin mode is enabled', :enable_admin_mode do it_behaves_like 'returns public, confidential, and hidden' - - context 'when feature flag is disabled' do - before do - stub_feature_flags(ban_user_feature_flag: false) - end - - it_behaves_like 'returns public, confidential, and hidden' - end end context 'when admin mode is disabled' do it_behaves_like 'returns public, does not return hidden or confidential' - - context 'when feature flag is disabled' do - before do - stub_feature_flags(ban_user_feature_flag: false) - end - - it_behaves_like 'returns public and hidden, does not return confidential' - end end end end @@ -1351,14 +1303,6 @@ RSpec.shared_examples 'issues or work items finder' do |factory, execute_context it_behaves_like 'returns public, does not return hidden or confidential' - context 'when feature flag is disabled' do - before do - stub_feature_flags(ban_user_feature_flag: false) - end - - it_behaves_like 'returns public and hidden, does not return confidential' - end - it 'does not filter by confidentiality' do expect(items_model).not_to receive(:where).with(a_string_matching('confidential'), anything) subject @@ -1370,14 +1314,6 @@ RSpec.shared_examples 'issues or work items finder' do |factory, execute_context it_behaves_like 'returns public, does not return hidden or confidential' - context 'when feature flag is disabled' do - before do - stub_feature_flags(ban_user_feature_flag: false) - end - - it_behaves_like 'returns public and hidden, does not return confidential' - end - it 'filters by confidentiality' do expect(subject.to_sql).to match("issues.confidential") end @@ -1392,14 +1328,6 @@ RSpec.shared_examples 'issues or work items finder' do |factory, execute_context it_behaves_like 'returns public, does not return hidden or confidential' - context 'when feature flag is disabled' do - before do - stub_feature_flags(ban_user_feature_flag: false) - end - - it_behaves_like 'returns public and hidden, does not return confidential' - end - it 'filters by confidentiality' do expect(subject.to_sql).to match("issues.confidential") end @@ -1410,14 +1338,6 @@ RSpec.shared_examples 'issues or work items finder' do |factory, execute_context it_behaves_like 'returns public and confidential, does not return hidden' - context 'when feature flag is disabled' do - before do - stub_feature_flags(ban_user_feature_flag: false) - end - - it_behaves_like 'returns public, confidential, and hidden' - end - it 'does not filter by confidentiality' do expect(items_model).not_to receive(:where).with(a_string_matching('confidential'), anything) @@ -1433,14 +1353,6 @@ RSpec.shared_examples 'issues or work items finder' do |factory, execute_context context 'when admin mode is enabled', :enable_admin_mode do it_behaves_like 'returns public, confidential, and hidden' - context 'when feature flag is disabled' do - before do - stub_feature_flags(ban_user_feature_flag: false) - end - - it_behaves_like 'returns public, confidential, and hidden' - end - it 'does not filter by confidentiality' do expect(items_model).not_to receive(:where).with(a_string_matching('confidential'), anything) @@ -1451,14 +1363,6 @@ RSpec.shared_examples 'issues or work items finder' do |factory, execute_context context 'when admin mode is disabled' do it_behaves_like 'returns public, does not return hidden or confidential' - context 'when feature flag is disabled' do - before do - stub_feature_flags(ban_user_feature_flag: false) - end - - it_behaves_like 'returns public and hidden, does not return confidential' - end - it 'filters by confidentiality' do expect(subject.to_sql).to match("issues.confidential") end diff --git a/spec/support/shared_examples/integrations/integration_settings_form.rb b/spec/support/shared_examples/integrations/integration_settings_form.rb index 1074bcc420c..aeb4e0feb12 100644 --- a/spec/support/shared_examples/integrations/integration_settings_form.rb +++ b/spec/support/shared_examples/integrations/integration_settings_form.rb @@ -54,12 +54,14 @@ RSpec.shared_examples 'integration settings form' do # Should match `integrationTriggerEventTitles` in app/assets/javascripts/integrations/constants.js event_titles = { push_events: s_('IntegrationEvents|A push is made to the repository'), - issues_events: s_('IntegrationEvents|IntegrationEvents|An issue is created, updated, or closed'), - confidential_issues_events: s_('IntegrationEvents|A confidential issue is created, updated, or closed'), - merge_requests_events: s_('IntegrationEvents|A merge request is created, updated, or merged'), - note_events: s_('IntegrationEvents|A comment is added on an issue'), - confidential_note_events: s_('IntegrationEvents|A comment is added on a confidential issue'), - tag_push_events: s_('IntegrationEvents|A tag is pushed to the repository'), + issues_events: s_('IntegrationEvents|An issue is created, closed, or reopened'), + confidential_issues_events: s_('A confidential issue is created, closed, or reopened'), + merge_requests_events: s_('IntegrationEvents|A merge request is created, merged, closed, or reopened'), + note_events: s_('IntegrationEvents|A comment is added'), + confidential_note_events: s_( + 'IntegrationEvents|An internal note or comment on a confidential issue is added' + ), + tag_push_events: s_('IntegrationEvents|A tag is pushed to the repository or removed'), pipeline_events: s_('IntegrationEvents|A pipeline status changes'), wiki_page_events: s_('IntegrationEvents|A wiki page is created or updated') }.with_indifferent_access |