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
9bffa830
Commit
9bffa830
authored
Feb 27, 2020
by
Jan Provaznik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed iid generation
* also minor spec fixes
parent
bb468849
Changes
9
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
46 additions
and
3 deletions
+46
-3
app/models/internal_id.rb
app/models/internal_id.rb
+1
-1
app/models/internal_id_enums.rb
app/models/internal_id_enums.rb
+10
-0
db/migrate/20200226100614_create_requirements.rb
db/migrate/20200226100614_create_requirements.rb
+1
-0
db/schema.rb
db/schema.rb
+1
-0
ee/app/models/ee/internal_id_enums.rb
ee/app/models/ee/internal_id_enums.rb
+16
-0
ee/app/models/requirement.rb
ee/app/models/requirement.rb
+7
-1
ee/spec/factories/requirements.rb
ee/spec/factories/requirements.rb
+0
-1
ee/spec/services/users/migrate_to_ghost_user_service_spec.rb
ee/spec/services/users/migrate_to_ghost_user_service_spec.rb
+9
-0
spec/lib/gitlab/import_export/all_models.yml
spec/lib/gitlab/import_export/all_models.yml
+1
-0
No files found.
app/models/internal_id.rb
View file @
9bffa830
...
@@ -21,7 +21,7 @@ class InternalId < ApplicationRecord
...
@@ -21,7 +21,7 @@ class InternalId < ApplicationRecord
belongs_to
:project
belongs_to
:project
belongs_to
:namespace
belongs_to
:namespace
enum
usage:
{
issues:
0
,
merge_requests:
1
,
deployments:
2
,
milestones:
3
,
epics:
4
,
ci_pipelines:
5
,
operations_feature_flags:
6
}
enum
usage:
::
InternalIdEnums
.
usage_resources
validates
:usage
,
presence:
true
validates
:usage
,
presence:
true
...
...
app/models/internal_id_enums.rb
0 → 100644
View file @
9bffa830
# frozen_string_literal: true
module
InternalIdEnums
def
self
.
usage_resources
# when adding new resource, make sure it doesn't conflict with EE usage_resources
{
issues:
0
,
merge_requests:
1
,
deployments:
2
,
milestones:
3
,
epics:
4
,
ci_pipelines:
5
,
operations_feature_flags:
6
}
end
end
InternalIdEnums
.
prepend_if_ee
(
'EE::InternalIdEnums'
)
db/migrate/20200226100614_create_requirements.rb
View file @
9bffa830
...
@@ -9,6 +9,7 @@ class CreateRequirements < ActiveRecord::Migration[6.0]
...
@@ -9,6 +9,7 @@ class CreateRequirements < ActiveRecord::Migration[6.0]
create_table
:requirements
do
|
t
|
create_table
:requirements
do
|
t
|
t
.
integer
:state
,
limit:
2
,
default:
1
,
null:
false
t
.
integer
:state
,
limit:
2
,
default:
1
,
null:
false
t
.
integer
:iid
,
null:
false
t
.
integer
:iid
,
null:
false
t
.
integer
:cached_markdown_version
t
.
references
:project
,
null:
false
,
index:
true
,
foreign_key:
{
on_delete: :cascade
}
t
.
references
:project
,
null:
false
,
index:
true
,
foreign_key:
{
on_delete: :cascade
}
t
.
references
:author
,
index:
true
,
foreign_key:
{
to_table: :users
,
on_delete: :nullify
}
t
.
references
:author
,
index:
true
,
foreign_key:
{
to_table: :users
,
on_delete: :nullify
}
t
.
timestamps_with_timezone
null:
false
t
.
timestamps_with_timezone
null:
false
...
...
db/schema.rb
View file @
9bffa830
...
@@ -3725,6 +3725,7 @@ ActiveRecord::Schema.define(version: 2020_02_27_165129) do
...
@@ -3725,6 +3725,7 @@ ActiveRecord::Schema.define(version: 2020_02_27_165129) do
create_table
"requirements"
,
force: :cascade
do
|
t
|
create_table
"requirements"
,
force: :cascade
do
|
t
|
t
.
integer
"state"
,
limit:
2
,
default:
1
,
null:
false
t
.
integer
"state"
,
limit:
2
,
default:
1
,
null:
false
t
.
integer
"iid"
,
null:
false
t
.
integer
"iid"
,
null:
false
t
.
integer
"cached_markdown_version"
t
.
bigint
"project_id"
,
null:
false
t
.
bigint
"project_id"
,
null:
false
t
.
bigint
"author_id"
t
.
bigint
"author_id"
t
.
datetime_with_timezone
"created_at"
,
null:
false
t
.
datetime_with_timezone
"created_at"
,
null:
false
...
...
ee/app/models/ee/internal_id_enums.rb
0 → 100644
View file @
9bffa830
# frozen_string_literal: true
module
EE
module
InternalIdEnums
extend
ActiveSupport
::
Concern
class_methods
do
extend
::
Gitlab
::
Utils
::
Override
override
:usage_resources
def
usage_resources
super
.
merge
(
requirements:
7
)
end
end
end
end
ee/app/models/requirement.rb
View file @
9bffa830
...
@@ -2,12 +2,18 @@
...
@@ -2,12 +2,18 @@
class
Requirement
<
ApplicationRecord
class
Requirement
<
ApplicationRecord
include
CacheMarkdownField
include
CacheMarkdownField
include
StripAttribute
include
AtomicInternalId
cache_markdown_field
:title
,
pipeline: :single_line
cache_markdown_field
:title
,
pipeline: :single_line
strip_attributes
:title
belongs_to
:author
,
class_name:
'User'
belongs_to
:author
,
class_name:
'User'
belongs_to
:project
belongs_to
:project
has_internal_id
:iid
,
scope: :project
,
init:
->
(
s
)
{
s
&
.
project
&
.
requirements
&
.
maximum
(
:iid
)
}
validates
:author
,
:project
,
:title
,
presence:
true
validates
:author
,
:project
,
:title
,
presence:
true
validates
:title
,
length:
{
maximum:
Issuable
::
TITLE_LENGTH_MAX
}
validates
:title
,
length:
{
maximum:
Issuable
::
TITLE_LENGTH_MAX
}
...
@@ -16,7 +22,7 @@ class Requirement < ApplicationRecord
...
@@ -16,7 +22,7 @@ class Requirement < ApplicationRecord
enum
state:
{
opened:
1
,
archived:
2
}
enum
state:
{
opened:
1
,
archived:
2
}
# In the next iteration we will support also group-level requirements
# In the next iteration we will support also group-level requirements
# so it use resource_parent instead of project directly
# so it
's better to
use resource_parent instead of project directly
def
resource_parent
def
resource_parent
project
project
end
end
...
...
ee/spec/factories/requirements.rb
View file @
9bffa830
# frozen_string_literal: true
# frozen_string_literal: true
FactoryBot
.
define
do
FactoryBot
.
define
do
...
...
ee/spec/services/users/migrate_to_ghost_user_service_spec.rb
View file @
9bffa830
...
@@ -48,4 +48,13 @@ describe Users::MigrateToGhostUserService do
...
@@ -48,4 +48,13 @@ describe Users::MigrateToGhostUserService do
let
(
:created_record
)
{
create
(
:review
,
author:
user
)
}
let
(
:created_record
)
{
create
(
:review
,
author:
user
)
}
end
end
end
end
context
'requirements'
do
let!
(
:user
)
{
create
(
:user
)
}
let
(
:service
)
{
described_class
.
new
(
user
)
}
include_examples
"migrating a deleted user's associated records to the ghost user"
,
Requirement
,
[
:author
]
do
let
(
:created_record
)
{
create
(
:requirement
,
author:
user
)
}
end
end
end
end
spec/lib/gitlab/import_export/all_models.yml
View file @
9bffa830
...
@@ -467,6 +467,7 @@ project:
...
@@ -467,6 +467,7 @@ project:
-
resource_groups
-
resource_groups
-
autoclose_referenced_issues
-
autoclose_referenced_issues
-
status_page_setting
-
status_page_setting
-
requirements
award_emoji
:
award_emoji
:
-
awardable
-
awardable
-
user
-
user
...
...
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