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
76c48f7f
Commit
76c48f7f
authored
Feb 05, 2020
by
Mayra Cabrera
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'sdesk-name-db' into 'master'
Add project_key column See merge request gitlab-org/gitlab!24063
parents
064696e1
38416e8c
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
45 additions
and
0 deletions
+45
-0
changelogs/unreleased/sdesk-name-handler.yml
changelogs/unreleased/sdesk-name-handler.yml
+5
-0
db/migrate/20200202100932_add_service_desk_project_key.rb
db/migrate/20200202100932_add_service_desk_project_key.rb
+9
-0
db/schema.rb
db/schema.rb
+1
-0
ee/app/models/ee/project.rb
ee/app/models/ee/project.rb
+6
-0
ee/app/models/service_desk_setting.rb
ee/app/models/service_desk_setting.rb
+2
-0
ee/spec/models/project_spec.rb
ee/spec/models/project_spec.rb
+14
-0
ee/spec/models/service_desk_setting_spec.rb
ee/spec/models/service_desk_setting_spec.rb
+7
-0
spec/lib/gitlab/import_export/safe_model_attributes.yml
spec/lib/gitlab/import_export/safe_model_attributes.yml
+1
-0
No files found.
changelogs/unreleased/sdesk-name-handler.yml
0 → 100644
View file @
76c48f7f
---
title
:
Added migration which adds project_key column to service_desk_settings.
merge_request
:
24063
author
:
type
:
added
db/migrate/20200202100932_add_service_desk_project_key.rb
0 → 100644
View file @
76c48f7f
# frozen_string_literal: true
class
AddServiceDeskProjectKey
<
ActiveRecord
::
Migration
[
5.2
]
DOWNTIME
=
false
def
change
add_column
:service_desk_settings
,
:project_key
,
:string
,
limit:
255
end
end
db/schema.rb
View file @
76c48f7f
...
@@ -3797,6 +3797,7 @@ ActiveRecord::Schema.define(version: 2020_02_04_131054) do
...
@@ -3797,6 +3797,7 @@ ActiveRecord::Schema.define(version: 2020_02_04_131054) do
create_table
"service_desk_settings"
,
primary_key:
"project_id"
,
id: :bigint
,
default:
nil
,
force: :cascade
do
|
t
|
create_table
"service_desk_settings"
,
primary_key:
"project_id"
,
id: :bigint
,
default:
nil
,
force: :cascade
do
|
t
|
t
.
string
"issue_template_key"
,
limit:
255
t
.
string
"issue_template_key"
,
limit:
255
t
.
string
"outgoing_name"
,
limit:
255
t
.
string
"outgoing_name"
,
limit:
255
t
.
string
"project_key"
,
limit:
255
end
end
create_table
"services"
,
id: :serial
,
force: :cascade
do
|
t
|
create_table
"services"
,
id: :serial
,
force: :cascade
do
|
t
|
...
...
ee/app/models/ee/project.rb
View file @
76c48f7f
...
@@ -196,6 +196,12 @@ module EE
...
@@ -196,6 +196,12 @@ module EE
joins
(
'LEFT JOIN services ON services.project_id = projects.id AND services.type = \'GitlabSlackApplicationService\' AND services.active IS true'
)
joins
(
'LEFT JOIN services ON services.project_id = projects.id AND services.type = \'GitlabSlackApplicationService\' AND services.active IS true'
)
.
where
(
'services.id IS NULL'
)
.
where
(
'services.id IS NULL'
)
end
end
def
find_by_service_desk_project_key
(
key
)
# project_key is not indexed for now
# see https://gitlab.com/gitlab-org/gitlab/-/merge_requests/24063#note_282435524 for details
joins
(
:service_desk_setting
).
find_by
(
'service_desk_settings.project_key'
=>
key
)
end
end
end
def
can_store_security_reports?
def
can_store_security_reports?
...
...
ee/app/models/service_desk_setting.rb
View file @
76c48f7f
...
@@ -7,6 +7,8 @@ class ServiceDeskSetting < ApplicationRecord
...
@@ -7,6 +7,8 @@ class ServiceDeskSetting < ApplicationRecord
validates
:project_id
,
presence:
true
validates
:project_id
,
presence:
true
validate
:valid_issue_template
validate
:valid_issue_template
validates
:outgoing_name
,
length:
{
maximum:
255
},
allow_blank:
true
validates
:outgoing_name
,
length:
{
maximum:
255
},
allow_blank:
true
validates
:project_key
,
length:
{
maximum:
255
},
allow_blank:
true
,
format:
{
with:
/\A[a-z0-9_]+\z/
}
validates_uniqueness_of
:project_key
def
issue_template_content
def
issue_template_content
strong_memoize
(
:issue_template_content
)
do
strong_memoize
(
:issue_template_content
)
do
...
...
ee/spec/models/project_spec.rb
View file @
76c48f7f
...
@@ -170,6 +170,20 @@ describe Project do
...
@@ -170,6 +170,20 @@ describe Project do
expect
(
described_class
.
with_active_prometheus_service
).
not_to
include
(
project_without_active_prometheus_service
)
expect
(
described_class
.
with_active_prometheus_service
).
not_to
include
(
project_without_active_prometheus_service
)
end
end
end
end
describe
'.find_by_service_desk_project_key'
do
it
'returns the correct project'
do
project2
=
create
(
:project
)
create
(
:service_desk_setting
,
project:
project
,
project_key:
'key1'
)
create
(
:service_desk_setting
,
project:
project2
,
project_key:
'key2'
)
expect
(
Project
.
find_by_service_desk_project_key
(
'key2'
)).
to
eq
(
project2
)
end
it
'returns nil if there is no project with the key'
do
expect
(
Project
.
find_by_service_desk_project_key
(
'some_key'
)).
to
be_nil
end
end
end
end
describe
'validations'
do
describe
'validations'
do
...
...
ee/spec/models/service_desk_setting_spec.rb
View file @
76c48f7f
...
@@ -4,8 +4,15 @@ require 'spec_helper'
...
@@ -4,8 +4,15 @@ require 'spec_helper'
describe
ServiceDeskSetting
do
describe
ServiceDeskSetting
do
describe
'validations'
do
describe
'validations'
do
subject
(
:service_desk_setting
)
{
create
(
:service_desk_setting
)
}
it
{
is_expected
.
to
validate_presence_of
(
:project_id
)
}
it
{
is_expected
.
to
validate_presence_of
(
:project_id
)
}
it
{
is_expected
.
to
validate_length_of
(
:outgoing_name
).
is_at_most
(
255
)
}
it
{
is_expected
.
to
validate_length_of
(
:outgoing_name
).
is_at_most
(
255
)
}
it
{
is_expected
.
to
validate_length_of
(
:project_key
).
is_at_most
(
255
)
}
it
{
is_expected
.
to
validate_uniqueness_of
(
:project_key
)
}
it
{
is_expected
.
to
allow_value
(
'abc123_'
).
for
(
:project_key
)
}
it
{
is_expected
.
not_to
allow_value
(
'abc 12'
).
for
(
:project_key
)
}
it
{
is_expected
.
not_to
allow_value
(
'Big val'
).
for
(
:project_key
)
}
describe
'.valid_issue_template'
do
describe
'.valid_issue_template'
do
let_it_be
(
:project
)
{
create
(
:project
,
:custom_repo
,
files:
{
'.gitlab/issue_templates/service_desk.md'
=>
'template'
})
}
let_it_be
(
:project
)
{
create
(
:project
,
:custom_repo
,
files:
{
'.gitlab/issue_templates/service_desk.md'
=>
'template'
})
}
...
...
spec/lib/gitlab/import_export/safe_model_attributes.yml
View file @
76c48f7f
...
@@ -783,6 +783,7 @@ ZoomMeeting:
...
@@ -783,6 +783,7 @@ ZoomMeeting:
ServiceDeskSetting
:
ServiceDeskSetting
:
-
project_id
-
project_id
-
issue_template_key
-
issue_template_key
-
project_key
ContainerExpirationPolicy
:
ContainerExpirationPolicy
:
-
created_at
-
created_at
-
updated_at
-
updated_at
...
...
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