diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-11-17 14:33:21 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-11-17 14:33:21 +0300 |
commit | 7021455bd1ed7b125c55eb1b33c5a01f2bc55ee0 (patch) | |
tree | 5bdc2229f5198d516781f8d24eace62fc7e589e9 /spec/requests/api/files_spec.rb | |
parent | 185b095e93520f96e9cfc31d9c3e69b498cdab7c (diff) |
Add latest changes from gitlab-org/gitlab@15-6-stable-eev15.6.0-rc42
Diffstat (limited to 'spec/requests/api/files_spec.rb')
-rw-r--r-- | spec/requests/api/files_spec.rb | 35 |
1 files changed, 33 insertions, 2 deletions
diff --git a/spec/requests/api/files_spec.rb b/spec/requests/api/files_spec.rb index e95a626b4aa..d4d3aace204 100644 --- a/spec/requests/api/files_spec.rb +++ b/spec/requests/api/files_spec.rb @@ -11,7 +11,7 @@ RSpec.describe API::Files do let_it_be(:inherited_reporter) { create(:user) } let_it_be(:inherited_developer) { create(:user) } - let!(:project) { create(:project, :repository, namespace: user.namespace ) } + let!(:project) { create(:project, :repository, namespace: user.namespace) } let(:guest) { create(:user) { |u| project.add_guest(u) } } let(:file_path) { 'files%2Fruby%2Fpopen%2Erb' } let(:file_name) { 'popen.rb' } @@ -935,7 +935,7 @@ RSpec.describe API::Files do end context 'and the repo is empty' do - let!(:project) { create(:project_empty_repo, namespace: user.namespace ) } + let!(:project) { create(:project_empty_repo, namespace: user.namespace) } it_behaves_like 'creates a new file in the project repo' do let(:current_user) { user } @@ -1253,4 +1253,35 @@ RSpec.describe API::Files do expect(json_response['content']).to eq(put_params[:content]) end end + + describe 'POST /projects/:id/repository/files with text encoding' do + let(:file_path) { 'test%2Etext' } + let(:put_params) do + { + branch: 'master', + content: 'test', + commit_message: 'Text file', + encoding: 'text' + } + end + + let(:get_params) do + { + ref: 'master' + } + end + + before do + post api(route(file_path), user), params: put_params + end + + it 'returns base64-encoded text file' do + get api(route(file_path), user), params: get_params + + expect(response).to have_gitlab_http_status(:ok) + expect(json_response['file_path']).to eq(CGI.unescape(file_path)) + expect(json_response['file_name']).to eq(CGI.unescape(file_path)) + expect(Base64.decode64(json_response['content'])).to eq("test") + end + end end |