Skip to content
Snippets Groups Projects
Verified Commit 7f0c8ee7 authored by Lee Tickett's avatar Lee Tickett :red_circle: Committed by GitLab
Browse files

Merge branch '2256-auto-enable-crm' into 'master'

Enable CRM by default for new groups

See merge request !108378



Merged-by: default avatarLee Tickett <ltickett@gitlab.com>
Approved-by: default avatarMax Orefice <morefice@gitlab.com>
Reviewed-by: default avatarMax Orefice <morefice@gitlab.com>
Reviewed-by: default avatarEulyeon Ko <5961404-euko@users.noreply.gitlab.com>
parents 29987dc9 8a3458ec
No related branches found
No related tags found
No related merge requests found
Pipeline #1166885838 failed
Pipeline: E2E Omnibus GitLab EE

#1166931611

    Pipeline: GitLab

    #1166893099

      Pipeline: E2E GDK

      #1166892582

        +1
        Showing
        with 52 additions and 51 deletions
        ...@@ -854,7 +854,7 @@ def group_feature ...@@ -854,7 +854,7 @@ def group_feature
        end end
        def crm_enabled? def crm_enabled?
        crm_settings&.enabled? crm_settings.nil? || crm_settings.enabled?
        end end
        def shared_with_group_links_visible_to_user(user) def shared_with_group_links_visible_to_user(user)
        ......
        # frozen_string_literal: true
        class ChangeGroupCrmSettingsEnabledDefault < Gitlab::Database::Migration[2.1]
        def change
        change_column_default(:group_crm_settings, :enabled, from: false, to: true)
        end
        end
        2513a093d556b741729fc6e6015f78d5f309e4deae25f7ba379e04553e7d71f2
        \ No newline at end of file
        ...@@ -17710,7 +17710,7 @@ CREATE TABLE group_crm_settings ( ...@@ -17710,7 +17710,7 @@ CREATE TABLE group_crm_settings (
        group_id bigint NOT NULL, group_id bigint NOT NULL,
        created_at timestamp with time zone NOT NULL, created_at timestamp with time zone NOT NULL,
        updated_at timestamp with time zone NOT NULL, updated_at timestamp with time zone NOT NULL,
        enabled boolean DEFAULT false NOT NULL enabled boolean DEFAULT true NOT NULL
        ); );
           
        CREATE SEQUENCE group_crm_settings_group_id_seq CREATE SEQUENCE group_crm_settings_group_id_seq
        ...@@ -34,9 +34,11 @@ For more information about what is planned for the future, see [issue 2256](http ...@@ -34,9 +34,11 @@ For more information about what is planned for the future, see [issue 2256](http
        ## Enable customer relations management (CRM) ## Enable customer relations management (CRM)
        Customer relations management features must be enabled at the group level. If your > - [Enabled by default](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/108378) in GitLab 15.8.
        Customer relations management features are enabled at the group level. If your
        group also contains subgroups, and you want to use CRM features in the subgroup, group also contains subgroups, and you want to use CRM features in the subgroup,
        you must enable CRM features for the subgroup. CRM features must also be enabled for the subgroup.
        To enable customer relations management in a group or subgroup: To enable customer relations management in a group or subgroup:
        ......
        ...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
        include_context 'group navbar structure' include_context 'group navbar structure'
        let_it_be(:user) { create(:user) } let_it_be(:user) { create(:user) }
        let_it_be(:group) { create(:group) } let_it_be(:group) { create(:group, :crm_disabled) }
        context 'for maintainers' do context 'for maintainers' do
        before do before do
        ...@@ -121,8 +121,8 @@ ...@@ -121,8 +121,8 @@
        it_behaves_like 'verified navigation bar' it_behaves_like 'verified navigation bar'
        end end
        context 'when customer relations feature is enabled' do context 'when crm feature is enabled' do
        let(:group) { create(:group, :crm_enabled) } let(:group) { create(:group) }
        before do before do
        insert_customer_relations_nav(_('Iterations')) insert_customer_relations_nav(_('Iterations'))
        ...@@ -133,8 +133,8 @@ ...@@ -133,8 +133,8 @@
        it_behaves_like 'verified navigation bar' it_behaves_like 'verified navigation bar'
        end end
        context 'when customer relations feature enabled but subgroup' do context 'when crm feature enabled but subgroup' do
        let(:group) { create(:group, :crm_enabled, parent: create(:group)) } let(:group) { create(:group, parent: create(:group)) }
        before do before do
        visit group_path(group) visit group_path(group)
        ......
        ...@@ -2541,7 +2541,7 @@ def set_access_level(access_level) ...@@ -2541,7 +2541,7 @@ def set_access_level(access_level)
        end end
        context 'with a public group' do context 'with a public group' do
        let_it_be(:public_group) { create(:group, :public, :crm_enabled) } let_it_be(:public_group) { create(:group, :public) }
        subject { described_class.new(user, public_group) } subject { described_class.new(user, public_group) }
        ......
        ...@@ -296,11 +296,7 @@ def members_by_username(username) ...@@ -296,11 +296,7 @@ def members_by_username(username)
        end end
        context 'when feature flag is enabled' do context 'when feature flag is enabled' do
        context 'when a group has contact relations enabled' do context 'when a group has crm enabled' do
        before do
        create(:crm_settings, group: group, enabled: true)
        end
        context 'when a user can read contacts' do context 'when a user can read contacts' do
        it 'lists contacts' do it 'lists contacts' do
        group.add_developer(user) group.add_developer(user)
        ...@@ -321,7 +317,11 @@ def members_by_username(username) ...@@ -321,7 +317,11 @@ def members_by_username(username)
        end end
        end end
        context 'when a group has contact relations disabled' do context 'when a group has crm disabled' do
        before do
        create(:crm_settings, group: group, enabled: false)
        end
        it 'renders 404' do it 'renders 404' do
        group.add_developer(user) group.add_developer(user)
        ......
        ...@@ -113,9 +113,9 @@ def create_graph(parent: nil, children: 4, depth: 4) ...@@ -113,9 +113,9 @@ def create_graph(parent: nil, children: 4, depth: 4)
        end end
        end end
        trait :crm_enabled do trait :crm_disabled do
        after(:create) do |group| after(:create) do |group|
        create(:crm_settings, group: group, enabled: true) create(:crm_settings, group: group, enabled: false)
        end end
        end end
        ......
        ...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
        RSpec.describe 'Create a CRM contact', :js, feature_category: :service_desk do RSpec.describe 'Create a CRM contact', :js, feature_category: :service_desk do
        let(:user) { create(:user) } let(:user) { create(:user) }
        let(:group) { create(:group, :crm_enabled) } let(:group) { create(:group) }
        let!(:crm_organization) { create(:crm_organization, group: group, name: 'GitLab') } let!(:crm_organization) { create(:crm_organization, group: group, name: 'GitLab') }
        before do before do
        ......
        ...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
        include ExternalAuthorizationServiceHelpers include ExternalAuthorizationServiceHelpers
        let(:user) { create(:user) } let(:user) { create(:user) }
        let(:group) { create(:group) } let(:group) { create(:group, :crm_disabled) }
        before do before do
        sign_in user sign_in user
        ......
        ...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
        create_package_nav(_('Operate')) create_package_nav(_('Operate'))
        insert_after_nav_item(_('Analyze'), new_nav_item: settings_for_maintainer_nav_item) if Gitlab.ee? insert_after_nav_item(_('Analyze'), new_nav_item: settings_for_maintainer_nav_item) if Gitlab.ee?
        insert_infrastructure_registry_nav(_('Kubernetes')) insert_infrastructure_registry_nav(_('Kubernetes'))
        insert_customer_relations_nav(Gitlab.ee? ? _('Iterations') : _('Milestones')) if group.crm_enabled?
        stub_config(dependency_proxy: { enabled: false }) stub_config(dependency_proxy: { enabled: false })
        stub_config(registry: { enabled: false }) stub_config(registry: { enabled: false })
        ...@@ -42,24 +43,14 @@ ...@@ -42,24 +43,14 @@
        it_behaves_like 'verified navigation bar' it_behaves_like 'verified navigation bar'
        end end
        context 'when customer_relations feature is enabled' do context 'when crm feature is disabled' do
        let(:group) { create(:group, :crm_enabled) } let(:group) { create(:group, :crm_disabled) }
        before do
        if Gitlab.ee?
        insert_customer_relations_nav(_('Iterations'))
        else
        insert_customer_relations_nav(_('Milestones'))
        end
        visit group_path(group)
        end
        it_behaves_like 'verified navigation bar' it_behaves_like 'verified navigation bar'
        end end
        context 'when customer_relations feature is enabled but subgroup' do context 'when crm feature is enabled but subgroup' do
        let(:group) { create(:group, :crm_enabled, parent: create(:group)) } let(:group) { create(:group, parent: create(:group)) }
        before do before do
        visit group_path(group) visit group_path(group)
        ......
        ...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
        let_it_be(:user) { create(:user, name: '💃speciąl someone💃', username: 'someone.special') } let_it_be(:user) { create(:user, name: '💃speciąl someone💃', username: 'someone.special') }
        let_it_be(:user2) { create(:user, name: 'Marge Simpson', username: 'msimpson') } let_it_be(:user2) { create(:user, name: 'Marge Simpson', username: 'msimpson') }
        let_it_be(:group) { create(:group, :crm_enabled) } let_it_be(:group) { create(:group) }
        let_it_be(:project) { create(:project, group: group) } let_it_be(:project) { create(:project, group: group) }
        let_it_be(:issue) { create(:issue, project: project, assignees: [user]) } let_it_be(:issue) { create(:issue, project: project, assignees: [user]) }
        let_it_be(:label) { create(:label, project: project, title: 'special+') } let_it_be(:label) { create(:label, project: project, title: 'special+') }
        ......
        ...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
        subject { described_class.new(user, group: group).execute } subject { described_class.new(user, group: group).execute }
        context 'when customer relations feature is enabled for the group' do context 'when customer relations feature is enabled for the group' do
        let_it_be(:root_group) { create(:group, :crm_enabled) } let_it_be(:root_group) { create(:group) }
        let_it_be(:group) { create(:group, parent: root_group) } let_it_be(:group) { create(:group, parent: root_group) }
        let_it_be(:contact_1) { create(:contact, group: root_group) } let_it_be(:contact_1) { create(:contact, group: root_group) }
        ...@@ -44,8 +44,8 @@ ...@@ -44,8 +44,8 @@
        end end
        end end
        context 'when customer relations feature is disabled for the group' do context 'when crm feature is disabled for the group' do
        let_it_be(:group) { create(:group) } let_it_be(:group) { create(:group, :crm_disabled) }
        let_it_be(:contact) { create(:contact, group: group) } let_it_be(:contact) { create(:contact, group: group) }
        before do before do
        ...@@ -58,7 +58,7 @@ ...@@ -58,7 +58,7 @@
        end end
        context 'with search informations' do context 'with search informations' do
        let_it_be(:search_test_group) { create(:group, :crm_enabled) } let_it_be(:search_test_group) { create(:group) }
        let_it_be(:search_test_a) do let_it_be(:search_test_a) do
        create( create(
        ...@@ -189,7 +189,7 @@ ...@@ -189,7 +189,7 @@
        end end
        describe '.counts_by_state' do describe '.counts_by_state' do
        let_it_be(:group) { create(:group, :crm_enabled) } let_it_be(:group) { create(:group) }
        let_it_be(:active_contacts) { create_list(:contact, 3, group: group, state: :active) } let_it_be(:active_contacts) { create_list(:contact, 3, group: group, state: :active) }
        let_it_be(:inactive_contacts) { create_list(:contact, 2, group: group, state: :inactive) } let_it_be(:inactive_contacts) { create_list(:contact, 2, group: group, state: :inactive) }
        ......
        ...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
        subject { described_class.new(user, group: group).execute } subject { described_class.new(user, group: group).execute }
        context 'when customer relations feature is enabled for the group' do context 'when customer relations feature is enabled for the group' do
        let_it_be(:root_group) { create(:group, :crm_enabled) } let_it_be(:root_group) { create(:group) }
        let_it_be(:group) { create(:group, parent: root_group) } let_it_be(:group) { create(:group, parent: root_group) }
        let_it_be(:crm_organization_1) { create(:crm_organization, group: root_group) } let_it_be(:crm_organization_1) { create(:crm_organization, group: root_group) }
        ...@@ -45,7 +45,7 @@ ...@@ -45,7 +45,7 @@
        end end
        context 'when customer relations feature is disabled for the group' do context 'when customer relations feature is disabled for the group' do
        let_it_be(:group) { create(:group) } let_it_be(:group) { create(:group, :crm_disabled) }
        let_it_be(:crm_organization) { create(:crm_organization, group: group) } let_it_be(:crm_organization) { create(:crm_organization, group: group) }
        before do before do
        ...@@ -58,7 +58,7 @@ ...@@ -58,7 +58,7 @@
        end end
        context 'with search informations' do context 'with search informations' do
        let_it_be(:search_test_group) { create(:group, :crm_enabled) } let_it_be(:search_test_group) { create(:group) }
        let_it_be(:search_test_a) do let_it_be(:search_test_a) do
        create( create(
        ...@@ -130,7 +130,7 @@ ...@@ -130,7 +130,7 @@
        end end
        context 'when sorting' do context 'when sorting' do
        let_it_be(:group) { create(:group, :crm_enabled) } let_it_be(:group) { create(:group) }
        let_it_be(:sort_test_a) do let_it_be(:sort_test_a) do
        create( create(
        ...@@ -185,7 +185,7 @@ ...@@ -185,7 +185,7 @@
        end end
        describe '.counts_by_state' do describe '.counts_by_state' do
        let_it_be(:group) { create(:group, :crm_enabled) } let_it_be(:group) { create(:group) }
        let_it_be(:active_crm_organizations) { create_list(:crm_organization, 3, group: group, state: :active) } let_it_be(:active_crm_organizations) { create_list(:crm_organization, 3, group: group, state: :active) }
        let_it_be(:inactive_crm_organizations) { create_list(:crm_organization, 2, group: group, state: :inactive) } let_it_be(:inactive_crm_organizations) { create_list(:crm_organization, 2, group: group, state: :inactive) }
        ......
        ...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
        let_it_be(:user) { create(:user) } let_it_be(:user) { create(:user) }
        let(:group) { create(:group, :crm_enabled) } let(:group) { create(:group) }
        let(:not_found_or_does_not_belong) { 'The specified organization was not found or does not belong to this group' } let(:not_found_or_does_not_belong) { 'The specified organization was not found or does not belong to this group' }
        let(:valid_params) do let(:valid_params) do
        attributes_for(:contact, attributes_for(:contact,
        ...@@ -41,7 +41,7 @@ ...@@ -41,7 +41,7 @@
        end end
        context 'when crm_enabled is false' do context 'when crm_enabled is false' do
        let(:group) { create(:group) } let(:group) { create(:group, :crm_disabled) }
        it 'raises an error' do it 'raises an error' do
        expect { resolve_mutation }.to raise_error(Gitlab::Graphql::Errors::ResourceNotAvailable) expect { resolve_mutation }.to raise_error(Gitlab::Graphql::Errors::ResourceNotAvailable)
        ......
        ...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
        RSpec.describe Mutations::CustomerRelations::Contacts::Update do RSpec.describe Mutations::CustomerRelations::Contacts::Update do
        let_it_be(:user) { create(:user) } let_it_be(:user) { create(:user) }
        let_it_be(:group) { create(:group, :crm_enabled) } let_it_be(:group) { create(:group) }
        let(:first_name) { 'Lionel' } let(:first_name) { 'Lionel' }
        let(:last_name) { 'Smith' } let(:last_name) { 'Smith' }
        ......
        ...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
        RSpec.describe Mutations::CustomerRelations::Organizations::Create do RSpec.describe Mutations::CustomerRelations::Organizations::Create do
        let_it_be(:user) { create(:user) } let_it_be(:user) { create(:user) }
        let_it_be(:group) { create(:group, :crm_enabled) } let_it_be(:group) { create(:group) }
        let(:valid_params) do let(:valid_params) do
        attributes_for(:crm_organization, attributes_for(:crm_organization,
        ......
        ...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
        RSpec.describe Mutations::CustomerRelations::Organizations::Update do RSpec.describe Mutations::CustomerRelations::Organizations::Update do
        let_it_be(:user) { create(:user) } let_it_be(:user) { create(:user) }
        let_it_be(:group) { create(:group, :crm_enabled) } let_it_be(:group) { create(:group) }
        let(:name) { 'GitLab' } let(:name) { 'GitLab' }
        let(:default_rate) { 1000.to_f } let(:default_rate) { 1000.to_f }
        ......
        ...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
        include GraphqlHelpers include GraphqlHelpers
        let_it_be(:user) { create(:user) } let_it_be(:user) { create(:user) }
        let_it_be(:group) { create(:group, :crm_enabled) } let_it_be(:group) { create(:group) }
        before_all do before_all do
        create(:contact, group: group, email: "x@test.com") create(:contact, group: group, email: "x@test.com")
        ......
        0% Loading or .
        You are about to add 0 people to the discussion. Proceed with caution.
        Finish editing this message first!
        Please register or to comment