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
4e10a8db
Commit
4e10a8db
authored
Jul 01, 2020
by
Francisco Javier López
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update snippet statistics after bundle import
parent
85461b92
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
31 additions
and
0 deletions
+31
-0
changelogs/unreleased/fj-223731-update-snippet-statistics-on-project-import.yml
...fj-223731-update-snippet-statistics-on-project-import.yml
+5
-0
lib/gitlab/import_export/snippet_repo_restorer.rb
lib/gitlab/import_export/snippet_repo_restorer.rb
+2
-0
spec/lib/gitlab/import_export/snippet_repo_restorer_spec.rb
spec/lib/gitlab/import_export/snippet_repo_restorer_spec.rb
+24
-0
No files found.
changelogs/unreleased/fj-223731-update-snippet-statistics-on-project-import.yml
0 → 100644
View file @
4e10a8db
---
title
:
Update snippet statistics after project import
merge_request
:
35730
author
:
type
:
changed
lib/gitlab/import_export/snippet_repo_restorer.rb
View file @
4e10a8db
...
...
@@ -42,6 +42,8 @@ module Gitlab
snippet
.
repository
.
expire_exists_cache
raise
SnippetRepositoryError
,
_
(
"Invalid repository bundle for snippet with id %{snippet_id}"
)
%
{
snippet_id:
snippet
.
id
}
else
Snippets
::
UpdateStatisticsService
.
new
(
snippet
).
execute
end
end
...
...
spec/lib/gitlab/import_export/snippet_repo_restorer_spec.rb
View file @
4e10a8db
...
...
@@ -35,6 +35,12 @@ RSpec.describe Gitlab::ImportExport::SnippetRepoRestorer do
end
end
it
'does not call snippet update statistics service'
do
expect
(
Snippets
::
UpdateStatisticsService
).
not_to
receive
(
:new
).
with
(
snippet
)
restorer
.
restore
end
context
'when the repository creation fails'
do
it
'returns false'
do
allow_any_instance_of
(
Gitlab
::
BackgroundMigration
::
BackfillSnippetRepositories
).
to
receive
(
:perform_by_ids
).
and_return
(
nil
)
...
...
@@ -66,6 +72,10 @@ RSpec.describe Gitlab::ImportExport::SnippetRepoRestorer do
before
do
expect
(
exporter
.
save
).
to
be_truthy
allow_next_instance_of
(
Snippets
::
RepositoryValidationService
)
do
|
instance
|
allow
(
instance
).
to
receive
(
:execute
).
and_return
(
ServiceResponse
.
success
)
end
end
context
'when it is valid'
do
...
...
@@ -115,5 +125,19 @@ RSpec.describe Gitlab::ImportExport::SnippetRepoRestorer do
end
end
end
it
'refreshes snippet statistics'
do
expect
(
snippet
.
statistics
.
commit_count
).
to
be_zero
expect
(
snippet
.
statistics
.
file_count
).
to
be_zero
expect
(
snippet
.
statistics
.
repository_size
).
to
be_zero
expect
(
Snippets
::
UpdateStatisticsService
).
to
receive
(
:new
).
with
(
snippet
).
and_call_original
restorer
.
restore
expect
(
snippet
.
statistics
.
commit_count
).
not_to
be_zero
expect
(
snippet
.
statistics
.
file_count
).
not_to
be_zero
expect
(
snippet
.
statistics
.
repository_size
).
not_to
be_zero
end
end
end
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