Commit dfeb0b6f authored by Adam Hegyi's avatar Adam Hegyi

Merge branch '211345-do-not-rely-on-models' into 'master'

Adjust migration specs to not rely on model version

See merge request gitlab-org/gitlab!27329
parents 9b843364 88a0a441
...@@ -13,6 +13,7 @@ describe Gitlab::BackgroundMigration::UserMentions::CreateResourceUserMention do ...@@ -13,6 +13,7 @@ describe Gitlab::BackgroundMigration::UserMentions::CreateResourceUserMention do
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 do ...@@ -33,13 +34,14 @@ describe Gitlab::BackgroundMigration::UserMentions::CreateResourceUserMention do
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
......
...@@ -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?
......
...@@ -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
......
...@@ -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
......
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