diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-05-20 17:34:42 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-05-20 17:34:42 +0300 |
commit | 9f46488805e86b1bc341ea1620b866016c2ce5ed (patch) | |
tree | f9748c7e287041e37d6da49e0a29c9511dc34768 /spec/models/remote_mirror_spec.rb | |
parent | dfc92d081ea0332d69c8aca2f0e745cb48ae5e6d (diff) |
Add latest changes from gitlab-org/gitlab@13-0-stable-ee
Diffstat (limited to 'spec/models/remote_mirror_spec.rb')
-rw-r--r-- | spec/models/remote_mirror_spec.rb | 52 |
1 files changed, 42 insertions, 10 deletions
diff --git a/spec/models/remote_mirror_spec.rb b/spec/models/remote_mirror_spec.rb index 15b162ae87a..a87cdcf9344 100644 --- a/spec/models/remote_mirror_spec.rb +++ b/spec/models/remote_mirror_spec.rb @@ -143,22 +143,54 @@ describe RemoteMirror, :mailer do end describe '#update_repository' do - let(:git_remote_mirror) { spy } + it 'performs update including options' do + git_remote_mirror = stub_const('Gitlab::Git::RemoteMirror', spy) + mirror = build(:remote_mirror) - before do - stub_const('Gitlab::Git::RemoteMirror', git_remote_mirror) + expect(mirror).to receive(:options_for_update).and_return(keep_divergent_refs: true) + mirror.update_repository + + expect(git_remote_mirror).to have_received(:new).with( + mirror.project.repository.raw, + mirror.remote_name, + keep_divergent_refs: true + ) + expect(git_remote_mirror).to have_received(:update) end + end - it 'includes the `keep_divergent_refs` setting' do + describe '#options_for_update' do + it 'includes the `keep_divergent_refs` option' do mirror = build_stubbed(:remote_mirror, keep_divergent_refs: true) - mirror.update_repository({}) + options = mirror.options_for_update - expect(git_remote_mirror).to have_received(:new).with( - anything, - mirror.remote_name, - hash_including(keep_divergent_refs: true) - ) + expect(options).to include(keep_divergent_refs: true) + end + + it 'includes the `only_branches_matching` option' do + branch = create(:protected_branch) + mirror = build_stubbed(:remote_mirror, project: branch.project, only_protected_branches: true) + + options = mirror.options_for_update + + expect(options).to include(only_branches_matching: [branch.name]) + end + + it 'includes the `ssh_key` option' do + mirror = build(:remote_mirror, :ssh, ssh_private_key: 'private-key') + + options = mirror.options_for_update + + expect(options).to include(ssh_key: 'private-key') + end + + it 'includes the `known_hosts` option' do + mirror = build(:remote_mirror, :ssh, ssh_known_hosts: 'known-hosts') + + options = mirror.options_for_update + + expect(options).to include(known_hosts: 'known-hosts') end end |