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
91bbbd1f
Commit
91bbbd1f
authored
May 25, 2021
by
Jonas Wälter
Committed by
Vitali Tatarintev
May 25, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Clean up intermediate state during data migration of project topics
parent
4b489b16
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
3 additions
and
54 deletions
+3
-54
app/models/project.rb
app/models/project.rb
+3
-29
spec/models/project_spec.rb
spec/models/project_spec.rb
+0
-25
No files found.
app/models/project.rb
View file @
91bbbd1f
...
...
@@ -129,41 +129,15 @@ class Project < ApplicationRecord
after_create
:check_repository_absence!
acts_as_ordered_taggable_on
:topics
# The 'tag_list' alias and the '
has_many' associations
are required during the 'tags -> topics' migration
# TODO: eliminate 'tag_list'
, 'topic_taggings'
and 'tags' in the further process of the migration
# https://gitlab.com/gitlab-org/gitlab/-/issues/3
31081
# The 'tag_list' alias and the '
tags' association
are required during the 'tags -> topics' migration
# TODO: eliminate 'tag_list' and 'tags' in the further process of the migration
# https://gitlab.com/gitlab-org/gitlab/-/issues/3
28226
alias_attribute
:tag_list
,
:topic_list
has_many
:topic_taggings
,
->
{
includes
(
:tag
).
order
(
"
#{
ActsAsTaggableOn
::
Tagging
.
table_name
}
.id"
)
},
as: :taggable
,
class_name:
'ActsAsTaggableOn::Tagging'
,
after_add: :dirtify_tag_list
,
after_remove: :dirtify_tag_list
has_many
:topics
,
->
{
order
(
"
#{
ActsAsTaggableOn
::
Tagging
.
table_name
}
.id"
)
},
class_name:
'ActsAsTaggableOn::Tag'
,
through: :topic_taggings
,
source: :tag
has_many
:tags
,
->
{
order
(
"
#{
ActsAsTaggableOn
::
Tagging
.
table_name
}
.id"
)
},
class_name:
'ActsAsTaggableOn::Tag'
,
through: :topic_taggings
,
source: :tag
# Overwriting 'topic_list' and 'topic_list=' is necessary to ensure functionality during the background migration [1].
# [1] https://gitlab.com/gitlab-org/gitlab/-/merge_requests/61237
# TODO: remove 'topic_list' and 'topic_list=' once the background migration is complete
# https://gitlab.com/gitlab-org/gitlab/-/issues/331081
def
topic_list
# Return both old topics (context 'tags') and new topics (context 'topics')
tag_list_on
(
'tags'
)
+
tag_list_on
(
'topics'
)
end
def
topic_list
=
(
new_tags
)
# Old topics with context 'tags' are added as new topics with context 'topics'
super
(
new_tags
)
# Remove old topics with context 'tags'
set_tag_list_on
(
'tags'
,
''
)
end
attr_accessor
:old_path_with_namespace
attr_accessor
:template_name
attr_writer
:pipeline_status
...
...
spec/models/project_spec.rb
View file @
91bbbd1f
...
...
@@ -6888,31 +6888,6 @@ RSpec.describe Project, factory_default: :keep do
expect
(
project
.
tags
.
map
(
&
:name
)).
to
match_array
(
%w[topic1 topic2 topic3]
)
end
end
context
'intermediate state during background migration'
do
before
do
project
.
taggings
.
first
.
update!
(
context:
'tags'
)
project
.
instance_variable_set
(
"@tag_list"
,
nil
)
project
.
reload
end
it
'tag_list returns string array including old and new topics'
do
expect
(
project
.
tag_list
).
to
match_array
(
%w[topic1 topic2 topic3]
)
end
it
'tags returns old and new tag records'
do
expect
(
project
.
tags
.
first
.
class
.
name
).
to
eq
(
'ActsAsTaggableOn::Tag'
)
expect
(
project
.
tags
.
map
(
&
:name
)).
to
match_array
(
%w[topic1 topic2 topic3]
)
expect
(
project
.
taggings
.
map
(
&
:context
)).
to
match_array
(
%w[tags topics topics]
)
end
it
'update tag_list adds new topics and removes old topics'
do
project
.
update!
(
tag_list:
'topic1, topic2, topic3, topic4'
)
expect
(
project
.
tags
.
map
(
&
:name
)).
to
match_array
(
%w[topic1 topic2 topic3 topic4]
)
expect
(
project
.
taggings
.
map
(
&
:context
)).
to
match_array
(
%w[topics topics topics topics]
)
end
end
end
def
finish_job
(
export_job
)
...
...
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