diff options
author | Jacopo <beschi.jacopo@gmail.com> | 2018-09-23 12:48:29 +0200 |
---|---|---|
committer | Jacopo <beschi.jacopo@gmail.com> | 2018-09-27 11:51:15 +0200 |
commit | 271776d4aa25a23b6f58c6befa94a240e61d4120 (patch) | |
tree | 5643a3e07a8e5efd9b03398d36e23606e91df091 /spec/services/files | |
parent | a1529944e962fc9b4addee324b4e606c4b7b1e93 (diff) | |
download | gitlab-ce-271776d4aa25a23b6f58c6befa94a240e61d4120.tar.gz |
Adds chmod action to POST /projects/:id/repository/commits API
With this action the user can update the execute_filemode of a given file in the repository.
Diffstat (limited to 'spec/services/files')
-rw-r--r-- | spec/services/files/multi_service_spec.rb | 36 |
1 files changed, 35 insertions, 1 deletions
diff --git a/spec/services/files/multi_service_spec.rb b/spec/services/files/multi_service_spec.rb index 3bdedaf3770..5f3c8e82715 100644 --- a/spec/services/files/multi_service_spec.rb +++ b/spec/services/files/multi_service_spec.rb @@ -11,6 +11,7 @@ describe Files::MultiService do let(:new_file_path) { 'files/ruby/popen.rb' } let(:file_content) { 'New content' } let(:action) { 'update' } + let(:commit_message) { 'Update File' } let!(:original_commit_id) do Gitlab::Git::Commit.last_for_path(project.repository, branch_name, original_file_path).sha @@ -30,7 +31,7 @@ describe Files::MultiService do let(:commit_params) do { - commit_message: "Update File", + commit_message: commit_message, branch_name: branch_name, start_branch: branch_name, actions: actions @@ -84,6 +85,39 @@ describe Files::MultiService do end end + describe 'changing execute_filemode of a file' do + let(:commit_message) { 'Chmod +x file' } + let(:file_path) { original_file_path } + let(:default_action) do + { + action: 'chmod', + file_path: file_path, + execute_filemode: true + } + end + + it 'accepts the commit' do + results = subject.execute + + expect(results[:status]).to eq(:success) + end + + it 'updates the execute_filemode of the file' do + expect { subject.execute }.to change { repository.blob_at_branch(branch_name, file_path).mode }.from('100644').to('100755') + end + + context "when the file doesn't exists" do + let(:file_path) { 'files/wrong_path.rb' } + + it 'rejects the commit' do + results = subject.execute + + expect(results[:status]).to eq(:error) + expect(results[:message]).to eq("A file with this name doesn't exist") + end + end + end + context 'when moving a file' do let(:action) { 'move' } let(:new_file_path) { 'files/ruby/new_popen.rb' } |