Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
083c1f8f
Commit
083c1f8f
authored
Dec 16, 2021
by
Lee Tickett
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add group crm settings
Changelog: added
parent
32dd97c8
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
98 additions
and
0 deletions
+98
-0
app/models/group.rb
app/models/group.rb
+6
-0
app/models/group/crm_settings.rb
app/models/group/crm_settings.rb
+10
-0
db/migrate/20211216220939_add_group_crm_settings.rb
db/migrate/20211216220939_add_group_crm_settings.rb
+13
-0
db/schema_migrations/20211216220939
db/schema_migrations/20211216220939
+1
-0
db/structure.sql
db/structure.sql
+26
-0
lib/gitlab/database/gitlab_schemas.yml
lib/gitlab/database/gitlab_schemas.yml
+1
-0
spec/factories/group/crm_settings.rb
spec/factories/group/crm_settings.rb
+7
-0
spec/models/group/crm_settings_spec.rb
spec/models/group/crm_settings_spec.rb
+15
-0
spec/models/group_spec.rb
spec/models/group_spec.rb
+19
-0
No files found.
app/models/group.rb
View file @
083c1f8f
...
...
@@ -92,6 +92,8 @@ class Group < Namespace
delegate
:prevent_sharing_groups_outside_hierarchy
,
:new_user_signups_cap
,
:setup_for_company
,
:jobs_to_be_done
,
to: :namespace_settings
has_one
:crm_settings
,
class_name:
'Group::CrmSettings'
,
inverse_of: :group
accepts_nested_attributes_for
:variables
,
allow_destroy:
true
validate
:visibility_level_allowed_by_projects
...
...
@@ -764,6 +766,10 @@ class Group < Namespace
super
||
build_dependency_proxy_image_ttl_policy
end
def
crm_enabled?
crm_settings
&
.
enabled?
end
private
def
max_member_access
(
user_ids
)
...
...
app/models/group/crm_settings.rb
0 → 100644
View file @
083c1f8f
# frozen_string_literal: true
class
Group::CrmSettings
<
ApplicationRecord
self
.
primary_key
=
:group_id
self
.
table_name
=
'group_crm_settings'
belongs_to
:group
,
->
{
where
(
type:
Group
.
sti_name
)
},
foreign_key:
'group_id'
validates
:group
,
presence:
true
end
db/migrate/20211216220939_add_group_crm_settings.rb
0 → 100644
View file @
083c1f8f
# frozen_string_literal: true
class
AddGroupCrmSettings
<
Gitlab
::
Database
::
Migration
[
1.0
]
enable_lock_retries!
def
change
create_table
:group_crm_settings
,
id:
false
do
|
t
|
t
.
references
:group
,
primary_key:
true
,
foreign_key:
{
to_table: :namespaces
,
on_delete: :cascade
}
t
.
timestamps_with_timezone
t
.
boolean
:enabled
,
null:
false
,
default:
false
end
end
end
db/schema_migrations/20211216220939
0 → 100644
View file @
083c1f8f
649cf0eb794904457b230c1240d2bea8a6e80b00dbf6b2d25b95c66247460aa4
\ No newline at end of file
db/structure.sql
View file @
083c1f8f
...
...
@@ -14713,6 +14713,22 @@ CREATE SEQUENCE grafana_integrations_id_seq
ALTER SEQUENCE grafana_integrations_id_seq OWNED BY grafana_integrations.id;
CREATE TABLE group_crm_settings (
group_id bigint NOT NULL,
created_at timestamp with time zone NOT NULL,
updated_at timestamp with time zone NOT NULL,
enabled boolean DEFAULT false NOT NULL
);
CREATE SEQUENCE group_crm_settings_group_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE group_crm_settings_group_id_seq OWNED BY group_crm_settings.group_id;
CREATE TABLE group_custom_attributes (
id integer NOT NULL,
created_at timestamp with time zone NOT NULL,
...
...
@@ -21635,6 +21651,8 @@ ALTER TABLE ONLY gpg_signatures ALTER COLUMN id SET DEFAULT nextval('gpg_signatu
ALTER TABLE ONLY grafana_integrations ALTER COLUMN id SET DEFAULT nextval('grafana_integrations_id_seq'::regclass);
ALTER TABLE ONLY group_crm_settings ALTER COLUMN group_id SET DEFAULT nextval('group_crm_settings_group_id_seq'::regclass);
ALTER TABLE ONLY group_custom_attributes ALTER COLUMN id SET DEFAULT nextval('group_custom_attributes_id_seq'::regclass);
ALTER TABLE ONLY group_deploy_keys ALTER COLUMN id SET DEFAULT nextval('group_deploy_keys_id_seq'::regclass);
...
...
@@ -23271,6 +23289,9 @@ ALTER TABLE ONLY gpg_signatures
ALTER TABLE ONLY grafana_integrations
ADD CONSTRAINT grafana_integrations_pkey PRIMARY KEY (id);
ALTER TABLE ONLY group_crm_settings
ADD CONSTRAINT group_crm_settings_pkey PRIMARY KEY (group_id);
ALTER TABLE ONLY group_custom_attributes
ADD CONSTRAINT group_custom_attributes_pkey PRIMARY KEY (id);
...
...
@@ -26159,6 +26180,8 @@ CREATE INDEX index_grafana_integrations_on_enabled ON grafana_integrations USING
CREATE INDEX index_grafana_integrations_on_project_id ON grafana_integrations USING btree (project_id);
CREATE INDEX index_group_crm_settings_on_group_id ON group_crm_settings USING btree (group_id);
CREATE UNIQUE INDEX index_group_custom_attributes_on_group_id_and_key ON group_custom_attributes USING btree (group_id, key);
CREATE INDEX index_group_custom_attributes_on_key_and_value ON group_custom_attributes USING btree (key, value);
...
...
@@ -30613,6 +30636,9 @@ ALTER TABLE ONLY dast_site_profiles
ALTER TABLE ONLY merge_request_context_commit_diff_files
ADD CONSTRAINT fk_rails_74a00a1787 FOREIGN KEY (merge_request_context_commit_id) REFERENCES merge_request_context_commits(id) ON DELETE CASCADE;
ALTER TABLE ONLY group_crm_settings
ADD CONSTRAINT fk_rails_74fdf2f13d FOREIGN KEY (group_id) REFERENCES namespaces(id) ON DELETE CASCADE;
ALTER TABLE ONLY clusters_applications_ingress
ADD CONSTRAINT fk_rails_753a7b41c1 FOREIGN KEY (cluster_id) REFERENCES clusters(id) ON DELETE CASCADE;
lib/gitlab/database/gitlab_schemas.yml
View file @
083c1f8f
...
...
@@ -231,6 +231,7 @@ gpg_key_subkeys: :gitlab_main
gpg_signatures
:
:gitlab_main
grafana_integrations
:
:gitlab_main
group_custom_attributes
:
:gitlab_main
group_crm_settings
:
:gitlab_main
group_deletion_schedules
:
:gitlab_main
group_deploy_keys
:
:gitlab_main
group_deploy_keys_groups
:
:gitlab_main
...
...
spec/factories/group/crm_settings.rb
0 → 100644
View file @
083c1f8f
# frozen_string_literal: true
FactoryBot
.
define
do
factory
:crm_settings
,
class:
'Group::CrmSettings'
do
group
end
end
spec/models/group/crm_settings_spec.rb
0 → 100644
View file @
083c1f8f
# frozen_string_literal: true
require
'spec_helper'
RSpec
.
describe
Group
::
CrmSettings
do
describe
'associations'
do
it
{
is_expected
.
to
belong_to
(
:group
)
}
end
describe
'validations'
do
subject
{
build
(
:crm_settings
)
}
it
{
is_expected
.
to
validate_presence_of
(
:group
)
}
end
end
spec/models/group_spec.rb
View file @
083c1f8f
...
...
@@ -39,6 +39,7 @@ RSpec.describe Group do
it
{
is_expected
.
to
have_many
(
:bulk_import_exports
).
class_name
(
'BulkImports::Export'
)
}
it
{
is_expected
.
to
have_many
(
:contacts
).
class_name
(
'CustomerRelations::Contact'
)
}
it
{
is_expected
.
to
have_many
(
:organizations
).
class_name
(
'CustomerRelations::Organization'
)
}
it
{
is_expected
.
to
have_one
(
:crm_settings
)
}
describe
'#members & #requesters'
do
let
(
:requester
)
{
create
(
:user
)
}
...
...
@@ -2784,4 +2785,22 @@ RSpec.describe Group do
end
end
end
describe
'#crm_enabled?'
do
it
'returns false where no crm_settings exist'
do
expect
(
group
.
crm_enabled?
).
to
be_falsey
end
it
'returns false where crm_settings.state is disabled'
do
create
(
:crm_settings
,
enabled:
false
,
group:
group
)
expect
(
group
.
crm_enabled?
).
to
be_falsey
end
it
'returns true where crm_settings.state is enabled'
do
create
(
:crm_settings
,
enabled:
true
,
group:
group
)
expect
(
group
.
crm_enabled?
).
to
be_truthy
end
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment