Commit 88a0a441 authored by Alexandru Croitor's avatar Alexandru Croitor

Adjust migration specs to not rely on model version

parent de84743f
......@@ -13,6 +13,7 @@ describe Gitlab::BackgroundMigration::UserMentions::CreateResourceUserMention, s
let(:namespaces) { table(:namespaces) }
let(:projects) { table(:projects) }
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(: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
before do
# 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
mentioned_groups.each do |gr|
gr.name += '-org'
gr.path += '-org'
gr.becomes(Namespace).save!
routes.create!(path: gr.path, source_type: 'Namespace', source_id: gr.id)
end
end
......
......@@ -24,7 +24,7 @@ module Gitlab
end
def for_project_noteable?
!for_personal_snippet?
!for_personal_snippet? && !for_epic?
end
def skip_project_check?
......
......@@ -12,6 +12,7 @@ describe Gitlab::BackgroundMigration::UserMentions::CreateResourceUserMention, s
let(:namespaces) { table(:namespaces) }
let(:projects) { table(:projects) }
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(: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
before do
# 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
mentioned_groups.each do |gr|
gr.name += '-org'
gr.path += '-org'
gr.becomes(Namespace).save!
routes.create!(path: gr.path, source_type: 'Namespace', source_id: gr.id)
end
end
......
......@@ -22,14 +22,6 @@ shared_examples 'resource mentions migration' do |migration_class, resource_clas
end
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
join = migration_class::JOIN
conditions = migration_class::QUERY_CONDITIONS
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment