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
path: root/spec
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-03-13 09:09:37 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-03-13 09:09:37 +0300
commit0301a0cad0063d76b1607358dc6c711ea043fdda (patch)
tree894ac424a6fb370ad8dc5de4294cdc87f0ae164e /spec
parentdcce066c5059c4df112dce4a9edf288d74aec48b (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec')
-rw-r--r--spec/initializers/100_patch_omniauth_saml_spec.rb (renamed from spec/lib/omni_auth/strategies/saml_spec.rb)2
-rw-r--r--spec/lib/gitlab/reference_extractor_spec.rb18
-rw-r--r--spec/services/issues/close_service_spec.rb32
-rw-r--r--spec/services/merge_requests/merge_service_spec.rb2
-rw-r--r--spec/services/system_notes/issuables_service_spec.rb31
5 files changed, 73 insertions, 12 deletions
diff --git a/spec/lib/omni_auth/strategies/saml_spec.rb b/spec/initializers/100_patch_omniauth_saml_spec.rb
index 447800bd93c..c4d20f79af0 100644
--- a/spec/lib/omni_auth/strategies/saml_spec.rb
+++ b/spec/initializers/100_patch_omniauth_saml_spec.rb
@@ -2,7 +2,7 @@
require 'spec_helper'
-describe OmniAuth::Strategies::SAML, type: :strategy do
+describe 'OmniAuth::Strategies::SAML', type: :strategy do
let(:idp_sso_target_url) { 'https://login.example.com/idp' }
let(:strategy) { [OmniAuth::Strategies::SAML, { idp_sso_target_url: idp_sso_target_url }] }
diff --git a/spec/lib/gitlab/reference_extractor_spec.rb b/spec/lib/gitlab/reference_extractor_spec.rb
index 0faaaa50621..a7961190ff1 100644
--- a/spec/lib/gitlab/reference_extractor_spec.rb
+++ b/spec/lib/gitlab/reference_extractor_spec.rb
@@ -225,6 +225,24 @@ describe Gitlab::ReferenceExtractor do
end
end
+ context 'with an inactive external issue tracker' do
+ let(:project) { create(:project) }
+ let!(:jira_service) { create(:jira_service, project: project, active: false) }
+ let(:issue) { create(:issue, project: project) }
+
+ context 'when GitLab issues are enabled' do
+ it 'returns only internal issue' do
+ subject.analyze("JIRA-123 and FOOBAR-4567 and #{issue.to_reference}")
+ expect(subject.issues).to eq([issue])
+ end
+
+ it 'does not return any issue if the internal one does not exists' do
+ subject.analyze("JIRA-123 and FOOBAR-4567 and #999")
+ expect(subject.issues).to be_empty
+ end
+ end
+ end
+
context 'with a project with an underscore' do
let(:other_project) { create(:project, path: 'test_project') }
let(:issue) { create(:issue, project: other_project) }
diff --git a/spec/services/issues/close_service_spec.rb b/spec/services/issues/close_service_spec.rb
index fa4e6ddb088..d8bcd8008ce 100644
--- a/spec/services/issues/close_service_spec.rb
+++ b/spec/services/issues/close_service_spec.rb
@@ -70,6 +70,38 @@ describe Issues::CloseService do
end
describe '#close_issue' do
+ context 'with external issue' do
+ context 'with an active external issue tracker supporting close_issue' do
+ let!(:external_issue_tracker) { create(:jira_service, project: project) }
+
+ it 'closes the issue on the external issue tracker' do
+ expect(project.external_issue_tracker).to receive(:close_issue)
+
+ described_class.new(project, user).close_issue(external_issue)
+ end
+ end
+
+ context 'with innactive external issue tracker supporting close_issue' do
+ let!(:external_issue_tracker) { create(:jira_service, project: project, active: false) }
+
+ it 'does not close the issue on the external issue tracker' do
+ expect(project.external_issue_tracker).not_to receive(:close_issue)
+
+ described_class.new(project, user).close_issue(external_issue)
+ end
+ end
+
+ context 'with an active external issue tracker not supporting close_issue' do
+ let!(:external_issue_tracker) { create(:bugzilla_service, project: project) }
+
+ it 'does not close the issue on the external issue tracker' do
+ expect(project.external_issue_tracker).not_to receive(:close_issue)
+
+ described_class.new(project, user).close_issue(external_issue)
+ end
+ end
+ end
+
context "closed by a merge request", :sidekiq_might_not_need_inline do
it 'mentions closure via a merge request' do
perform_enqueued_jobs do
diff --git a/spec/services/merge_requests/merge_service_spec.rb b/spec/services/merge_requests/merge_service_spec.rb
index 4d72decb632..fa7f745d8a0 100644
--- a/spec/services/merge_requests/merge_service_spec.rb
+++ b/spec/services/merge_requests/merge_service_spec.rb
@@ -158,7 +158,7 @@ describe MergeRequests::MergeService do
end
it 'does not close issue' do
- allow(jira_tracker).to receive_messages(jira_issue_transition_id: nil)
+ jira_tracker.update(jira_issue_transition_id: nil)
expect_any_instance_of(JiraService).not_to receive(:transition_issue)
diff --git a/spec/services/system_notes/issuables_service_spec.rb b/spec/services/system_notes/issuables_service_spec.rb
index 228d69fda4e..c0aaa65971a 100644
--- a/spec/services/system_notes/issuables_service_spec.rb
+++ b/spec/services/system_notes/issuables_service_spec.rb
@@ -598,8 +598,8 @@ describe ::SystemNotes::IssuablesService do
context 'when mentioner is not a MergeRequest' do
it 'is falsey' do
mentioner = noteable.dup
- expect(service.cross_reference_disallowed?(mentioner))
- .to be_falsey
+
+ expect(service.cross_reference_disallowed?(mentioner)).to be_falsey
end
end
@@ -609,24 +609,35 @@ describe ::SystemNotes::IssuablesService do
it 'is truthy when noteable is in commits' do
expect(mentioner).to receive(:commits).and_return([noteable])
- expect(service.cross_reference_disallowed?(mentioner))
- .to be_truthy
+
+ expect(service.cross_reference_disallowed?(mentioner)).to be_truthy
end
it 'is falsey when noteable is not in commits' do
expect(mentioner).to receive(:commits).and_return([])
- expect(service.cross_reference_disallowed?(mentioner))
- .to be_falsey
+
+ expect(service.cross_reference_disallowed?(mentioner)).to be_falsey
end
end
context 'when notable is an ExternalIssue' do
+ let(:project) { create(:project) }
let(:noteable) { ExternalIssue.new('EXT-1234', project) }
- it 'is truthy' do
- mentioner = noteable.dup
- expect(service.cross_reference_disallowed?(mentioner))
- .to be_truthy
+ it 'is false with issue tracker supporting referencing' do
+ create(:jira_service, project: project)
+
+ expect(service.cross_reference_disallowed?(noteable)).to be_falsey
+ end
+
+ it 'is true with issue tracker not supporting referencing' do
+ create(:bugzilla_service, project: project)
+
+ expect(service.cross_reference_disallowed?(noteable)).to be_truthy
+ end
+
+ it 'is true without issue tracker' do
+ expect(service.cross_reference_disallowed?(noteable)).to be_truthy
end
end
end