diff options
Diffstat (limited to 'spec/services/delete_branch_service_spec.rb')
-rw-r--r-- | spec/services/delete_branch_service_spec.rb | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/spec/services/delete_branch_service_spec.rb b/spec/services/delete_branch_service_spec.rb index 9c9fba030e7..b8064c2cbc1 100644 --- a/spec/services/delete_branch_service_spec.rb +++ b/spec/services/delete_branch_service_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' describe DeleteBranchService do @@ -6,20 +8,24 @@ describe DeleteBranchService do let(:user) { create(:user) } let(:service) { described_class.new(project, user) } + shared_examples 'a deleted branch' do |branch_name| + it 'removes the branch' do + expect(branch_exists?(branch_name)).to be true + + result = service.execute(branch_name) + + expect(result.status).to eq :success + expect(branch_exists?(branch_name)).to be false + end + end + describe '#execute' do context 'when user has access to push to repository' do before do project.add_developer(user) end - it 'removes the branch' do - expect(branch_exists?('feature')).to be true - - result = service.execute('feature') - - expect(result[:status]).to eq :success - expect(branch_exists?('feature')).to be false - end + it_behaves_like 'a deleted branch', 'feature' end context 'when user does not have access to push to repository' do @@ -28,8 +34,8 @@ describe DeleteBranchService do result = service.execute('feature') - expect(result[:status]).to eq :error - expect(result[:message]).to eq 'You dont have push access to repo' + expect(result.status).to eq :error + expect(result.message).to eq 'You dont have push access to repo' expect(branch_exists?('feature')).to be true end end |