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:
authorGitLab Bot <gitlab-bot@gitlab.com>2021-03-25 15:09:19 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2021-03-25 15:09:19 +0300
commita156fc95eb8499fec9cd081d30629f0faf18bfe9 (patch)
treeff59d44794ba9d8084e4d59057ec9507b3ba8e2f /spec/features/file_uploads
parent618be8f52d6349533c709a1d702e45b84338c36a (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/features/file_uploads')
-rw-r--r--spec/features/file_uploads/attachment_spec.rb44
1 files changed, 44 insertions, 0 deletions
diff --git a/spec/features/file_uploads/attachment_spec.rb b/spec/features/file_uploads/attachment_spec.rb
new file mode 100644
index 00000000000..9ad404ce869
--- /dev/null
+++ b/spec/features/file_uploads/attachment_spec.rb
@@ -0,0 +1,44 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+RSpec.describe 'Upload an attachment', :api, :js do
+ include_context 'file upload requests helpers'
+
+ let_it_be(:project) { create(:project) }
+ let_it_be(:user) { project.owner }
+ let_it_be(:personal_access_token) { create(:personal_access_token, user: user) }
+
+ let(:api_path) { "/projects/#{project_id}/uploads" }
+ let(:url) { capybara_url(api(api_path)) }
+ let(:file) { fixture_file_upload('spec/fixtures/dk.png') }
+
+ subject do
+ HTTParty.post(
+ url,
+ headers: { 'PRIVATE-TOKEN' => personal_access_token.token },
+ body: { file: file }
+ )
+ end
+
+ shared_examples 'for an attachment' do
+ it 'creates files' do
+ expect { subject }
+ .to change { Upload.count }.by(1)
+ end
+
+ it { expect(subject.code).to eq(201) }
+ end
+
+ context 'with an integer project ID' do
+ let(:project_id) { project.id }
+
+ it_behaves_like 'handling file uploads', 'for an attachment'
+ end
+
+ context 'with an encoded project ID' do
+ let(:project_id) { "#{project.namespace.path}%2F#{project.path}" }
+
+ it_behaves_like 'handling file uploads', 'for an attachment'
+ end
+end