diff --git a/config/feature_flags/wip/epic_creation_with_synced_work_item.yml b/config/feature_flags/wip/sync_epic_to_work_item.yml similarity index 82% rename from config/feature_flags/wip/epic_creation_with_synced_work_item.yml rename to config/feature_flags/wip/sync_epic_to_work_item.yml index 2083ca694d161d8f53d1bedde0a8070fae40ed23..cf3f6455b7e00f651e48f62c7284cb78100959e8 100644 --- a/config/feature_flags/wip/epic_creation_with_synced_work_item.yml +++ b/config/feature_flags/wip/sync_epic_to_work_item.yml @@ -1,5 +1,5 @@ --- -name: epic_creation_with_synced_work_item +name: sync_epic_to_work_item feature_issue_url: introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/140232 rollout_issue_url: diff --git a/ee/app/models/ee/group.rb b/ee/app/models/ee/group.rb index c9065c0933ea42cec64c0ebc33ac3d98f5dd6753..ec0f0bd3802977dd07ee88ebf249f3647aac0340 100644 --- a/ee/app/models/ee/group.rb +++ b/ee/app/models/ee/group.rb @@ -248,8 +248,8 @@ def service_accounts provisioned_users.service_account end - def epic_synced_with_work_item_enabled? - ::Feature.enabled?(:epic_creation_with_synced_work_item, self, type: :wip) + def epic_sync_to_work_item_enabled? + ::Feature.enabled?(:sync_epic_to_work_item, self, type: :wip) end end diff --git a/ee/app/services/concerns/epics/sync_as_work_item.rb b/ee/app/services/concerns/epics/sync_as_work_item.rb index 0cc09dd1ef49dd10bf3162cd26a6e08cfbbcba68..9a334c4744710cf0167d969ecf946cfa94f49051 100644 --- a/ee/app/services/concerns/epics/sync_as_work_item.rb +++ b/ee/app/services/concerns/epics/sync_as_work_item.rb @@ -12,7 +12,7 @@ module SyncAsWorkItem ].freeze def create_work_item_for! - return unless work_item_sync_enabled? + return unless group.epic_sync_to_work_item_enabled? service_response = ::WorkItems::CreateService.new( container: group, @@ -27,7 +27,7 @@ def create_work_item_for! end def update_work_item_for!(epic) - return true unless work_item_sync_enabled? + return true unless group.epic_sync_to_work_item_enabled? return true unless epic.work_item service_response = ::WorkItems::UpdateService.new( @@ -83,10 +83,6 @@ def handle_response!(action, service_response, epic = nil) raise SyncAsWorkItemError, error_message.join(", ") end - def work_item_sync_enabled? - ::Feature.enabled?(:epic_creation_with_synced_work_item, group, type: :wip) - end - def extract_widget_params work_item_type = WorkItems::Type.default_by_type(:epic) diff --git a/ee/app/services/epic_issues/create_service.rb b/ee/app/services/epic_issues/create_service.rb index 9321f2407f27fd6d175e2fdb62ba4bf961c0d946..bef005a834e103361e5fe594495dee2bd3509b75 100644 --- a/ee/app/services/epic_issues/create_service.rb +++ b/ee/app/services/epic_issues/create_service.rb @@ -74,7 +74,7 @@ def schedule_new_link_worker(link, referenced_issue, params) end def sync_work_item_link!(epic_issue_link) - if issuable.group.epic_synced_with_work_item_enabled? && issuable.work_item + if issuable.group.epic_sync_to_work_item_enabled? && issuable.work_item create_synced_work_item_link!(epic_issue_link) else delete_synced_work_item_link!(epic_issue_link) diff --git a/ee/app/services/epics/base_service.rb b/ee/app/services/epics/base_service.rb index 45223e433d4fda8387db75791536033d4163ce3f..5c8ad06efc05bbd132a739c60974a5d0aa2ec3e1 100644 --- a/ee/app/services/epics/base_service.rb +++ b/ee/app/services/epics/base_service.rb @@ -160,9 +160,5 @@ def log_audit_event(epic, event_type, message) ::Gitlab::Audit::Auditor.audit(audit_context) end - - def sync_as_work_item?(group) - ::Feature.enabled?(:epic_creation_with_synced_work_item, group, type: :wip) - end end end diff --git a/ee/app/services/epics/close_service.rb b/ee/app/services/epics/close_service.rb index 4d614e50aff2fad59b1ebcd3a7bc69a33250d503..82ab792eb3edd27f0ce0db92e32337df5f0e9247 100644 --- a/ee/app/services/epics/close_service.rb +++ b/ee/app/services/epics/close_service.rb @@ -11,7 +11,7 @@ def execute(epic) private def close_epic(epic) - work_item = epic.work_item if sync_as_work_item?(epic.group) && epic.work_item + work_item = epic.work_item if epic.group.epic_sync_to_work_item_enabled? && epic.work_item ApplicationRecord.transaction do epic.close! diff --git a/ee/app/services/epics/create_service.rb b/ee/app/services/epics/create_service.rb index b26bc2d8a34f9c16996a53e33c513d123df43028..77f9e508ba3278a96d137f79bf78116155688485 100644 --- a/ee/app/services/epics/create_service.rb +++ b/ee/app/services/epics/create_service.rb @@ -23,7 +23,7 @@ def execute def transaction_create(epic) return super unless epic.valid? - work_item = create_work_item_for! if work_item_sync_enabled? + work_item = create_work_item_for! if epic.group.epic_sync_to_work_item_enabled? if work_item epic.issue_id = work_item.id epic.iid = work_item.iid diff --git a/ee/app/services/epics/epic_links/create_service.rb b/ee/app/services/epics/epic_links/create_service.rb index d6013fadc1a82583a0ecb13e93c51945f234f1f8..a3b7d08b5ef7f2ab049ef996899ea03b9e275650 100644 --- a/ee/app/services/epics/epic_links/create_service.rb +++ b/ee/app/services/epics/epic_links/create_service.rb @@ -119,7 +119,7 @@ def can_link_epic?(epic) end def create_synced_work_item_link!(child_epic) - return true unless issuable.group.epic_synced_with_work_item_enabled? + return true unless issuable.group.epic_sync_to_work_item_enabled? return true unless issuable.work_item && child_epic.work_item response = ::WorkItems::ParentLinks::CreateService diff --git a/ee/app/services/epics/issue_promote_service.rb b/ee/app/services/epics/issue_promote_service.rb index 29df4eb9a01048602aa3ede69131b8952a483ab9..6bcf89827797bb567379ecd3684e90ac7eead617 100644 --- a/ee/app/services/epics/issue_promote_service.rb +++ b/ee/app/services/epics/issue_promote_service.rb @@ -54,7 +54,7 @@ def update_old_entity def update_new_entity_description super - return unless ::Feature.enabled?(:epic_creation_with_synced_work_item, parent_group, type: :wip) + return unless parent_group.epic_sync_to_work_item_enabled? return unless new_entity.work_item new_entity.work_item.update!(description: new_entity.description, description_html: new_entity.description_html) diff --git a/ee/app/services/epics/related_epic_links/create_service.rb b/ee/app/services/epics/related_epic_links/create_service.rb index a0322b83b43aedfbc9344e675044ad57a92a98aa..b02c0bc31ab69f12111ce2ecc418793e422f468b 100644 --- a/ee/app/services/epics/related_epic_links/create_service.rb +++ b/ee/app/services/epics/related_epic_links/create_service.rb @@ -76,7 +76,7 @@ def create_synced_work_item_links! end def sync_to_work_item? - issuable.group.epic_synced_with_work_item_enabled? && + issuable.group.epic_sync_to_work_item_enabled? && issuable.work_item && referenced_issuables.any?(&:issue_id) end diff --git a/ee/app/services/epics/reopen_service.rb b/ee/app/services/epics/reopen_service.rb index 8187fb89fddec77a4aa868be6202eb5fcd4ab89e..63901ea3abe17a1ee3ef083c6aaf525c53ba96d3 100644 --- a/ee/app/services/epics/reopen_service.rb +++ b/ee/app/services/epics/reopen_service.rb @@ -11,7 +11,7 @@ def execute(epic) private def reopen_epic(epic) - work_item = epic.work_item if sync_as_work_item?(epic.group) && epic.work_item + work_item = epic.work_item if epic.group.epic_sync_to_work_item_enabled? && epic.work_item ApplicationRecord.transaction do epic.reopen! diff --git a/ee/spec/models/ee/group_spec.rb b/ee/spec/models/ee/group_spec.rb index 3c338135147638fd5ae6a119e509f3636e4c0ad7..008c512abcca98f25f57af763c234b88bb550ba6 100644 --- a/ee/spec/models/ee/group_spec.rb +++ b/ee/spec/models/ee/group_spec.rb @@ -3568,14 +3568,14 @@ def webhook_headers end end - describe '#epic_synced_with_work_item_enabled?' do - subject { group.epic_synced_with_work_item_enabled? } + describe '#epic_sync_to_work_item_enabled?' do + subject { group.epic_sync_to_work_item_enabled? } it { is_expected.to be true } context 'when feature flag is disabled' do before do - stub_feature_flags(epic_creation_with_synced_work_item: false) + stub_feature_flags(sync_epic_to_work_item: false) end it { is_expected.to be false } diff --git a/ee/spec/services/epic_issues/create_service_spec.rb b/ee/spec/services/epic_issues/create_service_spec.rb index 34d121b074d29ee56800b57d0987feb67dfb011c..0bb974242ad011c89fb53d02fab91e8ec4950dac 100644 --- a/ee/spec/services/epic_issues/create_service_spec.rb +++ b/ee/spec/services/epic_issues/create_service_spec.rb @@ -250,9 +250,9 @@ def assign_issue(references) expect(WorkItem.find(issue.id).work_item_parent).to eq(another_epic.work_item) end - context 'when :epic_creation_with_synced_work_item FF is disabled' do + context 'when :sync_epic_to_work_item FF is disabled' do it 'deletes old parent link' do - stub_feature_flags(epic_creation_with_synced_work_item: false) + stub_feature_flags(sync_epic_to_work_item: false) expect { subject }.to change { WorkItems::ParentLink.count }.by(-1) expect(WorkItems::ParentLink.where(work_item_id: issue.id)).to be_empty @@ -328,9 +328,9 @@ def assign_issue(references) end end - context 'when epic_creation_with_synced_work_item feature flag is disabled' do + context 'when sync_epic_to_work_item feature flag is disabled' do before do - stub_feature_flags(epic_creation_with_synced_work_item: false) + stub_feature_flags(sync_epic_to_work_item: false) end it 'create relationship only for the epic' do diff --git a/ee/spec/services/epic_issues/destroy_service_spec.rb b/ee/spec/services/epic_issues/destroy_service_spec.rb index d4b09c83e520110c84ff6878a2e33b4ded30facc..0c8bcb8bf20eddbd2aa1467747f3ead2559142a0 100644 --- a/ee/spec/services/epic_issues/destroy_service_spec.rb +++ b/ee/spec/services/epic_issues/destroy_service_spec.rb @@ -117,7 +117,7 @@ context 'when feature flag is disabled' do before do - stub_feature_flags(epic_creation_with_synced_work_item: false) + stub_feature_flags(sync_epic_to_work_item: false) end it 'removes the epic and work item link' do diff --git a/ee/spec/services/epics/close_service_spec.rb b/ee/spec/services/epics/close_service_spec.rb index 9553c2fb1581564966d138150f018936f82f6208..9e2921af080b1b2910e1145c6f00c041381f141b 100644 --- a/ee/spec/services/epics/close_service_spec.rb +++ b/ee/spec/services/epics/close_service_spec.rb @@ -88,7 +88,7 @@ context 'when feature flag is disabled' do before do - stub_feature_flags(epic_creation_with_synced_work_item: false) + stub_feature_flags(sync_epic_to_work_item: false) end it 'does not change the work item' do diff --git a/ee/spec/services/epics/create_service_spec.rb b/ee/spec/services/epics/create_service_spec.rb index 866cbbf5276d78088467c9fa848298cf15ba5ec3..70010a243c528846f5f7597b15fe3e9fd69a33b9 100644 --- a/ee/spec/services/epics/create_service_spec.rb +++ b/ee/spec/services/epics/create_service_spec.rb @@ -168,9 +168,9 @@ end end - context 'when epic_creation_with_synced_work_item feature flag is disabled' do + context 'when sync_epic_to_work_item feature flag is disabled' do before do - stub_feature_flags(epic_creation_with_synced_work_item: false) + stub_feature_flags(sync_epic_to_work_item: false) end it 'does not create epic work item' do diff --git a/ee/spec/services/epics/epic_links/create_service_spec.rb b/ee/spec/services/epics/epic_links/create_service_spec.rb index 7bfaea2d8b28bca3a0adf14406b834e8254f7d1c..98d210538a7c9e1c9e3db51af9aadbad67c490ae 100644 --- a/ee/spec/services/epics/epic_links/create_service_spec.rb +++ b/ee/spec/services/epics/epic_links/create_service_spec.rb @@ -626,9 +626,9 @@ def add_epic(references) it_behaves_like 'rollback changes when creation fails' end - context 'when epic_creation_with_synced_work_item feature flag is disabled' do + context 'when sync_epic_to_work_item feature flag is disabled' do before do - stub_feature_flags(epic_creation_with_synced_work_item: false) + stub_feature_flags(sync_epic_to_work_item: false) end it 'create relationship only for the epic' do diff --git a/ee/spec/services/epics/epic_links/destroy_service_spec.rb b/ee/spec/services/epics/epic_links/destroy_service_spec.rb index e770d8131cab3cb717f4804c99e2c7927e259c26..9872016461bf3f2cad8950b8affc60e67a690874 100644 --- a/ee/spec/services/epics/epic_links/destroy_service_spec.rb +++ b/ee/spec/services/epics/epic_links/destroy_service_spec.rb @@ -189,9 +189,9 @@ def remove_epic_relation(child_epic) end end - context 'when epic_creation_with_synced_work_item feature flag is disabled' do + context 'when sync_epic_to_work_item feature flag is disabled' do before do - stub_feature_flags(epic_creation_with_synced_work_item: false) + stub_feature_flags(sync_epic_to_work_item: false) end it 'removes epic relationship and destroy work item parent link' do diff --git a/ee/spec/services/epics/issue_promote_service_spec.rb b/ee/spec/services/epics/issue_promote_service_spec.rb index 7b11f3f14c9051f9af25c4027ba73a612cdf2e1f..8b3ccd6bfcc8142f8ad43ba0602b25625d03a1b6 100644 --- a/ee/spec/services/epics/issue_promote_service_spec.rb +++ b/ee/spec/services/epics/issue_promote_service_spec.rb @@ -389,7 +389,7 @@ context 'when feature flag is enabled' do before do - stub_feature_flags(epic_creation_with_synced_work_item: group) + stub_feature_flags(sync_epic_to_work_item: group) end it_behaves_like 'syncs all data from an epic to a work item' do @@ -399,7 +399,7 @@ context 'when feature flag is disabled' do before do - stub_feature_flags(epic_creation_with_synced_work_item: false) + stub_feature_flags(sync_epic_to_work_item: false) end it 'does not create a synced work item for the epic' do diff --git a/ee/spec/services/epics/related_epic_links/create_service_spec.rb b/ee/spec/services/epics/related_epic_links/create_service_spec.rb index 8ef5021b976d4be12f3023f79d13f91257410355..26fc90eab0579cf75cac9121f0fdf431cec09795 100644 --- a/ee/spec/services/epics/related_epic_links/create_service_spec.rb +++ b/ee/spec/services/epics/related_epic_links/create_service_spec.rb @@ -131,7 +131,7 @@ context 'when feature flag is disabled' do before do - stub_feature_flags(epic_creation_with_synced_work_item: false) + stub_feature_flags(sync_epic_to_work_item: false) end it_behaves_like 'only creates an epic link' @@ -139,7 +139,7 @@ context 'when feature flag is enabled' do before do - stub_feature_flags(epic_creation_with_synced_work_item: group) + stub_feature_flags(sync_epic_to_work_item: group) end it_behaves_like 'syncs all data from an epic to a work item' do diff --git a/ee/spec/services/epics/related_epic_links/destroy_service_spec.rb b/ee/spec/services/epics/related_epic_links/destroy_service_spec.rb index 958b9177141574f0653a8bcb70e3eb8f5f735e9d..5210cc981b01f757efde9ae7aa625557f50c1f68 100644 --- a/ee/spec/services/epics/related_epic_links/destroy_service_spec.rb +++ b/ee/spec/services/epics/related_epic_links/destroy_service_spec.rb @@ -34,7 +34,7 @@ context 'when feature flag is disabled' do before do - stub_feature_flags(epic_creation_with_synced_work_item: false) + stub_feature_flags(sync_epic_to_work_item: false) end it 'removes the epic and the work item relation' do @@ -45,7 +45,7 @@ context 'when feature flag is enabled' do before do - stub_feature_flags(epic_creation_with_synced_work_item: group) + stub_feature_flags(sync_epic_to_work_item: group) end context 'when epic is the source' do diff --git a/ee/spec/services/epics/reopen_service_spec.rb b/ee/spec/services/epics/reopen_service_spec.rb index d501e654024ae46b4aadfb25bcb95e3446c68c3f..990783c8db9b34a4bf6872b44ef493e678df646b 100644 --- a/ee/spec/services/epics/reopen_service_spec.rb +++ b/ee/spec/services/epics/reopen_service_spec.rb @@ -118,7 +118,7 @@ context 'when feature flag is disabled' do before do - stub_feature_flags(epic_creation_with_synced_work_item: false) + stub_feature_flags(sync_epic_to_work_item: false) end it 'does not change the work item' do diff --git a/ee/spec/services/epics/update_service_spec.rb b/ee/spec/services/epics/update_service_spec.rb index 4dc011deae11b7b64896e0f5ae309e8a59b406e2..9c19066086a2d6f1033788751d2098dbee94e87b 100644 --- a/ee/spec/services/epics/update_service_spec.rb +++ b/ee/spec/services/epics/update_service_spec.rb @@ -966,7 +966,7 @@ def update_issuable(update_params) context 'when feature flag is disabled' do before do - stub_feature_flags(epic_creation_with_synced_work_item: false) + stub_feature_flags(sync_epic_to_work_item: false) end it 'does not propagate changes' do @@ -1003,7 +1003,7 @@ def update_issuable(update_params) context 'when feature flag is disabled' do before do - stub_feature_flags(epic_creation_with_synced_work_item: false) + stub_feature_flags(sync_epic_to_work_item: false) end it 'does not propagate changes' do