Skip to content
Snippets Groups Projects
Commit f35bac57 authored by Robert Speicher's avatar Robert Speicher
Browse files

Merge branch '40744-idempotent-ids' into 'master'

Use the DatabaseCleaner 'deletion' strategy instead of 'truncation'

Closes #30783

See merge request gitlab-org/gitlab-ce!16516
parents 8fe314e4 2fe57353
No related branches found
No related tags found
No related merge requests found
Showing
with 32 additions and 29 deletions
require 'database_cleaner'
 
DatabaseCleaner[:active_record].strategy = :truncation
DatabaseCleaner[:active_record].strategy = :deletion
 
Spinach.hooks.before_scenario do
DatabaseCleaner.start
Loading
Loading
Loading
Loading
@@ -108,7 +108,7 @@ describe 'Merge request > User resolves diff notes and discussions', :js do
it 'shows resolved discussion when toggled' do
find(".timeline-content .discussion[data-discussion-id='#{note.discussion_id}'] .discussion-toggle-button").click
 
expect(page.find(".timeline-content #note_#{note.noteable_id}")).to be_visible
expect(page.find(".timeline-content #note_#{note.id}")).to be_visible
end
end
 
Loading
Loading
Loading
Loading
@@ -10,9 +10,10 @@ describe('Pipelines table in Commits and Merge requests', () => {
preloadFixtures(jsonFixtureName);
 
beforeEach(() => {
PipelinesTable = Vue.extend(pipelinesTable);
const pipelines = getJSONFixture(jsonFixtureName).pipelines;
pipeline = pipelines.find(p => p.id === 1);
PipelinesTable = Vue.extend(pipelinesTable);
pipeline = pipelines.find(p => p.user !== null && p.commit !== null);
});
 
describe('successful request', () => {
Loading
Loading
Loading
Loading
@@ -24,9 +24,10 @@ describe('Pipelines Table Row', () => {
 
beforeEach(() => {
const pipelines = getJSONFixture(jsonFixtureName).pipelines;
pipeline = pipelines.find(p => p.id === 1);
pipelineWithoutAuthor = pipelines.find(p => p.id === 2);
pipelineWithoutCommit = pipelines.find(p => p.id === 3);
pipeline = pipelines.find(p => p.user !== null && p.commit !== null);
pipelineWithoutAuthor = pipelines.find(p => p.user == null && p.commit !== null);
pipelineWithoutCommit = pipelines.find(p => p.user == null && p.commit == null);
});
 
afterEach(() => {
Loading
Loading
Loading
Loading
@@ -11,9 +11,10 @@ describe('Pipelines Table', () => {
preloadFixtures(jsonFixtureName);
 
beforeEach(() => {
PipelinesTableComponent = Vue.extend(pipelinesTableComp);
const pipelines = getJSONFixture(jsonFixtureName).pipelines;
pipeline = pipelines.find(p => p.id === 1);
PipelinesTableComponent = Vue.extend(pipelinesTableComp);
pipeline = pipelines.find(p => p.user !== null && p.commit !== null);
});
 
describe('table', () => {
Loading
Loading
require 'spec_helper'
 
describe Gitlab::BackgroundMigration::DeserializeMergeRequestDiffsAndCommits, :truncate, :migration, schema: 20171114162227 do
describe Gitlab::BackgroundMigration::DeserializeMergeRequestDiffsAndCommits, :migration, schema: 20171114162227 do
let(:merge_request_diffs) { table(:merge_request_diffs) }
let(:merge_requests) { table(:merge_requests) }
 
Loading
Loading
require 'spec_helper'
 
describe Gitlab::BackgroundMigration::MigrateSystemUploadsToNewFolder do
describe Gitlab::BackgroundMigration::MigrateSystemUploadsToNewFolder, :delete do
let(:migration) { described_class.new }
 
before do
Loading
Loading
@@ -8,7 +8,7 @@ describe Gitlab::BackgroundMigration::MigrateSystemUploadsToNewFolder do
end
 
describe '#perform' do
it 'renames the path of system-uploads', :truncate do
it 'renames the path of system-uploads' do
upload = create(:upload, model: create(:project), path: 'uploads/system/project/avatar.jpg')
 
migration.perform('uploads/system/', 'uploads/-/system/')
Loading
Loading
require 'spec_helper'
 
describe Gitlab::Database::RenameReservedPathsMigration::V1::RenameBase, :truncate do
describe Gitlab::Database::RenameReservedPathsMigration::V1::RenameBase, :delete do
let(:migration) { FakeRenameReservedPathMigrationV1.new }
let(:subject) { described_class.new(['the-path'], migration) }
 
Loading
Loading
require 'spec_helper'
 
describe Gitlab::Database::RenameReservedPathsMigration::V1::RenameNamespaces, :truncate do
describe Gitlab::Database::RenameReservedPathsMigration::V1::RenameNamespaces, :delete do
let(:migration) { FakeRenameReservedPathMigrationV1.new }
let(:subject) { described_class.new(['the-path'], migration) }
let(:namespace) { create(:group, name: 'the-path') }
Loading
Loading
require 'spec_helper'
 
describe Gitlab::Database::RenameReservedPathsMigration::V1::RenameProjects, :truncate do
describe Gitlab::Database::RenameReservedPathsMigration::V1::RenameProjects, :delete do
let(:migration) { FakeRenameReservedPathMigrationV1.new }
let(:subject) { described_class.new(['the-path'], migration) }
let(:project) do
Loading
Loading
Loading
Loading
@@ -13,7 +13,7 @@ shared_examples 'renames child namespaces' do |type|
end
end
 
describe Gitlab::Database::RenameReservedPathsMigration::V1, :truncate do
describe Gitlab::Database::RenameReservedPathsMigration::V1, :delete do
let(:subject) { FakeRenameReservedPathMigrationV1.new }
 
before do
Loading
Loading
require 'spec_helper'
require Rails.root.join('db', 'post_migrate', '20170508170547_add_head_pipeline_for_each_merge_request.rb')
 
describe AddHeadPipelineForEachMergeRequest, :truncate do
describe AddHeadPipelineForEachMergeRequest, :delete do
include ProjectForksHelper
 
let(:migration) { described_class.new }
Loading
Loading
Loading
Loading
@@ -3,7 +3,7 @@
require 'spec_helper'
require Rails.root.join('db', 'post_migrate', '20170803090603_calculate_conv_dev_index_percentages.rb')
 
describe CalculateConvDevIndexPercentages, truncate: true do
describe CalculateConvDevIndexPercentages, :delete do
let(:migration) { described_class.new }
let!(:conv_dev_index) do
create(:conversational_development_index_metric,
Loading
Loading
require 'spec_helper'
require Rails.root.join('db', 'post_migrate', '20170518231126_fix_wrongly_renamed_routes.rb')
 
describe FixWronglyRenamedRoutes, :truncate, :migration do
describe FixWronglyRenamedRoutes, :migration do
let(:subject) { described_class.new }
let(:namespaces_table) { table(:namespaces) }
let(:projects_table) { table(:projects) }
Loading
Loading
Loading
Loading
@@ -8,10 +8,10 @@ describe MigrateIssuesToGhostUser, :migration do
let(:users) { table(:users) }
 
before do
projects.create!(name: 'gitlab')
project = projects.create!(name: 'gitlab')
user = users.create(email: 'test@example.com')
issues.create(title: 'Issue 1', author_id: nil, project_id: 1)
issues.create(title: 'Issue 2', author_id: user.id, project_id: 1)
issues.create(title: 'Issue 1', author_id: nil, project_id: project.id)
issues.create(title: 'Issue 2', author_id: user.id, project_id: project.id)
end
 
context 'when ghost user exists' do
Loading
Loading
Loading
Loading
@@ -3,7 +3,7 @@
require 'spec_helper'
require Rails.root.join('db', 'post_migrate', '20170324160416_migrate_user_activities_to_users_last_activity_on.rb')
 
describe MigrateUserActivitiesToUsersLastActivityOn, :clean_gitlab_redis_shared_state, :truncate do
describe MigrateUserActivitiesToUsersLastActivityOn, :clean_gitlab_redis_shared_state, :delete do
let(:migration) { described_class.new }
let!(:user_active_1) { create(:user) }
let!(:user_active_2) { create(:user) }
Loading
Loading
Loading
Loading
@@ -3,7 +3,7 @@
require 'spec_helper'
require Rails.root.join('db', 'post_migrate', '20170406142253_migrate_user_project_view.rb')
 
describe MigrateUserProjectView, :truncate do
describe MigrateUserProjectView, :delete do
let(:migration) { described_class.new }
let!(:user) { create(:user, project_view: 'readme') }
 
Loading
Loading
require 'spec_helper'
require Rails.root.join('db', 'post_migrate', '20170815060945_remove_duplicate_mr_events.rb')
 
describe RemoveDuplicateMrEvents, truncate: true do
describe RemoveDuplicateMrEvents, :delete do
let(:migration) { described_class.new }
 
describe '#up' do
Loading
Loading
Loading
Loading
@@ -5,8 +5,8 @@ require Rails.root.join('db', 'post_migrate', '20170313133418_rename_more_reserv
 
# This migration uses multiple threads, and thus different transactions. This
# means data created in this spec may not be visible to some threads. To work
# around this we use the TRUNCATE cleaning strategy.
describe RenameMoreReservedProjectNames, truncate: true do
# around this we use the DELETE cleaning strategy.
describe RenameMoreReservedProjectNames, :delete do
let(:migration) { described_class.new }
let!(:project) { create(:project) }
 
Loading
Loading
Loading
Loading
@@ -5,8 +5,8 @@ require Rails.root.join('db', 'post_migrate', '20161221153951_rename_reserved_pr
 
# This migration uses multiple threads, and thus different transactions. This
# means data created in this spec may not be visible to some threads. To work
# around this we use the TRUNCATE cleaning strategy.
describe RenameReservedProjectNames, truncate: true do
# around this we use the DELETE cleaning strategy.
describe RenameReservedProjectNames, :delete do
let(:migration) { described_class.new }
let!(:project) { create(:project) }
 
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment