2017-04-05 13:59:46 -04:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2017-07-10 10:24:02 -04:00
|
|
|
describe ProtectedBranches::UpdateService do
|
2017-04-05 13:59:46 -04:00
|
|
|
let(:protected_branch) { create(:protected_branch) }
|
|
|
|
let(:project) { protected_branch.project }
|
|
|
|
let(:user) { project.owner }
|
|
|
|
let(:params) { { name: 'new protected branch name' } }
|
|
|
|
|
|
|
|
describe '#execute' do
|
|
|
|
subject(:service) { described_class.new(project, user, params) }
|
|
|
|
|
|
|
|
it 'updates a protected branch' do
|
|
|
|
result = service.execute(protected_branch)
|
|
|
|
|
|
|
|
expect(result.reload.name).to eq(params[:name])
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'without admin_project permissions' do
|
|
|
|
let(:user) { create(:user) }
|
|
|
|
|
|
|
|
it "raises error" do
|
2017-08-09 05:52:22 -04:00
|
|
|
expect { service.execute(protected_branch) }.to raise_error(Gitlab::Access::AccessDeniedError)
|
2017-04-05 13:59:46 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|