diff options
author | Danilo Sousa <dsgoncalves@uoldiveo.com> | 2016-02-22 14:16:29 -0300 |
---|---|---|
committer | Danilo Sousa <dsgoncalves@uoldiveo.com> | 2016-02-22 14:16:29 -0300 |
commit | 69210c7ddf7d77cc9eb7b78f0bc00ad2f1475955 (patch) | |
tree | 4872e339aacfe6aa75bad26718dc3489b6cacfe9 /spec | |
parent | c098f57f5dfc4588673ac62083611736c8a75136 (diff) |
follow the hook remotes config also for groups repositories
ref.: https://github.com/ytti/oxidized/pull/326/files#r53557892
Diffstat (limited to 'spec')
-rw-r--r-- | spec/githubrepo_spec.rb | 4 | ||||
-rw-r--r-- | spec/node_spec.rb | 47 |
2 files changed, 37 insertions, 14 deletions
diff --git a/spec/githubrepo_spec.rb b/spec/githubrepo_spec.rb index b6a8d9e..ab5e251 100644 --- a/spec/githubrepo_spec.rb +++ b/spec/githubrepo_spec.rb @@ -12,7 +12,6 @@ describe GithubRepo do before(:each) do Oxidized.asetus = Asetus.new - Oxidized.config.output.git.repo = 'foo.git' Oxidized.config.log = '/dev/null' Oxidized.setup_logger end @@ -97,6 +96,7 @@ describe GithubRepo do describe 'when there is only one repository and no groups' do before do + Oxidized.config.output.git.repo = 'foo.git' remote.expects(:url).returns('https://github.com/username/foo.git') remote.expects(:push).with(['refs/heads/master'], credentials: credentials).returns(true) repo.expects(:remotes).returns({'origin' => remote}) @@ -139,6 +139,7 @@ describe GithubRepo do let(:repository) { './ggrroouupp.git' } before do + Oxidized.config.output.git.repo.ggrroouupp = repository Oxidized.config.hooks.github_repo_hook.remote_repo.ggrroouupp = 'ggrroouupp#remote_repo' end @@ -153,6 +154,7 @@ describe GithubRepo do let(:repository) { 'foo.git' } before do + Oxidized.config.output.git.repo = repository Oxidized.config.hooks.github_repo_hook.remote_repo = 'github_repo_hook#remote_repo' Oxidized.config.output.git.single_repo = true end diff --git a/spec/node_spec.rb b/spec/node_spec.rb index f9c912e..21c6e34 100644 --- a/spec/node_spec.rb +++ b/spec/node_spec.rb @@ -3,7 +3,6 @@ require 'spec_helper' describe Oxidized::Node do before(:each) do Oxidized.stubs(:asetus).returns(Asetus.new) - Oxidized.config.output.git.repo = '/tmp/repository.git' Oxidized::Node.any_instance.stubs(:resolve_output) @node = Oxidized::Node.new(name: 'example.com', @@ -44,25 +43,47 @@ describe Oxidized::Node do end describe '#repo' do - it 'when there is no groups' do - @node.repo.must_equal '/tmp/repository.git' + let(:group) { nil } + let(:node) do + Oxidized::Node.new({ + ip: '127.0.0.1', group: group, model: 'junos' + }) + end + + it 'when there are no groups' do + Oxidized.config.output.git.repo = '/tmp/repository.git' + node.repo.must_equal '/tmp/repository.git' end describe 'when there are groups' do - let(:node) do - Oxidized::Node.new({ - ip: '127.0.0.1', group: 'ggrroouupp', model: 'junos' - }) + let(:group) { 'ggrroouupp' } + + before do + Oxidized.config.output.git.single_repo = single_repo end - it 'with only one repository' do - Oxidized.config.output.git.single_repo = true - node.repo.must_equal '/tmp/repository.git' + describe 'with only one repository' do + let(:single_repo) { true } + + before do + Oxidized.config.output.git.repo = '/tmp/repository.git' + end + + it 'should use the correct remote' do + node.repo.must_equal '/tmp/repository.git' + end end - it 'with more than one repository' do - Oxidized.config.output.git.single_repo = false - node.repo.must_equal '/tmp/ggrroouupp.git' + describe 'with more than one repository' do + let(:single_repo) { nil } + + before do + Oxidized.config.output.git.repo.ggrroouupp = '/tmp/ggrroouupp.git' + end + + it 'should use the correct remote' do + node.repo.must_equal '/tmp/ggrroouupp.git' + end end end end |