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
88a0a441
Commit
88a0a441
authored
Mar 16, 2020
by
Alexandru Croitor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adjust migration specs to not rely on model version
parent
de84743f
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
13 additions
and
17 deletions
+13
-17
ee/spec/lib/gitlab/background_migration/user_mentions/create_resource_user_mention_spec.rb
...ration/user_mentions/create_resource_user_mention_spec.rb
+6
-4
lib/gitlab/background_migration/user_mentions/models/note.rb
lib/gitlab/background_migration/user_mentions/models/note.rb
+1
-1
spec/lib/gitlab/background_migration/user_mentions/create_resource_user_mention_spec.rb
...ration/user_mentions/create_resource_user_mention_spec.rb
+6
-4
spec/support/shared_examples/lib/gitlab/background_migration/mentions_migration_shared_examples.rb
...ackground_migration/mentions_migration_shared_examples.rb
+0
-8
No files found.
ee/spec/lib/gitlab/background_migration/user_mentions/create_resource_user_mention_spec.rb
View file @
88a0a441
...
@@ -13,6 +13,7 @@ describe Gitlab::BackgroundMigration::UserMentions::CreateResourceUserMention, s
...
@@ -13,6 +13,7 @@ describe Gitlab::BackgroundMigration::UserMentions::CreateResourceUserMention, s
let
(
:namespaces
)
{
table
(
:namespaces
)
}
let
(
:namespaces
)
{
table
(
:namespaces
)
}
let
(
:projects
)
{
table
(
:projects
)
}
let
(
:projects
)
{
table
(
:projects
)
}
let
(
:notes
)
{
table
(
:notes
)
}
let
(
:notes
)
{
table
(
:notes
)
}
let
(
:routes
)
{
table
(
:routes
)
}
let
(
:author
)
{
users
.
create!
(
email:
'author@example.com'
,
notification_email:
'author@example.com'
,
name:
'author'
,
username:
'author'
,
projects_limit:
10
,
state:
'active'
)
}
let
(
:author
)
{
users
.
create!
(
email:
'author@example.com'
,
notification_email:
'author@example.com'
,
name:
'author'
,
username:
'author'
,
projects_limit:
10
,
state:
'active'
)
}
let
(
:member
)
{
users
.
create!
(
email:
'member@example.com'
,
notification_email:
'member@example.com'
,
name:
'member'
,
username:
'member'
,
projects_limit:
10
,
state:
'active'
)
}
let
(
:member
)
{
users
.
create!
(
email:
'member@example.com'
,
notification_email:
'member@example.com'
,
name:
'member'
,
username:
'member'
,
projects_limit:
10
,
state:
'active'
)
}
...
@@ -33,13 +34,14 @@ describe Gitlab::BackgroundMigration::UserMentions::CreateResourceUserMention, s
...
@@ -33,13 +34,14 @@ describe Gitlab::BackgroundMigration::UserMentions::CreateResourceUserMention, s
before
do
before
do
# build personal namespaces and routes for users
# build personal namespaces and routes for users
mentioned_users
.
each
{
|
u
|
u
.
becomes
(
User
).
save!
}
mentioned_users
.
each
do
|
u
|
namespace
=
namespaces
.
create!
(
path:
u
.
username
,
name:
u
.
name
,
runners_token:
"my-token-u
#{
u
.
id
}
"
,
owner_id:
u
.
id
,
type:
nil
)
routes
.
create!
(
path:
namespace
.
path
,
source_type:
'Namespace'
,
source_id:
namespace
.
id
)
end
# build namespaces and routes for groups
# build namespaces and routes for groups
mentioned_groups
.
each
do
|
gr
|
mentioned_groups
.
each
do
|
gr
|
gr
.
name
+=
'-org'
routes
.
create!
(
path:
gr
.
path
,
source_type:
'Namespace'
,
source_id:
gr
.
id
)
gr
.
path
+=
'-org'
gr
.
becomes
(
Namespace
).
save!
end
end
end
end
...
...
lib/gitlab/background_migration/user_mentions/models/note.rb
View file @
88a0a441
...
@@ -24,7 +24,7 @@ module Gitlab
...
@@ -24,7 +24,7 @@ module Gitlab
end
end
def
for_project_noteable?
def
for_project_noteable?
!
for_personal_snippet?
!
for_personal_snippet?
&&
!
for_epic?
end
end
def
skip_project_check?
def
skip_project_check?
...
...
spec/lib/gitlab/background_migration/user_mentions/create_resource_user_mention_spec.rb
View file @
88a0a441
...
@@ -12,6 +12,7 @@ describe Gitlab::BackgroundMigration::UserMentions::CreateResourceUserMention, s
...
@@ -12,6 +12,7 @@ describe Gitlab::BackgroundMigration::UserMentions::CreateResourceUserMention, s
let
(
:namespaces
)
{
table
(
:namespaces
)
}
let
(
:namespaces
)
{
table
(
:namespaces
)
}
let
(
:projects
)
{
table
(
:projects
)
}
let
(
:projects
)
{
table
(
:projects
)
}
let
(
:notes
)
{
table
(
:notes
)
}
let
(
:notes
)
{
table
(
:notes
)
}
let
(
:routes
)
{
table
(
:routes
)
}
let
(
:author
)
{
users
.
create!
(
email:
'author@example.com'
,
notification_email:
'author@example.com'
,
name:
'author'
,
username:
'author'
,
projects_limit:
10
,
state:
'active'
)
}
let
(
:author
)
{
users
.
create!
(
email:
'author@example.com'
,
notification_email:
'author@example.com'
,
name:
'author'
,
username:
'author'
,
projects_limit:
10
,
state:
'active'
)
}
let
(
:member
)
{
users
.
create!
(
email:
'member@example.com'
,
notification_email:
'member@example.com'
,
name:
'member'
,
username:
'member'
,
projects_limit:
10
,
state:
'active'
)
}
let
(
:member
)
{
users
.
create!
(
email:
'member@example.com'
,
notification_email:
'member@example.com'
,
name:
'member'
,
username:
'member'
,
projects_limit:
10
,
state:
'active'
)
}
...
@@ -32,13 +33,14 @@ describe Gitlab::BackgroundMigration::UserMentions::CreateResourceUserMention, s
...
@@ -32,13 +33,14 @@ describe Gitlab::BackgroundMigration::UserMentions::CreateResourceUserMention, s
before
do
before
do
# build personal namespaces and routes for users
# build personal namespaces and routes for users
mentioned_users
.
each
{
|
u
|
u
.
becomes
(
User
).
save!
}
mentioned_users
.
each
do
|
u
|
namespace
=
namespaces
.
create!
(
path:
u
.
username
,
name:
u
.
name
,
runners_token:
"my-token-u
#{
u
.
id
}
"
,
owner_id:
u
.
id
,
type:
nil
)
routes
.
create!
(
path:
namespace
.
path
,
source_type:
'Namespace'
,
source_id:
namespace
.
id
)
end
# build namespaces and routes for groups
# build namespaces and routes for groups
mentioned_groups
.
each
do
|
gr
|
mentioned_groups
.
each
do
|
gr
|
gr
.
name
+=
'-org'
routes
.
create!
(
path:
gr
.
path
,
source_type:
'Namespace'
,
source_id:
gr
.
id
)
gr
.
path
+=
'-org'
gr
.
becomes
(
Namespace
).
save!
end
end
end
end
...
...
spec/support/shared_examples/lib/gitlab/background_migration/mentions_migration_shared_examples.rb
View file @
88a0a441
...
@@ -22,14 +22,6 @@ shared_examples 'resource mentions migration' do |migration_class, resource_clas
...
@@ -22,14 +22,6 @@ shared_examples 'resource mentions migration' do |migration_class, resource_clas
end
end
shared_examples
'resource notes mentions migration'
do
|
migration_class
,
resource_class
|
shared_examples
'resource notes mentions migration'
do
|
migration_class
,
resource_class
|
before
do
note1
.
becomes
(
Note
).
save!
note2
.
becomes
(
Note
).
save!
note3
.
becomes
(
Note
).
save!
note4
.
becomes
(
Note
).
save!
note5
.
becomes
(
Note
).
save
(
validate:
false
)
end
it
'migrates mentions from note'
do
it
'migrates mentions from note'
do
join
=
migration_class
::
JOIN
join
=
migration_class
::
JOIN
conditions
=
migration_class
::
QUERY_CONDITIONS
conditions
=
migration_class
::
QUERY_CONDITIONS
...
...
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