Commit 942c30de authored by Dylan Griffith's avatar Dylan Griffith

Merge branch 'fj-fix-snippet-import-from-database' into 'master'

Change snippet import logic from db

See merge request gitlab-org/gitlab!33506
parents ff596a68 cc9fbfcc
---
title: Fix snippet repository import edge cases
merge_request: 33506
author:
type: fixed
......@@ -34,14 +34,7 @@ module Gitlab
end
def create_repository_from_db
snippet.create_repository
commit_attrs = {
branch_name: 'master',
message: 'Initial commit'
}
repository.create_file(@user, snippet.file_name, snippet.content, commit_attrs)
Gitlab::BackgroundMigration::BackfillSnippetRepositories.new.perform_by_ids([snippet.id])
end
end
end
......
......@@ -25,10 +25,9 @@ describe Gitlab::ImportExport::SnippetRepoRestorer do
expect(snippet.repository_exists?).to be_falsey
aggregate_failures do
expect(restorer.restore).to be_truthy
expect(snippet.repository_exists?).to be_truthy
expect(snippet.snippet_repository).not_to be_nil
expect do
expect(restorer.restore).to be_truthy
end.to change { SnippetRepository.count }.by(1)
blob = snippet.repository.blob_at('HEAD', snippet.file_name)
expect(blob).not_to be_nil
......
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