diff options
author | Rubén Dávila <ruben@gitlab.com> | 2017-12-14 06:58:10 +0300 |
---|---|---|
committer | Rubén Dávila <ruben@gitlab.com> | 2017-12-20 09:24:53 +0300 |
commit | 81331fa77e181d193f444c34443d6ef0c5b01ed6 (patch) | |
tree | cea89999114181f12eaf78987831614a1b771f3a /spec | |
parent | 5b880f0d36b082a0b443c5fe95f51a84dee27475 (diff) |
Add some initial specs for Files::MultiService class
Diffstat (limited to 'spec')
-rw-r--r-- | spec/services/files/multi_service_spec.rb | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/spec/services/files/multi_service_spec.rb b/spec/services/files/multi_service_spec.rb new file mode 100644 index 00000000000..34457ee796a --- /dev/null +++ b/spec/services/files/multi_service_spec.rb @@ -0,0 +1,54 @@ +require "spec_helper" + +describe Files::MultiService do + subject { described_class.new(project, user, commit_params) } + + let(:project) { create(:project, :repository) } + let(:user) { create(:user) } + let(:branch_name) { project.default_branch } + let(:action) { 'update' } + + let(:actions) do + [ + { + action: action, + file_path: 'files/ruby/popen.rb', + content: 'New content' + } + ] + end + + let(:commit_params) do + { + commit_message: "Update File", + branch_name: branch_name, + start_branch: branch_name, + actions: actions + } + end + + before do + project.team << [user, :master] + end + + describe '#execute' do + context 'with a valid action' do + it 'returns a hash with the :success status ' do + results = subject.execute + + expect(results[:status]).to eq(:success) + end + end + + context 'with an invalid action' do + let(:action) { 'rename' } + + it 'returns a hash with the :error status ' do + results = subject.execute + + expect(results[:status]).to eq(:error) + expect(results[:message]).to match(/Unknown action/) + end + end + end +end |