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
c5f6766a
Commit
c5f6766a
authored
Feb 07, 2020
by
nmilojevic1
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add specs for create_from_bundle
- Change response for method
parent
a1c10909
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
42 additions
and
4 deletions
+42
-4
app/models/repository.rb
app/models/repository.rb
+3
-4
spec/models/repository_spec.rb
spec/models/repository_spec.rb
+39
-0
No files found.
app/models/repository.rb
View file @
c5f6766a
...
...
@@ -1131,10 +1131,9 @@ class Repository
end
def
create_from_bundle
(
bundle_path
)
raw
.
create_from_bundle
(
bundle_path
)
after_create
true
raw
.
create_from_bundle
(
bundle_path
).
tap
do
|
result
|
after_create
if
result
end
end
def
blobs_metadata
(
paths
,
ref
=
'HEAD'
)
...
...
spec/models/repository_spec.rb
View file @
c5f6766a
...
...
@@ -2781,6 +2781,45 @@ describe Repository do
end
end
describe
'#create_from_bundle'
do
let
(
:project
)
{
create
(
:project
)
}
let
(
:repository
)
{
project
.
repository
}
let
(
:valid_bundle_path
)
{
File
.
join
(
Dir
.
tmpdir
,
"repo-
#{
SecureRandom
.
hex
}
.bundle"
)
}
let
(
:raw_repository
)
{
repository
.
raw
}
before
do
allow
(
raw_repository
).
to
receive
(
:create_from_bundle
).
and_return
({})
end
after
do
FileUtils
.
rm_rf
(
valid_bundle_path
)
end
it
'calls out to the raw_repository to create a repo from bundle'
do
expect
(
raw_repository
).
to
receive
(
:create_from_bundle
)
repository
.
create_from_bundle
(
valid_bundle_path
)
end
it
'calls after_create'
do
expect
(
repository
).
to
receive
(
:after_create
)
repository
.
create_from_bundle
(
valid_bundle_path
)
end
context
'when exception is raised'
do
before
do
allow
(
raw_repository
).
to
receive
(
:create_from_bundle
).
and_raise
(
::
Gitlab
::
Git
::
BundleFile
::
InvalidBundleError
)
end
it
'after_create is not executed'
do
expect
(
repository
).
not_to
receive
(
:after_create
)
expect
{
repository
.
create_from_bundle
(
valid_bundle_path
)}.
to
raise_error
(
::
Gitlab
::
Git
::
BundleFile
::
InvalidBundleError
)
end
end
end
describe
"#blobs_metadata"
do
let_it_be
(
:project
)
{
create
(
:project
,
:repository
)
}
let
(
:repository
)
{
project
.
repository
}
...
...
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