diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-03-13 06:09:37 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-03-13 06:09:37 +0000 |
commit | 0301a0cad0063d76b1607358dc6c711ea043fdda (patch) | |
tree | 894ac424a6fb370ad8dc5de4294cdc87f0ae164e | |
parent | dcce066c5059c4df112dce4a9edf288d74aec48b (diff) | |
download | gitlab-ce-0301a0cad0063d76b1607358dc6c711ea043fdda.tar.gz |
Add latest changes from gitlab-org/gitlab@master
-rw-r--r-- | app/models/project.rb | 4 | ||||
-rw-r--r-- | app/models/project_services/issue_tracker_service.rb | 8 | ||||
-rw-r--r-- | app/models/project_services/jira_service.rb | 11 | ||||
-rw-r--r-- | app/services/issues/close_service.rb | 13 | ||||
-rw-r--r-- | app/services/system_notes/issuables_service.rb | 2 | ||||
-rw-r--r-- | config/initializers_before_autoloader/100_patch_omniauth_saml.rb (renamed from lib/omni_auth/strategies/saml.rb) | 5 | ||||
-rw-r--r-- | doc/user/admin_area/settings/usage_statistics.md | 289 | ||||
-rw-r--r-- | lib/gitlab/reference_extractor.rb | 2 | ||||
-rw-r--r-- | locale/gitlab.pot | 3 | ||||
-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.rb | 18 | ||||
-rw-r--r-- | spec/services/issues/close_service_spec.rb | 32 | ||||
-rw-r--r-- | spec/services/merge_requests/merge_service_spec.rb | 2 | ||||
-rw-r--r-- | spec/services/system_notes/issuables_service_spec.rb | 31 |
14 files changed, 402 insertions, 20 deletions
diff --git a/app/models/project.rb b/app/models/project.rb index 890768ccf58..6d9a0e5e813 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -1190,6 +1190,10 @@ class Project < ApplicationRecord update_column(:has_external_issue_tracker, services.external_issue_trackers.any?) if Gitlab::Database.read_write? end + def external_references_supported? + external_issue_tracker&.support_cross_reference? + end + def has_wiki? wiki_enabled? || has_external_wiki? end diff --git a/app/models/project_services/issue_tracker_service.rb b/app/models/project_services/issue_tracker_service.rb index 2bf14a6ed25..3f7e8a720aa 100644 --- a/app/models/project_services/issue_tracker_service.rb +++ b/app/models/project_services/issue_tracker_service.rb @@ -151,6 +151,14 @@ class IssueTrackerService < Service result end + def support_close_issue? + false + end + + def support_cross_reference? + false + end + private def enabled_in_gitlab_config diff --git a/app/models/project_services/jira_service.rb b/app/models/project_services/jira_service.rb index e3cd345d065..2766ba11c97 100644 --- a/app/models/project_services/jira_service.rb +++ b/app/models/project_services/jira_service.rb @@ -1,6 +1,7 @@ # frozen_string_literal: true class JiraService < IssueTrackerService + extend ::Gitlab::Utils::Override include Gitlab::Routing include ApplicationHelper include ActionView::Helpers::AssetUrlHelper @@ -205,6 +206,16 @@ class JiraService < IssueTrackerService nil end + override :support_close_issue? + def support_close_issue? + true + end + + override :support_cross_reference? + def support_cross_reference? + true + end + private def test_settings diff --git a/app/services/issues/close_service.rb b/app/services/issues/close_service.rb index d5a542a418d..2cf4bbcd590 100644 --- a/app/services/issues/close_service.rb +++ b/app/services/issues/close_service.rb @@ -18,9 +18,9 @@ module Issues # The code calling this method is responsible for ensuring that a user is # allowed to close the given issue. def close_issue(issue, closed_via: nil, notifications: true, system_note: true) - if project.jira_tracker_active? && issue.is_a?(ExternalIssue) - project.jira_service.close_issue(closed_via, issue) - todo_service.close_issue(issue, current_user) + if issue.is_a?(ExternalIssue) + close_external_issue(issue, closed_via) + return issue end @@ -47,6 +47,13 @@ module Issues private + def close_external_issue(issue, closed_via) + return unless project.external_issue_tracker&.support_close_issue? + + project.external_issue_tracker.close_issue(closed_via, issue) + todo_service.close_issue(issue, current_user) + end + def create_note(issue, current_commit) SystemNoteService.change_status(issue, issue.project, current_user, issue.state, current_commit) end diff --git a/app/services/system_notes/issuables_service.rb b/app/services/system_notes/issuables_service.rb index d7787dac4b8..b555760f88e 100644 --- a/app/services/system_notes/issuables_service.rb +++ b/app/services/system_notes/issuables_service.rb @@ -144,7 +144,7 @@ module SystemNotes # # Returns Boolean def cross_reference_disallowed?(mentioner) - return true if noteable.is_a?(ExternalIssue) && !noteable.project.jira_tracker_active? + return true if noteable.is_a?(ExternalIssue) && !noteable.project&.external_references_supported? return false unless mentioner.is_a?(MergeRequest) return false unless noteable.is_a?(Commit) diff --git a/lib/omni_auth/strategies/saml.rb b/config/initializers_before_autoloader/100_patch_omniauth_saml.rb index ebe062f17e0..d46842ed9a0 100644 --- a/lib/omni_auth/strategies/saml.rb +++ b/config/initializers_before_autoloader/100_patch_omniauth_saml.rb @@ -1,14 +1,13 @@ # frozen_string_literal: true +require 'omniauth/strategies/saml' + module OmniAuth module Strategies class SAML - extend ::Gitlab::Utils::Override - # NOTE: This method duplicates code from omniauth-saml # so that we can access authn_request to store it # See: https://github.com/omniauth/omniauth-saml/issues/172 - override :request_phase def request_phase authn_request = OneLogin::RubySaml::Authrequest.new diff --git a/doc/user/admin_area/settings/usage_statistics.md b/doc/user/admin_area/settings/usage_statistics.md index f087280f693..fff7544139e 100644 --- a/doc/user/admin_area/settings/usage_statistics.md +++ b/doc/user/admin_area/settings/usage_statistics.md @@ -150,3 +150,292 @@ but commented out to help encourage others to add to it in the future. --> [ee-735]: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/735 [ce-23361]: https://gitlab.com/gitlab-org/gitlab-foss/issues/23361 [ee-6602]: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/6602 + +## Usage Statistics Collected + +| Statistic | Section | Stage | Description | +|---|---|---|---| +|uuid||| +|hostname||| +|version||| +|installation_type||| +|active_user_count||| +|recorded_at||| +|edition||| +|license_md5||| +|license_id||| +|historical_max_users||| +|Name|licensee|| +|Email|licensee|| +|Company|licensee|| +|license_user_count||| +|license_starts_at||| +|license_expires_at||| +|license_plan||| +|license_trial||| +|assignee_lists|counts|| +|boards|counts|| +|ci_builds|counts|| +|ci_internal_pipelines|counts|| +|ci_external_pipelines|counts|| +|ci_pipeline_config_auto_devops|counts|| +|ci_pipeline_config_repository|counts|| +|ci_runners|counts|| +|ci_triggers|counts|| +|ci_pipeline_schedules|counts|| +|auto_devops_enabled|counts|| +|auto_devops_disabled|counts|| +|deploy_keys|counts|| +|deployments|counts|| +|successful_deployments|counts|| +|failed_deployments|counts|| +|environments|counts|| +|clusters|counts|| +|clusters_enabled|counts|| +|project_clusters_enabled|counts|| +|group_clusters_enabled|counts|| +|clusters_disabled|counts|| +|project_clusters_disabled|counts|| +|group_clusters_disabled|counts|| +|clusters_platforms_eks|counts|| +|clusters_platforms_gke|counts|| +|clusters_platforms_user|counts|| +|clusters_applications_helm|counts|| +|clusters_applications_ingress|counts|| +|clusters_applications_cert_managers|counts|| +|clusters_applications_crossplane|counts|| +|clusters_applications_prometheus|counts|| +|clusters_applications_runner|counts|| +|clusters_applications_knative|counts|| +|clusters_applications_elastic_stack|counts|| +|in_review_folder|counts|| +|grafana_integrated_projects|counts|| +|groups|counts|| +|issues|counts|| +|issues_created_from_gitlab_error_tracking_ui|counts|| +|issues_with_associated_zoom_link|counts|| +|issues_using_zoom_quick_actions|counts|| +|issues_with_embedded_grafana_charts_approx|counts|| +|keys|counts|| +|label_lists|counts|| +|lfs_objects|counts|| +|milestone_lists|counts|| +|milestones|counts|| +|pages_domains|counts|| +|pool_repositories|counts|| +|projects|counts|| +|projects_imported_from_github|counts|| +|projects_with_repositories_enabled|counts|| +|projects_with_error_tracking_enabled|counts|| +|protected_branches|counts|| +|releases|counts|| +|remote_mirrors|counts|| +|snippets|counts|| +|suggestions|counts|| +|todos|counts|| +|uploads|counts|| +|web_hooks|counts|| +|projects_alerts_active|counts|| +|projects_asana_active|counts|| +|projects_assembla_active|counts|| +|projects_bamboo_active|counts|| +|projects_bugzilla_active|counts|| +|projects_buildkite_active|counts|| +|projects_campfire_active|counts|| +|projects_custom_issue_tracker_active|counts|| +|projects_discord_active|counts|| +|projects_drone_ci_active|counts|| +|projects_emails_on_push_active|counts|| +|projects_external_wiki_active|counts|| +|projects_flowdock_active|counts|| +|projects_github_active|counts|| +|projects_hangouts_chat_active|counts|| +|projects_hipchat_active|counts|| +|projects_irker_active|counts|| +|projects_jenkins_active|counts|| +|projects_jenkins_deprecated_active|counts|| +|projects_jira_active -|counts|| +|projects_mattermost_active|counts|| +|projects_mattermost_slash_commands_active|counts|| +|projects_microsoft_teams_active|counts|| +|projects_packagist_active|counts|| +|projects_pipelines_email_active|counts|| +|projects_pivotaltracker_active|counts|| +|projects_prometheus_active|counts|| +|projects_pushover_active|counts|| +|projects_redmine_active|counts|| +|projects_slack_active|counts|| +|projects_slack_slash_commands_active|counts|| +|projects_teamcity_active|counts|| +|projects_unify_circuit_active|counts|| +|projects_youtrack_active|counts|| +|projects_slack_notifications_active|counts|| +|projects_slack_slash_active|counts|| +|projects_jira_server_active|counts|| +|projects_jira_cloud_active|counts|| +|projects_jira_dvcs_cloud_active|counts|| +|projects_jira_dvcs_server_active|counts|| +|labels|counts|| +|merge_requests|counts|| +|notes|counts|| +|wiki_pages_create|counts|| +|wiki_pages_update|counts|| +|wiki_pages_delete|counts|| +|web_ide_commits|counts|| +|web_ide_views|counts|| +|web_ide_merge_requests|counts|| +|web_ide_previews|counts|| +|snippet_comment|counts|| +|commit_comment|counts|| +|merge_request_comment|counts|| +|snippet_create|counts|| +|snippet_update|counts|| +|navbar_searches|counts|| +|cycle_analytics_views|counts|| +|productivity_analytics_views|counts|| +|source_code_pushes|counts|| +|merge_request_create|counts|| +|design_management_designs_create|counts|| +|design_management_designs_update|counts|| +|design_management_designs_delete|counts|| +|licenses_list_views|counts|| +|user_preferences_group_overview_details|counts|| +|user_preferences_group_overview_security_dashboard|counts|| +|ingress_modsecurity_blocking|counts|| +|ingress_modsecurity_disabled|counts|| +|dependency_list_usages_total|counts|| +|epics|counts|| +|feature_flags|counts|| +|geo_nodes|counts|| +|incident_issues|counts|| +|ldap_group_links|counts|| +|ldap_keys|counts|| +|ldap_users|counts|| +|pod_logs_usages_total|counts|| +|projects_enforcing_code_owner_approval|counts|| +|projects_mirrored_with_pipelines_enabled|counts|| +|projects_reporting_ci_cd_back_to_github|counts|| +|projects_with_packages|counts|| +|projects_with_prometheus_alerts|counts|| +|projects_with_tracing_enabled|counts|| +|projects_with_alerts_service_enabled|counts|| +|template_repositories|counts|| +|container_scanning_jobs|counts|| +|dependency_scanning_jobs|counts|| +|license_management_jobs|counts|| +|sast_jobs|counts|| +|epics_deepest_relationship_level|counts|| +|operations_dashboard_default_dashboard|counts|| +|operations_dashboard_users_with_projects_added|counts|| +|container_registry_enabled||| +|dependency_proxy_enabled||| +|gitlab_shared_runners_enabled||| +|gravatar_enabled||| +|influxdb_metrics_enabled||| +|ldap_enabled||| +|mattermost_enabled||| +|omniauth_enabled||| +|prometheus_metrics_enabled||| +|reply_by_email_enabled||| +|signup_enabled||| +|web_ide_clientside_preview_enabled||| +|ingress_modsecurity_enabled||| +|elasticsearch_enabled||| +|license_trial_ends_on||| +|geo_enabled||| +|version|Git|| +|version|Gitaly|| +|servers|Gitaly|| +|filesystems|Gitaly|| +|enabled|gitlab_pages|| +|version|gitlab_pages|| +|adapter|database|| +|version|database|| +|average|avg_cycle_analytics - issue|| +|sd|avg_cycle_analytics - issue|| +|missing|avg_cycle_analytics - issue|| +|average|avg_cycle_analytics - plan|| +|sd|avg_cycle_analytics - plan|| +|missing|avg_cycle_analytics - plan|| +|average|avg_cycle_analytics - code|| +|sd|avg_cycle_analytics - code|| +|missing|avg_cycle_analytics - code|| +|average|avg_cycle_analytics - test|| +|sd|avg_cycle_analytics - test|| +|missing|avg_cycle_analytics - test|| +|average|avg_cycle_analytics - review|| +|sd|avg_cycle_analytics - review|| +|missing|avg_cycle_analytics - review|| +|average|avg_cycle_analytics - staging|| +|sd|avg_cycle_analytics - staging|| +|missing|avg_cycle_analytics - staging|| +|average|avg_cycle_analytics - production|| +|sd|avg_cycle_analytics - production|| +|missing|avg_cycle_analytics - production|| +|total|avg_cycle_analytics|| +|clusters_applications_cert_managers|usage_activity_by_stage|configure| +|clusters_applications_helm|usage_activity_by_stage|configure| +|clusters_applications_ingress|usage_activity_by_stage|configure| +|clusters_applications_knative|usage_activity_by_stage|configure| +|clusters_disabled|usage_activity_by_stage|configure| +|clusters_enabled|usage_activity_by_stage|configure| +|clusters_platforms_gke|usage_activity_by_stage|configure| +|clusters_platforms_eks|usage_activity_by_stage|configure| +|clusters_platforms_user|usage_activity_by_stage|configure| +|group_clusters_disabled|usage_activity_by_stage|configure| +|group_clusters_enabled|usage_activity_by_stage|configure| +|project_clusters_disabled|usage_activity_by_stage|configure| +|project_clusters_enabled|usage_activity_by_stage|configure| +|projects_slack_notifications_active|usage_activity_by_stage|configure| +|projects_slack_slash_active|usage_activity_by_stage|configure| +|projects_with_prometheus_alerts: 0|usage_activity_by_stage|configure| +|deploy_keys|usage_activity_by_stage|create| +|keys|usage_activity_by_stage|create| +|merge_requests|usage_activity_by_stage|create| +|projects_enforcing_code_owner_approval|usage_activity_by_stage|create| +|projects_imported_from_github|usage_activity_by_stage|create| +|projects_with_repositories_enabled|usage_activity_by_stage|create| +|protected_branches|usage_activity_by_stage|create| +|remote_mirrors|usage_activity_by_stage|create| +|snippets|usage_activity_by_stage|create| +|suggestions:|usage_activity_by_stage|create| +|groups|usage_activity_by_stage|manage| +|ldap_keys|usage_activity_by_stage|manage| +|ldap_users: 0|usage_activity_by_stage|manage| +|clusters|usage_activity_by_stage|monitor| +|clusters_applications_prometheus|usage_activity_by_stage|monitor| +|operations_dashboard_default_dashboard|usage_activity_by_stage|monitor| +|operations_dashboard_users_with_projects_added|usage_activity_by_stage|monitor| +|projects_prometheus_active|usage_activity_by_stage|monitor| +|projects_with_error_tracking_enabled|usage_activity_by_stage|monitor| +|projects_with_tracing_enabled: 0|usage_activity_by_stage|monitor| +|projects_with_packages: 0|usage_activity_by_stage|package| +|assignee_lists|usage_activity_by_stage|plan| +|epics|usage_activity_by_stage|plan| +|issues|usage_activity_by_stage|plan| +|label_lists|usage_activity_by_stage|plan| +|milestone_lists|usage_activity_by_stage|plan| +|notes|usage_activity_by_stage|plan| +|projects|usage_activity_by_stage|plan| +|projects_jira_active|usage_activity_by_stage|plan| +|projects_jira_dvcs_cloud_active|usage_activity_by_stage|plan| +|projects_jira_dvcs_server_active|usage_activity_by_stage|plan| +|service_desk_enabled_projects|usage_activity_by_stage|plan| +|service_desk_issues|usage_activity_by_stage|plan| +|todos: 0|usage_activity_by_stage|plan| +|deployments|usage_activity_by_stage|release| +|failed_deployments|usage_activity_by_stage|release| +|projects_mirrored_with_pipelines_enabled|usage_activity_by_stage|release| +|releases|usage_activity_by_stage|release| +|successful_deployments: 0|usage_activity_by_stage|release| +|user_preferences_group_overview_security_dashboard: 0|usage_activity_by_stage|secure| +|ci_builds|usage_activity_by_stage|verify| +|ci_external_pipelines|usage_activity_by_stage|verify| +|ci_internal_pipelines|usage_activity_by_stage|verify| +|ci_pipeline_config_auto_devops|usage_activity_by_stage|verify| +|ci_pipeline_config_repository|usage_activity_by_stage|verify| +|ci_pipeline_schedules|usage_activity_by_stage|verify| +|ci_pipelines|usage_activity_by_stage|verify| +|ci_triggers|usage_activity_by_stage|verify| +|clusters_applications_runner|usage_activity_by_stage|verify| +|projects_reporting_ci_cd_back_to_github: 0|usage_activity_by_stage|verify| diff --git a/lib/gitlab/reference_extractor.rb b/lib/gitlab/reference_extractor.rb index 519eb49658a..d07d6440c6b 100644 --- a/lib/gitlab/reference_extractor.rb +++ b/lib/gitlab/reference_extractor.rb @@ -44,7 +44,7 @@ module Gitlab end def issues - if project && project.jira_tracker? + if project&.external_references_supported? if project.issues_enabled? @references[:all_issues] ||= references(:external_issue) + references(:issue) else diff --git a/locale/gitlab.pot b/locale/gitlab.pot index 3d817921ef4..9684efba728 100644 --- a/locale/gitlab.pot +++ b/locale/gitlab.pot @@ -9949,6 +9949,9 @@ msgstr "" msgid "GroupRoadmap|Something went wrong while fetching epics" msgstr "" +msgid "GroupRoadmap|Something went wrong while fetching milestones" +msgstr "" + msgid "GroupRoadmap|Sorry, no epics matched your search" msgstr "" 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 |