From a06e8e81cc9bc444c7eef92373fcd4da4128c4b8 Mon Sep 17 00:00:00 2001 From: Piotr Skorupa Date: Thu, 11 May 2023 01:17:14 +0200 Subject: [PATCH 1/2] Add description_diffs to Registration Features This adds description_diffs feature to the Registration Features program. This feature will be enabled when Service Ping is enabled on self-managed free plans as an incentive. Changelog: changed --- .../admin_area/settings/usage_statistics.md | 1 + .../models/gitlab_subscriptions/features.rb | 2 +- .../api/graphql/project/work_items_spec.rb | 9 ++++++++ ee/spec/serializers/ee/note_entity_spec.rb | 13 +++++++++++ ...escription_diff_actions_shared_examples.rb | 23 +++++++++++++++---- 5 files changed, 42 insertions(+), 6 deletions(-) diff --git a/doc/user/admin_area/settings/usage_statistics.md b/doc/user/admin_area/settings/usage_statistics.md index 64bec01b765c3f..e952c22bf91655 100644 --- a/doc/user/admin_area/settings/usage_statistics.md +++ b/doc/user/admin_area/settings/usage_statistics.md @@ -52,6 +52,7 @@ tier. Users can continue to access the features in a paid tier without sharing u ### Features available in 16.0 and later +- [View description change history](../../../user/discussions/index.md#view-description-change-history). - [Maintenance mode](../../../administration/maintenance_mode/index.md). - [Configurable issue boards](../../project/issue_board.md#configurable-issue-boards). - [Coverage-guided fuzz testing](../../application_security/coverage_fuzzing/index.md). diff --git a/ee/app/models/gitlab_subscriptions/features.rb b/ee/app/models/gitlab_subscriptions/features.rb index 8c2e7884f56471..3ae84bc2070196 100644 --- a/ee/app/models/gitlab_subscriptions/features.rb +++ b/ee/app/models/gitlab_subscriptions/features.rb @@ -48,7 +48,6 @@ class Features code_owners code_review_analytics contribution_analytics - description_diffs elastic_search full_codequality_report group_activity_analytics @@ -256,6 +255,7 @@ class Features ].freeze STARTER_FEATURES_WITH_USAGE_PING = %i[ + description_diffs send_emails_from_admin_area repository_size_limit maintenance_mode diff --git a/ee/spec/requests/api/graphql/project/work_items_spec.rb b/ee/spec/requests/api/graphql/project/work_items_spec.rb index 20e9a4b75f6b97..0ddde876e76f0b 100644 --- a/ee/spec/requests/api/graphql/project/work_items_spec.rb +++ b/ee/spec/requests/api/graphql/project/work_items_spec.rb @@ -311,6 +311,15 @@ it_behaves_like 'description change diff', description_diffs_enabled: false end + + context 'with description_diffs enabled through Registration Features' do + before do + stub_licensed_features(description_diffs: false) + stub_application_setting(usage_ping_features_enabled: true) + end + + it_behaves_like 'description change diff', description_diffs_enabled: true + end end end diff --git a/ee/spec/serializers/ee/note_entity_spec.rb b/ee/spec/serializers/ee/note_entity_spec.rb index dabfb59f5e6bc4..e53f9bbf910f14 100644 --- a/ee/spec/serializers/ee/note_entity_spec.rb +++ b/ee/spec/serializers/ee/note_entity_spec.rb @@ -27,6 +27,19 @@ end end + context 'when description_diffs feature is available through Registration Features' do + before do + stub_application_setting(usage_ping_features_enabled: true) + end + + it 'includes description versions attributes' do + expect(subject[:description_version_id]).to eq(description_version.id) + expect(subject[:description_diff_path]).to eq(description_diff_project_issue_path(issue.project, issue, description_version.id)) + expect(subject[:delete_description_version_path]).to eq(delete_description_version_project_issue_path(issue.project, issue, description_version.id)) + expect(subject[:can_delete_description_version]).to eq(true) + end + end + context 'when description_diffs license is not available' do before do stub_licensed_features(description_diffs: false) diff --git a/ee/spec/support/shared_examples/controllers/concerns/description_diff_actions_shared_examples.rb b/ee/spec/support/shared_examples/controllers/concerns/description_diff_actions_shared_examples.rb index 1830c15cd25408..b42a0cad5e6f25 100644 --- a/ee/spec/support/shared_examples/controllers/concerns/description_diff_actions_shared_examples.rb +++ b/ee/spec/support/shared_examples/controllers/concerns/description_diff_actions_shared_examples.rb @@ -16,11 +16,7 @@ def delete_description_version(extra_params = {}) delete :delete_description_version, params: base_params.merge(extra_params) end - context 'when license is available' do - before do - stub_licensed_features(epics: true, description_diffs: true) - end - + shared_examples 'description diff actions' do context 'GET description_diff' do it 'returns the diff with the previous version' do expect(Gitlab::Diff::CharDiff).to receive(:new).with(version_2.description, version_3.description).and_call_original @@ -129,6 +125,23 @@ def delete_description_version(extra_params = {}) end end + context 'when license is available' do + before do + stub_licensed_features(epics: true, description_diffs: true) + end + + it_behaves_like 'description diff actions' + end + + context 'when features are available through Registration Features' do + before do + stub_application_setting(usage_ping_features_enabled: true) + stub_licensed_features(epics: true) + end + + it_behaves_like 'description diff actions' + end + context 'when license is not available' do before do stub_licensed_features(epics: true, description_diffs: false) -- GitLab From d1d745fb26cfb8e5407aa27c83079096d2275d7a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miko=C5=82aj=20Wawrzyniak?= Date: Thu, 11 May 2023 09:56:13 +0000 Subject: [PATCH 2/2] Add explicitly stubbing description_diffs in specs --- ee/spec/serializers/ee/note_entity_spec.rb | 1 + .../concerns/description_diff_actions_shared_examples.rb | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/ee/spec/serializers/ee/note_entity_spec.rb b/ee/spec/serializers/ee/note_entity_spec.rb index e53f9bbf910f14..4667442b300eb7 100644 --- a/ee/spec/serializers/ee/note_entity_spec.rb +++ b/ee/spec/serializers/ee/note_entity_spec.rb @@ -30,6 +30,7 @@ context 'when description_diffs feature is available through Registration Features' do before do stub_application_setting(usage_ping_features_enabled: true) + stub_licensed_features(description_diffs: false) end it 'includes description versions attributes' do diff --git a/ee/spec/support/shared_examples/controllers/concerns/description_diff_actions_shared_examples.rb b/ee/spec/support/shared_examples/controllers/concerns/description_diff_actions_shared_examples.rb index b42a0cad5e6f25..0636d73f2645e9 100644 --- a/ee/spec/support/shared_examples/controllers/concerns/description_diff_actions_shared_examples.rb +++ b/ee/spec/support/shared_examples/controllers/concerns/description_diff_actions_shared_examples.rb @@ -136,7 +136,7 @@ def delete_description_version(extra_params = {}) context 'when features are available through Registration Features' do before do stub_application_setting(usage_ping_features_enabled: true) - stub_licensed_features(epics: true) + stub_licensed_features(epics: true, description_diffs: false) end it_behaves_like 'description diff actions' -- GitLab