diff options
author | Zeger-Jan van de Weg <git@zjvandeweg.nl> | 2018-05-14 11:04:39 +0200 |
---|---|---|
committer | Zeger-Jan van de Weg <git@zjvandeweg.nl> | 2018-05-14 12:18:23 +0200 |
commit | e012485a99d83cc57a46b17eb50b9e360dbb51c9 (patch) | |
tree | e27142a3266c7e9e04c56340b4cf8d80e9a5af63 /spec | |
parent | 40683268b2b5ad807194387d8345a30195e178c4 (diff) | |
download | gitlab-ce-e012485a99d83cc57a46b17eb50b9e360dbb51c9.tar.gz |
Move Gitlab::Git::Repository#add_branch to mandatory
Prior to this change, a feature flag could be used to disable this
feature. Now all requests go through Gitaly's OperationService.
Closes https://gitlab.com/gitlab-org/gitaly/issues/540
When vendoring `Gitlab::Git` again in Gitaly, this implemenation will be
gone, but this is readded there through:
https://gitlab.com/gitlab-org/gitaly/merge_requests/717
Diffstat (limited to 'spec')
-rw-r--r-- | spec/models/repository_spec.rb | 68 |
1 files changed, 14 insertions, 54 deletions
diff --git a/spec/models/repository_spec.rb b/spec/models/repository_spec.rb index a7755a505d8..ac8d9a32d4e 100644 --- a/spec/models/repository_spec.rb +++ b/spec/models/repository_spec.rb @@ -990,65 +990,25 @@ describe Repository do subject { repository.add_branch(user, branch_name, target) } - context 'with Gitaly enabled' do - it "calls Gitaly's OperationService" do - expect_any_instance_of(Gitlab::GitalyClient::OperationService) - .to receive(:user_create_branch).with(branch_name, user, target) - .and_return(nil) - - subject - end - - it 'creates_the_branch' do - expect(subject.name).to eq(branch_name) - expect(repository.find_branch(branch_name)).not_to be_nil - end - - context 'with a non-existing target' do - let(:target) { 'fake-target' } + it "calls Gitaly's OperationService" do + expect_any_instance_of(Gitlab::GitalyClient::OperationService) + .to receive(:user_create_branch).with(branch_name, user, target) + .and_return(nil) - it "returns false and doesn't create the branch" do - expect(subject).to be(false) - expect(repository.find_branch(branch_name)).to be_nil - end - end + subject end - context 'with Gitaly disabled', :disable_gitaly do - context 'when pre hooks were successful' do - it 'runs without errors' do - hook = double(trigger: [true, nil]) - expect(Gitlab::Git::Hook).to receive(:new).exactly(3).times.and_return(hook) - - expect { subject }.not_to raise_error - end - - it 'creates the branch' do - allow_any_instance_of(Gitlab::Git::Hook).to receive(:trigger).and_return([true, nil]) - - expect(subject.name).to eq(branch_name) - end - - it 'calls the after_create_branch hook' do - expect(repository).to receive(:after_create_branch) - - subject - end - end - - context 'when pre hooks failed' do - it 'gets an error' do - allow_any_instance_of(Gitlab::Git::Hook).to receive(:trigger).and_return([false, '']) - - expect { subject }.to raise_error(Gitlab::Git::HooksService::PreReceiveError) - end + it 'creates_the_branch' do + expect(subject.name).to eq(branch_name) + expect(repository.find_branch(branch_name)).not_to be_nil + end - it 'does not create the branch' do - allow_any_instance_of(Gitlab::Git::Hook).to receive(:trigger).and_return([false, '']) + context 'with a non-existing target' do + let(:target) { 'fake-target' } - expect { subject }.to raise_error(Gitlab::Git::HooksService::PreReceiveError) - expect(repository.find_branch(branch_name)).to be_nil - end + it "returns false and doesn't create the branch" do + expect(subject).to be(false) + expect(repository.find_branch(branch_name)).to be_nil end end end |