Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2021-02-11 12:09:18 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2021-02-11 12:09:18 +0300
commit7240fb1a06c9e1b254719426b1ac96ec2f00fe35 (patch)
treea2c0e2b679bc34c9446a5e4653f5d63f2292205d /spec/services/integrations
parent62d57690bc54e195b2544091725421144ce76900 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/services/integrations')
-rw-r--r--spec/services/integrations/test/project_service_spec.rb50
1 files changed, 39 insertions, 11 deletions
diff --git a/spec/services/integrations/test/project_service_spec.rb b/spec/services/integrations/test/project_service_spec.rb
index 67968deb528..af83fa9533d 100644
--- a/spec/services/integrations/test/project_service_spec.rb
+++ b/spec/services/integrations/test/project_service_spec.rb
@@ -3,6 +3,8 @@
require 'spec_helper'
RSpec.describe Integrations::Test::ProjectService do
+ include AfterNextHelpers
+
describe '#execute' do
let_it_be(:project) { create(:project) }
let(:integration) { create(:slack_service, project: project) }
@@ -72,9 +74,7 @@ RSpec.describe Integrations::Test::ProjectService do
create(:note, project: project)
allow(Gitlab::DataBuilder::Note).to receive(:build).and_return(sample_data)
- allow_next_instance_of(NotesFinder) do |finder|
- allow(finder).to receive(:execute).and_return(Note.all)
- end
+ allow_next(NotesFinder).to receive(:execute).and_return(Note.all)
expect(integration).to receive(:test).with(sample_data).and_return(success_result)
expect(subject).to eq(success_result)
@@ -92,9 +92,7 @@ RSpec.describe Integrations::Test::ProjectService do
it 'executes integration' do
allow(project).to receive(:issues).and_return([issue])
allow(issue).to receive(:to_hook_data).and_return(sample_data)
- allow_next_instance_of(IssuesFinder) do |finder|
- allow(finder).to receive(:execute).and_return([issue])
- end
+ allow_next(IssuesFinder).to receive(:execute).and_return([issue])
expect(integration).to receive(:test).with(sample_data).and_return(success_result)
expect(subject).to eq(success_result)
@@ -124,9 +122,7 @@ RSpec.describe Integrations::Test::ProjectService do
it 'executes integration' do
allow(merge_request).to receive(:to_hook_data).and_return(sample_data)
- allow_next_instance_of(MergeRequestsFinder) do |finder|
- allow(finder).to receive(:execute).and_return([merge_request])
- end
+ allow_next(MergeRequestsFinder).to receive(:execute).and_return([merge_request])
expect(integration).to receive(:test).with(sample_data).and_return(success_result)
expect(subject).to include(success_result)
@@ -135,6 +131,7 @@ RSpec.describe Integrations::Test::ProjectService do
context 'deployment' do
let_it_be(:project) { create(:project, :test_repo) }
+ let(:deployment) { build(:deployment) }
let(:event) { 'deployment' }
it 'returns error message if not enough data' do
@@ -143,16 +140,32 @@ RSpec.describe Integrations::Test::ProjectService do
end
it 'executes integration' do
- create(:deployment, project: project)
allow(Gitlab::DataBuilder::Deployment).to receive(:build).and_return(sample_data)
+ allow_next(DeploymentsFinder).to receive(:execute).and_return([deployment])
expect(integration).to receive(:test).with(sample_data).and_return(success_result)
expect(subject).to eq(success_result)
end
+
+ context 'when the reorder feature flag is disabled' do
+ before do
+ stub_feature_flags(integrations_test_webhook_reorder: false)
+ end
+
+ it 'executes the old query' do
+ allow(Gitlab::DataBuilder::Deployment).to receive(:build).and_return(sample_data)
+
+ expect(DeploymentsFinder).not_to receive(:new)
+ expect(project).to receive(:deployments).and_return([deployment])
+ expect(integration).to receive(:test).with(sample_data).and_return(success_result)
+ expect(subject).to eq(success_result)
+ end
+ end
end
context 'pipeline' do
let(:event) { 'pipeline' }
+ let(:pipeline) { build(:ci_pipeline) }
it 'returns error message if not enough data' do
expect(integration).not_to receive(:test)
@@ -160,12 +173,27 @@ RSpec.describe Integrations::Test::ProjectService do
end
it 'executes integration' do
- create(:ci_empty_pipeline, project: project)
allow(Gitlab::DataBuilder::Pipeline).to receive(:build).and_return(sample_data)
+ allow_next(Ci::PipelinesFinder).to receive(:execute).and_return([pipeline])
expect(integration).to receive(:test).with(sample_data).and_return(success_result)
expect(subject).to eq(success_result)
end
+
+ context 'when the reorder feature flag is disabled' do
+ before do
+ stub_feature_flags(integrations_test_webhook_reorder: false)
+ end
+
+ it 'executes the old query' do
+ create(:ci_empty_pipeline, project: project)
+ allow(Gitlab::DataBuilder::Pipeline).to receive(:build).and_return(sample_data)
+
+ expect(Ci::PipelinesFinder).not_to receive(:new)
+ expect(integration).to receive(:test).with(sample_data).and_return(success_result)
+ expect(subject).to eq(success_result)
+ end
+ end
end
context 'wiki_page' do