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
path: root/spec
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-01-27 12:08:32 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-01-27 12:08:32 +0300
commitc8e28a0bb8dd45d91cb72ff2c930bc4a562f1fc7 (patch)
treea6b5d07b456c9494eb68ed210af74b58dc699a26 /spec
parenteace733dca6e5c87315b42f42eb4d8f05934d6de (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec')
-rw-r--r--spec/models/hooks/web_hook_log_spec.rb16
-rw-r--r--spec/requests/api/project_import_spec.rb13
2 files changed, 29 insertions, 0 deletions
diff --git a/spec/models/hooks/web_hook_log_spec.rb b/spec/models/hooks/web_hook_log_spec.rb
index 3520720d9a4..128601794cf 100644
--- a/spec/models/hooks/web_hook_log_spec.rb
+++ b/spec/models/hooks/web_hook_log_spec.rb
@@ -69,4 +69,20 @@ describe WebHookLog do
it { expect(web_hook_log.success?).to be_falsey }
end
end
+
+ describe '#internal_error?' do
+ let(:web_hook_log) { build_stubbed(:web_hook_log, response_status: status) }
+
+ context 'when response status is not an internal error' do
+ let(:status) { '200' }
+
+ it { expect(web_hook_log.internal_error?).to be_falsey }
+ end
+
+ context 'when response status is an internal error' do
+ let(:status) { 'internal error' }
+
+ it { expect(web_hook_log.internal_error?).to be_truthy }
+ end
+ end
end
diff --git a/spec/requests/api/project_import_spec.rb b/spec/requests/api/project_import_spec.rb
index 186f0f52a46..71dd8fee0ae 100644
--- a/spec/requests/api/project_import_spec.rb
+++ b/spec/requests/api/project_import_spec.rb
@@ -196,6 +196,19 @@ describe API::ProjectImport do
end
end
+ context 'when request exceeds the rate limit' do
+ before do
+ allow(::Gitlab::ApplicationRateLimiter).to receive(:throttled?).and_return(true)
+ end
+
+ it 'prevents users from importing projects' do
+ post api('/projects/import', user), params: { path: 'test-import', file: fixture_file_upload(file), namespace: namespace.id }
+
+ expect(response).to have_gitlab_http_status(429)
+ expect(json_response['message']['error']).to eq('This endpoint has been requested too many times. Try again later.')
+ end
+ end
+
def stub_import(namespace)
expect_any_instance_of(ProjectImportState).to receive(:schedule)
expect(::Projects::CreateService).to receive(:new).with(user, hash_including(namespace_id: namespace.id)).and_call_original