Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'spec/services/admin')
-rw-r--r--spec/services/admin/abuse_reports/moderate_user_service_spec.rb (renamed from spec/services/admin/abuse_report_update_service_spec.rb)2
-rw-r--r--spec/services/admin/plan_limits/update_service_spec.rb127
2 files changed, 119 insertions, 10 deletions
diff --git a/spec/services/admin/abuse_report_update_service_spec.rb b/spec/services/admin/abuse_reports/moderate_user_service_spec.rb
index 7069d8ee5c1..6e8a59f4e49 100644
--- a/spec/services/admin/abuse_report_update_service_spec.rb
+++ b/spec/services/admin/abuse_reports/moderate_user_service_spec.rb
@@ -2,7 +2,7 @@
require 'spec_helper'
-RSpec.describe Admin::AbuseReportUpdateService, feature_category: :instance_resiliency do
+RSpec.describe Admin::AbuseReports::ModerateUserService, feature_category: :instance_resiliency do
let_it_be_with_reload(:abuse_report) { create(:abuse_report) }
let(:action) { 'ban_user' }
let(:close) { true }
diff --git a/spec/services/admin/plan_limits/update_service_spec.rb b/spec/services/admin/plan_limits/update_service_spec.rb
index 718367fadc2..e57c234780c 100644
--- a/spec/services/admin/plan_limits/update_service_spec.rb
+++ b/spec/services/admin/plan_limits/update_service_spec.rb
@@ -16,10 +16,10 @@ RSpec.describe Admin::PlanLimits::UpdateService, feature_category: :shared do
ci_registered_group_runners: 107,
ci_registered_project_runners: 108,
conan_max_file_size: 10,
- enforcement_limit: 15,
+ enforcement_limit: 100,
generic_packages_max_file_size: 20,
helm_max_file_size: 25,
- notification_limit: 30,
+ notification_limit: 95,
maven_max_file_size: 40,
npm_max_file_size: 60,
nuget_max_file_size: 60,
@@ -50,10 +50,10 @@ RSpec.describe Admin::PlanLimits::UpdateService, feature_category: :shared do
expect(limits.limits_history).to eq(
{ "enforcement_limit" =>
[{ "user_id" => user.id, "username" => user.username,
- "timestamp" => current_timestamp, "value" => 15 }],
+ "timestamp" => current_timestamp, "value" => 100 }],
"notification_limit" =>
[{ "user_id" => user.id, "username" => user.username,
- "timestamp" => current_timestamp, "value" => 30 }],
+ "timestamp" => current_timestamp, "value" => 95 }],
"storage_size_limit" =>
[{ "user_id" => user.id, "username" => user.username,
"timestamp" => current_timestamp, "value" => 90 }] }
@@ -68,13 +68,122 @@ RSpec.describe Admin::PlanLimits::UpdateService, feature_category: :shared do
end
context 'when the update is unsuccessful' do
- let(:params) { { notification_limit: 'abc' } }
+ context 'when notification_limit is less than storage_size_limit' do
+ let(:params) { { notification_limit: 2 } }
+
+ before do
+ limits.update!(
+ storage_size_limit: 5,
+ enforcement_limit: 10
+ )
+ end
- it 'returns an error' do
- response = update_plan_limits
+ it 'returns an error' do
+ response = update_plan_limits
+
+ expect(response[:status]).to eq :error
+ expect(response[:message]).to eq ["Notification limit must be greater than or equal to " \
+ "storage_size_limit (Dashboard limit): 5 " \
+ "and less than or equal to enforcement_limit: 10"]
+ end
+ end
+
+ context 'when notification_limit is greater than enforcement_limit' do
+ let(:params) { { notification_limit: 11 } }
+
+ before do
+ limits.update!(
+ storage_size_limit: 5,
+ enforcement_limit: 10
+ )
+ end
+
+ it 'returns an error' do
+ response = update_plan_limits
+
+ expect(response[:status]).to eq :error
+ expect(response[:message]).to eq ["Notification limit must be greater than or equal to " \
+ "storage_size_limit (Dashboard limit): 5 " \
+ "and less than or equal to enforcement_limit: 10"]
+ end
+ end
+
+ context 'when enforcement_limit is less than storage_size_limit' do
+ let(:params) { { enforcement_limit: 9 } }
+
+ before do
+ limits.update!(
+ storage_size_limit: 12,
+ notification_limit: 12
+ )
+ end
+
+ it 'returns an error' do
+ response = update_plan_limits
+
+ expect(response[:status]).to eq :error
+ expect(response[:message]).to eq ["Enforcement limit must be greater than " \
+ "or equal to storage_size_limit (Dashboard limit): " \
+ "12 and greater than or equal to notification_limit: 12"]
+ end
+ end
- expect(response[:status]).to eq :error
- expect(response[:message]).to include 'Notification limit is not a number'
+ context 'when enforcement_limit is less than notification_limit' do
+ let(:params) { { enforcement_limit: 9 } }
+
+ before do
+ limits.update!(
+ storage_size_limit: 10,
+ notification_limit: 10
+ )
+ end
+
+ it 'returns an error' do
+ response = update_plan_limits
+
+ expect(response[:status]).to eq :error
+ expect(response[:message]).to eq ["Enforcement limit must be greater than or equal to " \
+ "storage_size_limit (Dashboard limit): " \
+ "10 and greater than or equal to notification_limit: 10"]
+ end
+ end
+
+ context 'when storage_size_limit is greater than notification_limit' do
+ let(:params) { { storage_size_limit: 11 } }
+
+ before do
+ limits.update!(
+ enforcement_limit: 12,
+ notification_limit: 10
+ )
+ end
+
+ it 'returns an error' do
+ response = update_plan_limits
+
+ expect(response[:status]).to eq :error
+ expect(response[:message]).to eq ["Storage size limit (Dashboard limit) must be less than or " \
+ "equal to enforcement_limit: 12 and notification_limit: 10"]
+ end
+ end
+
+ context 'when storage_size_limit is greater than enforcement_limit' do
+ let(:params) { { storage_size_limit: 11 } }
+
+ before do
+ limits.update!(
+ enforcement_limit: 10,
+ notification_limit: 11
+ )
+ end
+
+ it 'returns an error' do
+ response = update_plan_limits
+
+ expect(response[:status]).to eq :error
+ expect(response[:message]).to eq ["Storage size limit (Dashboard limit) must be less than or " \
+ "equal to enforcement_limit: 10 and notification_limit: 11"]
+ end
end
end
end