Commit 4f99af95 authored by Tan Le's avatar Tan Le

Fix visibility of issue enforcement setting

This change ensures that Jira issue association is only enabled when
project has a `jira_issues_integration` license and an active Jira
integration. When the above conditions are not met, the `Require an
associated issue from Jira` project setting is not shown.

Changelog: fixed
EE: true
parent 275079fd
......@@ -242,8 +242,14 @@ module EE
alias_attribute :fallback_approvals_required, :approvals_before_merge
def jira_issue_association_required_to_merge_enabled?
::Feature.enabled?(:jira_issue_association_on_merge_request, self) &&
feature_available?(:jira_issue_association_enforcement)
strong_memoize(:jira_issue_association_required_to_merge_enabled) do
next false unless jira_issues_integration_available?
next false unless jira_service&.active?
next false unless ::Feature.enabled?(:jira_issue_association_on_merge_request, self, default_enabled: :yaml)
next false unless feature_available?(:jira_issue_association_enforcement)
true
end
end
def jira_vulnerabilities_integration_enabled?
......
......@@ -105,17 +105,32 @@ RSpec.describe Project do
end
describe '#jira_issue_association_required_to_merge_enabled?' do
using RSpec::Parameterized::TableSyntax
where(:licensed, :feature_flag, :result) do
true | true | true
true | false | false
false | false | false
false | true | false
where(:jira_integration_licensed, :jira_integration_active, :jira_enforcement_licensed, :feature_flag, :result) do
true | true | true | true | true
true | true | true | false | false
true | true | false | true | false
true | true | false | false | false
true | false | true | true | false
true | false | true | false | false
true | false | false | true | false
true | false | false | false | false
false | true | true | true | false
false | true | true | false | false
false | true | false | true | false
false | true | false | false | false
false | false | true | true | false
false | false | true | false | false
false | false | false | true | false
false | false | false | false | false
end
before do
stub_licensed_features(jira_issue_association_enforcement: licensed)
stub_licensed_features(
jira_issues_integration: jira_integration_licensed,
jira_issue_association_enforcement: jira_enforcement_licensed
)
project.build_jira_service(active: jira_integration_active)
stub_feature_flags(jira_issue_association_on_merge_request: feature_flag)
end
......@@ -2784,8 +2799,6 @@ RSpec.describe Project do
end
describe '#prevent_merge_without_jira_issue?' do
using RSpec::Parameterized::TableSyntax
subject { project.prevent_merge_without_jira_issue? }
where(:feature_available, :prevent_merge, :result) do
......
......@@ -25,8 +25,10 @@ RSpec.describe MergeRequestPollCachedWidgetEntity do
context 'jira_associations' do
context 'when feature is available' do
let_it_be(:jira_service) { create(:jira_service, project: project, active: true) }
before do
stub_licensed_features(jira_issue_association_enforcement: true)
stub_licensed_features(jira_issues_integration: true, jira_issue_association_enforcement: true)
stub_feature_flags(jira_issue_association_on_merge_request: true)
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment