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
0
Merge Requests
0
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
Boxiang Sun
gitlab-ce
Commits
78ea074f
Commit
78ea074f
authored
Nov 08, 2017
by
James Edwards-Jones
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Moved LfsIntegrity specs to own file
parent
c76426fc
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
59 additions
and
37 deletions
+59
-37
spec/lib/gitlab/checks/change_access_spec.rb
spec/lib/gitlab/checks/change_access_spec.rb
+6
-37
spec/lib/gitlab/checks/lfs_integrity_spec.rb
spec/lib/gitlab/checks/lfs_integrity_spec.rb
+53
-0
No files found.
spec/lib/gitlab/checks/change_access_spec.rb
View file @
78ea074f
...
@@ -165,47 +165,16 @@ describe Gitlab::Checks::ChangeAccess do
...
@@ -165,47 +165,16 @@ describe Gitlab::Checks::ChangeAccess do
end
end
context
'LFS integrity check'
do
context
'LFS integrity check'
do
let
(
:blob_object
)
{
project
.
repository
.
blob_at_branch
(
'lfs'
,
'files/lfs/lfs_object.iso'
)
}
it
'fails if any LFS blobs are missing'
do
allow_any_instance_of
(
Gitlab
::
Checks
::
LfsIntegrity
).
to
receive
(
:objects_missing?
).
and_return
(
true
)
before
do
expect
{
subject
.
exec
}.
to
raise_error
(
Gitlab
::
GitAccess
::
UnauthorizedError
,
/LFS objects are missing/
)
allow_any_instance_of
(
Gitlab
::
Git
::
RevList
).
to
receive
(
:new_objects
)
do
|&
lazy_block
|
lazy_block
.
call
([
blob_object
.
id
])
end
end
context
'with LFS not enabled'
do
it
'skips integrity check'
do
expect_any_instance_of
(
Gitlab
::
Git
::
RevList
).
not_to
receive
(
:new_objects
)
subject
.
exec
end
end
end
context
'with LFS enabled'
do
it
'succeeds if LFS objects have already been uploaded'
do
before
do
allow_any_instance_of
(
Gitlab
::
Checks
::
LfsIntegrity
).
to
receive
(
:objects_missing?
).
and_return
(
false
)
allow
(
project
).
to
receive
(
:lfs_enabled?
).
and_return
(
true
)
end
context
'deletion'
do
let
(
:changes
)
{
{
oldrev:
oldrev
,
ref:
ref
}
}
it
'skips integrity check'
do
expect_any_instance_of
(
Gitlab
::
Git
::
RevList
).
not_to
receive
(
:new_objects
)
subject
.
exec
expect
{
subject
.
exec
}.
not_to
raise_error
end
end
it
'fails if any LFS blobs are missing'
do
expect
{
subject
.
exec
}.
to
raise_error
(
Gitlab
::
GitAccess
::
UnauthorizedError
,
/LFS objects are missing/
)
end
it
'succeeds if LFS objects have already been uploaded'
do
lfs_object
=
create
(
:lfs_object
,
oid:
blob_object
.
lfs_oid
)
create
(
:lfs_objects_project
,
project:
project
,
lfs_object:
lfs_object
)
expect
{
subject
.
exec
}.
not_to
raise_error
end
end
end
end
end
end
end
...
...
spec/lib/gitlab/checks/lfs_integrity_spec.rb
0 → 100644
View file @
78ea074f
require
'spec_helper'
describe
Gitlab
::
Checks
::
LfsIntegrity
do
let
(
:project
)
{
create
(
:project
,
:repository
)
}
let
(
:newrev
)
{
'54fcc214b94e78d7a41a9a8fe6d87a5e59500e51'
}
subject
{
described_class
.
new
(
project
,
newrev
)
}
describe
'#objects_missing?'
do
let
(
:blob_object
)
{
project
.
repository
.
blob_at_branch
(
'lfs'
,
'files/lfs/lfs_object.iso'
)
}
before
do
allow_any_instance_of
(
Gitlab
::
Git
::
RevList
).
to
receive
(
:new_objects
)
do
|&
lazy_block
|
lazy_block
.
call
([
blob_object
.
id
])
end
end
context
'with LFS not enabled'
do
it
'skips integrity check'
do
expect_any_instance_of
(
Gitlab
::
Git
::
RevList
).
not_to
receive
(
:new_objects
)
subject
.
objects_missing?
end
end
context
'with LFS enabled'
do
before
do
allow
(
project
).
to
receive
(
:lfs_enabled?
).
and_return
(
true
)
end
context
'deletion'
do
let
(
:newrev
)
{
nil
}
it
'skips integrity check'
do
expect_any_instance_of
(
Gitlab
::
Git
::
RevList
).
not_to
receive
(
:new_objects
)
expect
(
subject
.
objects_missing?
).
to
be_falsey
end
end
it
'is true if any LFS blobs are missing'
do
expect
(
subject
.
objects_missing?
).
to
be_truthy
end
it
'is false if LFS objects have already been uploaded'
do
lfs_object
=
create
(
:lfs_object
,
oid:
blob_object
.
lfs_oid
)
create
(
:lfs_objects_project
,
project:
project
,
lfs_object:
lfs_object
)
expect
(
subject
.
objects_missing?
).
to
be_falsey
end
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