diff options
author | Nick Thomas <nick@gitlab.com> | 2019-05-20 11:11:49 +0300 |
---|---|---|
committer | Nick Thomas <nick@gitlab.com> | 2019-05-20 11:11:49 +0300 |
commit | 5f261b62c773b9d59c668ff31dde86cb53096027 (patch) | |
tree | cab6f86105f82216f59cd3eb8500f7c78a40e6a3 /spec | |
parent | 82c4a99cdc1568fda80905b772316b9cde4aa54d (diff) | |
parent | 6c6e4ca495f56ec9df8e5e6ec744744404414f8c (diff) |
Merge branch 'sh-fix-tag-push-remote-mirror' into 'master'
Fix remote mirrors not updating after tag push
Closes #51240
See merge request gitlab-org/gitlab-ce!28430
Diffstat (limited to 'spec')
-rw-r--r-- | spec/services/git/base_hooks_service_spec.rb | 90 | ||||
-rw-r--r-- | spec/services/git/branch_hooks_service_spec.rb | 6 | ||||
-rw-r--r-- | spec/services/git/branch_push_service_spec.rb | 66 | ||||
-rw-r--r-- | spec/services/git/tag_hooks_service_spec.rb | 6 |
4 files changed, 102 insertions, 66 deletions
diff --git a/spec/services/git/base_hooks_service_spec.rb b/spec/services/git/base_hooks_service_spec.rb new file mode 100644 index 00000000000..4a2ec769116 --- /dev/null +++ b/spec/services/git/base_hooks_service_spec.rb @@ -0,0 +1,90 @@ +# frozen_string_literal: true + +require 'spec_helper' + +describe Git::BaseHooksService do + include RepoHelpers + include GitHelpers + + let(:user) { create(:user) } + let(:project) { create(:project, :repository) } + let(:service) { described_class.new(project, user, oldrev: oldrev, newrev: newrev, ref: ref) } + + let(:oldrev) { Gitlab::Git::BLANK_SHA } + let(:newrev) { "8a2a6eb295bb170b34c24c76c49ed0e9b2eaf34b" } # gitlab-test: git rev-parse refs/tags/v1.1.0 + let(:ref) { 'refs/tags/v1.1.0' } + + describe 'with remote mirrors' do + class TestService < described_class + def commits + [] + end + end + + let(:project) { create(:project, :repository, :remote_mirror) } + + subject { TestService.new(project, user, oldrev: oldrev, newrev: newrev, ref: ref) } + + before do + expect(subject).to receive(:execute_project_hooks) + end + + context 'when remote mirror feature is enabled' do + it 'fails stuck remote mirrors' do + allow(project).to receive(:update_remote_mirrors).and_return(project.remote_mirrors) + expect(project).to receive(:mark_stuck_remote_mirrors_as_failed!) + + subject.execute + end + + it 'updates remote mirrors' do + expect(project).to receive(:update_remote_mirrors) + + subject.execute + end + end + + context 'when remote mirror feature is disabled' do + before do + stub_application_setting(mirror_available: false) + end + + context 'with remote mirrors global setting overridden' do + before do + project.remote_mirror_available_overridden = true + end + + it 'fails stuck remote mirrors' do + allow(project).to receive(:update_remote_mirrors).and_return(project.remote_mirrors) + expect(project).to receive(:mark_stuck_remote_mirrors_as_failed!) + + subject.execute + end + + it 'updates remote mirrors' do + expect(project).to receive(:update_remote_mirrors) + + subject.execute + end + end + + context 'without remote mirrors global setting overridden' do + before do + project.remote_mirror_available_overridden = false + end + + it 'does not fails stuck remote mirrors' do + expect(project).not_to receive(:mark_stuck_remote_mirrors_as_failed!) + + subject.execute + end + + it 'does not updates remote mirrors' do + expect(project).not_to receive(:update_remote_mirrors) + + subject.execute + end + end + end + end +end diff --git a/spec/services/git/branch_hooks_service_spec.rb b/spec/services/git/branch_hooks_service_spec.rb index 4895e762602..22faa996015 100644 --- a/spec/services/git/branch_hooks_service_spec.rb +++ b/spec/services/git/branch_hooks_service_spec.rb @@ -18,6 +18,12 @@ describe Git::BranchHooksService do described_class.new(project, user, oldrev: oldrev, newrev: newrev, ref: ref) end + it 'update remote mirrors' do + expect(service).to receive(:update_remote_mirrors).and_call_original + + service.execute + end + describe "Git Push Data" do subject(:push_data) { service.execute } diff --git a/spec/services/git/branch_push_service_spec.rb b/spec/services/git/branch_push_service_spec.rb index ad21f710833..6e39fa6b3c0 100644 --- a/spec/services/git/branch_push_service_spec.rb +++ b/spec/services/git/branch_push_service_spec.rb @@ -17,72 +17,6 @@ describe Git::BranchPushService, services: true do project.add_maintainer(user) end - describe 'with remote mirrors' do - let(:project) { create(:project, :repository, :remote_mirror) } - - subject do - described_class.new(project, user, oldrev: oldrev, newrev: newrev, ref: ref) - end - - context 'when remote mirror feature is enabled' do - it 'fails stuck remote mirrors' do - allow(project).to receive(:update_remote_mirrors).and_return(project.remote_mirrors) - expect(project).to receive(:mark_stuck_remote_mirrors_as_failed!) - - subject.execute - end - - it 'updates remote mirrors' do - expect(project).to receive(:update_remote_mirrors) - - subject.execute - end - end - - context 'when remote mirror feature is disabled' do - before do - stub_application_setting(mirror_available: false) - end - - context 'with remote mirrors global setting overridden' do - before do - project.remote_mirror_available_overridden = true - end - - it 'fails stuck remote mirrors' do - allow(project).to receive(:update_remote_mirrors).and_return(project.remote_mirrors) - expect(project).to receive(:mark_stuck_remote_mirrors_as_failed!) - - subject.execute - end - - it 'updates remote mirrors' do - expect(project).to receive(:update_remote_mirrors) - - subject.execute - end - end - - context 'without remote mirrors global setting overridden' do - before do - project.remote_mirror_available_overridden = false - end - - it 'does not fails stuck remote mirrors' do - expect(project).not_to receive(:mark_stuck_remote_mirrors_as_failed!) - - subject.execute - end - - it 'does not updates remote mirrors' do - expect(project).not_to receive(:update_remote_mirrors) - - subject.execute - end - end - end - end - describe 'Push branches' do subject do execute_service(project, user, oldrev, newrev, ref) diff --git a/spec/services/git/tag_hooks_service_spec.rb b/spec/services/git/tag_hooks_service_spec.rb index f4c02932f98..f5938a5c708 100644 --- a/spec/services/git/tag_hooks_service_spec.rb +++ b/spec/services/git/tag_hooks_service_spec.rb @@ -18,6 +18,12 @@ describe Git::TagHooksService, :service do described_class.new(project, user, oldrev: oldrev, newrev: newrev, ref: ref) end + it 'update remote mirrors' do + expect(service).to receive(:update_remote_mirrors).and_call_original + + service.execute + end + describe 'System hooks' do it 'Executes system hooks' do push_data = service.execute |