diff options
Diffstat (limited to 'spec/workers/post_receive_spec.rb')
-rw-r--r-- | spec/workers/post_receive_spec.rb | 97 |
1 files changed, 10 insertions, 87 deletions
diff --git a/spec/workers/post_receive_spec.rb b/spec/workers/post_receive_spec.rb index d034e962cee..6983fea021c 100644 --- a/spec/workers/post_receive_spec.rb +++ b/spec/workers/post_receive_spec.rb @@ -73,8 +73,7 @@ describe PostReceive do context 'empty changes' do it "does not call any PushService but runs after project hooks" do - expect(Git::BranchPushService).not_to receive(:new) - expect(Git::TagPushService).not_to receive(:new) + expect(Git::ProcessRefChangesService).not_to receive(:new) expect_next_instance_of(SystemHooksService) { |service| expect(service).to receive(:execute_hooks) } perform(changes: "") @@ -87,8 +86,7 @@ describe PostReceive do let!(:key_id) { "" } it 'returns false' do - expect(Git::BranchPushService).not_to receive(:new) - expect(Git::TagPushService).not_to receive(:new) + expect(Git::ProcessRefChangesService).not_to receive(:new) expect(perform).to be false end @@ -131,13 +129,11 @@ describe PostReceive do perform end - it 'calls Git::BranchPushService' do - expect_any_instance_of(Git::BranchPushService) do |service| + it 'calls Git::ProcessRefChangesService' do + expect_next_instance_of(Git::ProcessRefChangesService) do |service| expect(service).to receive(:execute).and_return(true) end - expect(Git::TagPushService).not_to receive(:new) - perform end @@ -174,8 +170,6 @@ describe PostReceive do 654321 210987 refs/tags/tag1 654322 210986 refs/tags/tag2 654323 210985 refs/tags/tag3 - 654324 210984 refs/tags/tag4 - 654325 210983 refs/tags/tag5 EOF end @@ -189,23 +183,19 @@ describe PostReceive do perform end - it "only invalidates tags once" do - expect(project.repository).to receive(:repository_event).exactly(5).times.with(:push_tag).and_call_original + it 'only invalidates tags once' do + expect(project.repository).to receive(:repository_event).exactly(3).times.with(:push_tag).and_call_original expect(project.repository).to receive(:expire_caches_for_tags).once.and_call_original expect(project.repository).to receive(:expire_tags_cache).once.and_call_original perform end - it "calls Git::TagPushService" do - expect(Git::BranchPushService).not_to receive(:new) - - expect_any_instance_of(Git::TagPushService) do |service| + it 'calls Git::ProcessRefChangesService' do + expect_next_instance_of(Git::ProcessRefChangesService) do |service| expect(service).to receive(:execute).and_return(true) end - expect(Git::BranchPushService).not_to receive(:new) - perform end @@ -223,8 +213,7 @@ describe PostReceive do let(:changes) { "123456 789012 refs/merge-requests/123" } it "does not call any of the services" do - expect(Git::BranchPushService).not_to receive(:new) - expect(Git::TagPushService).not_to receive(:new) + expect(Git::ProcessRefChangesService).not_to receive(:new) perform end @@ -232,72 +221,6 @@ describe PostReceive do it_behaves_like 'not updating remote mirrors' end - context "gitlab-ci.yml" do - let(:changes) do - <<-EOF.strip_heredoc - 123456 789012 refs/heads/feature - 654321 210987 refs/tags/tag - 123456 789012 refs/heads/feature2 - 123458 789013 refs/heads/feature3 - 123459 789015 refs/heads/feature4 - EOF - end - - let(:changes_count) { changes.lines.count } - - subject { perform } - - context "with valid .gitlab-ci.yml" do - before do - stub_ci_pipeline_to_return_yaml_file - - allow_any_instance_of(Project) - .to receive(:commit) - .and_return(project.commit) - - allow_any_instance_of(Repository) - .to receive(:branch_exists?) - .and_return(true) - end - - context 'when git_push_create_all_pipelines is disabled' do - before do - stub_feature_flags(git_push_create_all_pipelines: false) - end - - it "creates pipeline for branches and tags" do - subject - - expect(Ci::Pipeline.pluck(:ref)).to contain_exactly("feature", "tag", "feature2", "feature3") - end - - it "creates exactly #{described_class::PIPELINE_PROCESS_LIMIT} pipelines" do - expect(changes_count).to be > described_class::PIPELINE_PROCESS_LIMIT - - expect { subject }.to change { Ci::Pipeline.count }.by(described_class::PIPELINE_PROCESS_LIMIT) - end - end - - context 'when git_push_create_all_pipelines is enabled' do - before do - stub_feature_flags(git_push_create_all_pipelines: true) - end - - it "creates all pipelines" do - expect { subject }.to change { Ci::Pipeline.count }.by(changes_count) - end - end - end - - context "does not create a Ci::Pipeline" do - before do - stub_ci_pipeline_yaml_file(nil) - end - - it { expect { subject }.not_to change { Ci::Pipeline.count } } - end - end - context 'after project changes hooks' do let(:changes) { '123456 789012 refs/heads/tést' } let(:fake_hook_data) { Hash.new(event_name: 'repository_update') } @@ -306,7 +229,7 @@ describe PostReceive do allow_any_instance_of(Gitlab::DataBuilder::Repository).to receive(:update).and_return(fake_hook_data) # silence hooks so we can isolate allow_any_instance_of(Key).to receive(:post_create_hook).and_return(true) - expect_next_instance_of(Git::BranchPushService) do |service| + expect_next_instance_of(Git::ProcessRefChangesService) do |service| expect(service).to receive(:execute).and_return(true) end end |