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-18 13:34:06 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2021-02-18 13:34:06 +0300
commit859a6fb938bb9ee2a317c46dfa4fcc1af49608f0 (patch)
treed7f2700abe6b4ffcb2dcfc80631b2d87d0609239 /spec/services/integrations/test/project_service_spec.rb
parent446d496a6d000c73a304be52587cd9bbc7493136 (diff)
Add latest changes from gitlab-org/gitlab@13-9-stable-eev13.9.0-rc42
Diffstat (limited to 'spec/services/integrations/test/project_service_spec.rb')
-rw-r--r--spec/services/integrations/test/project_service_spec.rb50
1 files changed, 25 insertions, 25 deletions
diff --git a/spec/services/integrations/test/project_service_spec.rb b/spec/services/integrations/test/project_service_spec.rb
index dd603765d59..052b25b0f10 100644
--- a/spec/services/integrations/test/project_service_spec.rb
+++ b/spec/services/integrations/test/project_service_spec.rb
@@ -3,11 +3,12 @@
require 'spec_helper'
RSpec.describe Integrations::Test::ProjectService do
- let(:user) { double('user') }
+ include AfterNextHelpers
describe '#execute' do
- let(:project) { create(:project) }
+ let_it_be(:project) { create(:project) }
let(:integration) { create(:slack_service, project: project) }
+ let(:user) { project.owner }
let(:event) { nil }
let(:sample_data) { { data: 'sample' } }
let(:success_result) { { success: true, result: {} } }
@@ -70,16 +71,17 @@ RSpec.describe Integrations::Test::ProjectService do
end
it 'executes integration' do
- allow(project).to receive(:notes).and_return([Note.new])
+ create(:note, project: project)
+
allow(Gitlab::DataBuilder::Note).to receive(:build).and_return(sample_data)
+ 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)
end
end
- context 'issue' do
- let(:event) { 'issue' }
+ shared_examples_for 'a test of an integration that operates on issues' do
let(:issue) { build(:issue) }
it 'returns error message if not enough data' do
@@ -90,32 +92,28 @@ 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(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)
end
end
- context 'confidential_issue' do
- let(:event) { 'confidential_issue' }
- let(:issue) { build(:issue) }
+ context 'issue' do
+ let(:event) { 'issue' }
- it 'returns error message if not enough data' do
- expect(integration).not_to receive(:test)
- expect(subject).to include({ status: :error, message: 'Ensure the project has issues.' })
- end
+ it_behaves_like 'a test of an integration that operates on issues'
+ end
- it 'executes integration' do
- allow(project).to receive(:issues).and_return([issue])
- allow(issue).to receive(:to_hook_data).and_return(sample_data)
+ context 'confidential_issue' do
+ let(:event) { 'confidential_issue' }
- expect(integration).to receive(:test).with(sample_data).and_return(success_result)
- expect(subject).to eq(success_result)
- end
+ it_behaves_like 'a test of an integration that operates on issues'
end
context 'merge_request' do
let(:event) { 'merge_request' }
+ let(:merge_request) { build(:merge_request) }
it 'returns error message if not enough data' do
expect(integration).not_to receive(:test)
@@ -123,16 +121,17 @@ RSpec.describe Integrations::Test::ProjectService do
end
it 'executes integration' do
- create(:merge_request, source_project: project)
- allow_any_instance_of(MergeRequest).to receive(:to_hook_data).and_return(sample_data)
+ allow(merge_request).to receive(:to_hook_data).and_return(sample_data)
+ 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 eq(success_result)
+ expect(subject).to include(success_result)
end
end
context 'deployment' do
- let(:project) { create(:project, :test_repo) }
+ let_it_be(:project) { create(:project, :test_repo) }
+ let(:deployment) { build(:deployment) }
let(:event) { 'deployment' }
it 'returns error message if not enough data' do
@@ -141,8 +140,8 @@ 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)
@@ -151,6 +150,7 @@ RSpec.describe Integrations::Test::ProjectService do
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)
@@ -158,8 +158,8 @@ 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)
@@ -167,7 +167,7 @@ RSpec.describe Integrations::Test::ProjectService do
end
context 'wiki_page' do
- let(:project) { create(:project, :wiki_repo) }
+ let_it_be(:project) { create(:project, :wiki_repo) }
let(:event) { 'wiki_page' }
it 'returns error message if wiki disabled' do