Commit c00d73be authored by Savas Vedova's avatar Savas Vedova

Merge branch '297644-jira-association-requirements-be' into 'master'

Adds jira issue enforcement field [RUN ALL RSPEC] [RUN AS-IF-FOSS]

See merge request gitlab-org/gitlab!52896
parents 01119a1f ffecffce
......@@ -397,6 +397,14 @@ class ProjectsController < Projects::ApplicationController
]
end
def project_setting_attributes
%i[
show_default_award_emojis
squash_option
allow_editing_commit_messages
]
end
def project_params_attributes
[
:allow_merge_on_skipped_pipeline,
......@@ -434,11 +442,7 @@ class ProjectsController < Projects::ApplicationController
:suggestion_commit_message,
:packages_enabled,
:service_desk_enabled,
project_setting_attributes: %i[
show_default_award_emojis
squash_option
allow_editing_commit_messages
]
project_setting_attributes: project_setting_attributes
] + [project_feature_attributes: project_feature_attributes]
end
......
......@@ -21,4 +21,4 @@ class ProjectSetting < ApplicationRecord
end
end
ProjectSetting.prepend_if_ee('EE::ProjectSetting')
ProjectSetting.prepend_ee_mod
......@@ -24,3 +24,4 @@
= form.check_box :only_allow_merge_if_all_discussions_are_resolved, class: 'form-check-input', data: { qa_selector: 'allow_merge_if_all_discussions_are_resolved_checkbox' }
= form.label :only_allow_merge_if_all_discussions_are_resolved, class: 'form-check-label' do
= s_('ProjectSettings|All discussions must be resolved')
= render_if_exists 'projects/merge_request_merge_checks_jira_enforcement', form: form, project: @project
---
title: Adds jira issue enforcement field
merge_request: 52896
author:
type: added
# frozen_string_literal: true
class AddPreventMergeWithoutJiraIssueToProjectSettings < ActiveRecord::Migration[6.0]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
def up
with_lock_retries do
add_column :project_settings, :prevent_merge_without_jira_issue, :boolean, null: false, default: false
end
end
def down
with_lock_retries do
remove_column :project_settings, :prevent_merge_without_jira_issue
end
end
end
ae84fa35fcc5a0780d86887294a32e250d2ac13dcf607750f834df5828e5bece
\ No newline at end of file
......@@ -16064,6 +16064,7 @@ CREATE TABLE project_settings (
has_confluence boolean DEFAULT false NOT NULL,
has_vulnerabilities boolean DEFAULT false NOT NULL,
allow_editing_commit_messages boolean DEFAULT false NOT NULL,
prevent_merge_without_jira_issue boolean DEFAULT false NOT NULL,
CONSTRAINT check_bde223416c CHECK ((show_default_award_emojis IS NOT NULL))
);
......
......@@ -73,6 +73,11 @@ module EE
private
override :project_setting_attributes
def project_setting_attributes
super + [:prevent_merge_without_jira_issue]
end
def project_params_ee
attrs = %i[
approvals_before_merge
......
......@@ -231,6 +231,11 @@ module EE
accepts_nested_attributes_for :compliance_framework_setting, update_only: true, allow_destroy: true
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)
end
end
class_methods do
......
......@@ -153,6 +153,7 @@ class License < ApplicationRecord
insights
issuable_health_status
jira_vulnerabilities_integration
jira_issue_association_enforcement
license_scanning
personal_access_token_expiration_policy
project_activity_analytics
......
- project = local_assigns.fetch(:project)
- if project.jira_issue_association_required_to_merge_enabled?
.form-check.gl-mb-3
= form.fields_for :project_setting do |settings|
= settings.check_box :prevent_merge_without_jira_issue, class: 'form-check-input'
= settings.label :prevent_merge_without_jira_issue, class: 'form-check-label' do
= s_('ProjectSettings|Require an associated issue from Jira')
---
name: jira_issue_association_on_merge_request
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/52896
rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/300271
milestone: '13.9'
type: development
group: group::compliance
default_enabled: false
......@@ -56,6 +56,28 @@ RSpec.describe Project do
it { is_expected.to have_many(:incident_management_oncall_schedules).class_name('IncidentManagement::OncallSchedule') }
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
end
before do
stub_licensed_features(jira_issue_association_enforcement: licensed)
stub_feature_flags(jira_issue_association_on_merge_request: feature_flag)
end
with_them do
it 'returns the correct value' do
expect(project.jira_issue_association_required_to_merge_enabled?).to eq(result)
end
end
end
describe 'approval_rules association' do
let_it_be(:rule, reload: true) { create(:approval_project_rule) }
let(:project) { rule.project }
......
......@@ -23061,6 +23061,9 @@ msgstr ""
msgid "ProjectSettings|Require"
msgstr ""
msgid "ProjectSettings|Require an associated issue from Jira"
msgstr ""
msgid "ProjectSettings|Requirements"
msgstr ""
......
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