summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorAlejandro Rodríguez <alejorro70@gmail.com>2017-12-18 23:27:21 -0300
committerAlejandro Rodríguez <alejorro70@gmail.com>2018-01-03 23:06:34 -0300
commit43308bd826a88f92bbc92320e0591faf92acd66f (patch)
tree63e5201178fa3daf6ac54b0392ace8720ae44a96 /spec
parentfb583c4b1839af16c50e27105a300695aa50bcad (diff)
downloadgitlab-ce-43308bd826a88f92bbc92320e0591faf92acd66f.tar.gz
Move push_remote_branches from Gitlab::Shell to Gitlab::Git::Repository
Diffstat (limited to 'spec')
-rw-r--r--spec/lib/gitlab/git/repository_spec.rb40
-rw-r--r--spec/lib/gitlab/shell_spec.rb28
2 files changed, 38 insertions, 30 deletions
diff --git a/spec/lib/gitlab/git/repository_spec.rb b/spec/lib/gitlab/git/repository_spec.rb
index 0e4292026df..12ec7b1fdc4 100644
--- a/spec/lib/gitlab/git/repository_spec.rb
+++ b/spec/lib/gitlab/git/repository_spec.rb
@@ -18,9 +18,10 @@ describe Gitlab::Git::Repository, seed_helper: true do
end
let(:repository) { Gitlab::Git::Repository.new('default', TEST_REPO_PATH, '') }
+ let(:storage_path) { TestEnv.repos_path }
describe '.create_hooks' do
- let(:repo_path) { File.join(TestEnv.repos_path, 'hook-test.git') }
+ let(:repo_path) { File.join(storage_path, 'hook-test.git') }
let(:hooks_dir) { File.join(repo_path, 'hooks') }
let(:target_hooks_dir) { Gitlab.config.gitlab_shell.hooks_path }
let(:existing_target) { File.join(repo_path, 'foobar') }
@@ -645,7 +646,7 @@ describe Gitlab::Git::Repository, seed_helper: true do
end
after do
- Gitlab::Shell.new.remove_repository(TestEnv.repos_path, 'my_project')
+ Gitlab::Shell.new.remove_repository(storage_path, 'my_project')
end
it 'fetches a repository as a mirror remote' do
@@ -1884,6 +1885,41 @@ describe Gitlab::Git::Repository, seed_helper: true do
end
end
+ describe '#gitlab_projects' do
+ subject { repository.gitlab_projects }
+
+ it { expect(subject.shard_path).to eq(storage_path) }
+ it { expect(subject.repository_relative_path).to eq(repository.relative_path) }
+ end
+
+ context 'gitlab_projects commands' do
+ let(:gitlab_projects) { repository.gitlab_projects }
+ let(:timeout) { Gitlab.config.gitlab_shell.git_timeout }
+
+ describe '#push_remote_branches' do
+ subject do
+ repository.push_remote_branches('downstream-remote', ['master'])
+ end
+
+ it 'executes the command' do
+ expect(gitlab_projects).to receive(:push_branches)
+ .with('downstream-remote', timeout, true, ['master'])
+ .and_return(true)
+
+ is_expected.to be_truthy
+ end
+
+ it 'raises an error if the command fails' do
+ allow(gitlab_projects).to receive(:output) { 'error' }
+ expect(gitlab_projects).to receive(:push_branches)
+ .with('downstream-remote', timeout, true, ['master'])
+ .and_return(false)
+
+ expect { subject }.to raise_error(Gitlab::Git::CommandError, 'error')
+ end
+ end
+ end
+
def create_remote_branch(repository, remote_name, branch_name, source_branch_name)
source_branch = repository.branches.find { |branch| branch.name == source_branch_name }
rugged = repository.rugged
diff --git a/spec/lib/gitlab/shell_spec.rb b/spec/lib/gitlab/shell_spec.rb
index dd779b04741..7c2c02505b3 100644
--- a/spec/lib/gitlab/shell_spec.rb
+++ b/spec/lib/gitlab/shell_spec.rb
@@ -348,34 +348,6 @@ describe Gitlab::Shell do
end
end
- describe '#push_remote_branches' do
- subject(:result) do
- gitlab_shell.push_remote_branches(
- project.repository_storage_path,
- project.disk_path,
- 'downstream-remote',
- ['master']
- )
- end
-
- it 'executes the command' do
- expect(gitlab_projects).to receive(:push_branches)
- .with('downstream-remote', timeout, true, ['master'])
- .and_return(true)
-
- is_expected.to be_truthy
- end
-
- it 'fails to execute the command' do
- allow(gitlab_projects).to receive(:output) { 'error' }
- expect(gitlab_projects).to receive(:push_branches)
- .with('downstream-remote', timeout, true, ['master'])
- .and_return(false)
-
- expect { result }.to raise_error(Gitlab::Shell::Error, 'error')
- end
- end
-
describe '#delete_remote_branches' do
subject(:result) do
gitlab_shell.delete_remote_branches(