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
4abecc72
Commit
4abecc72
authored
Aug 06, 2018
by
Gabriel Mazetto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added specs for new methods in project_registry
parent
82d6d3ab
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
135 additions
and
1 deletion
+135
-1
ee/app/models/geo/project_registry.rb
ee/app/models/geo/project_registry.rb
+22
-1
ee/spec/models/geo/project_registry_spec.rb
ee/spec/models/geo/project_registry_spec.rb
+113
-0
No files found.
ee/app/models/geo/project_registry.rb
View file @
4abecc72
...
...
@@ -168,14 +168,29 @@ class Geo::ProjectRegistry < Geo::BaseRegistry
project
.
wiki_enabled?
&&
(
never_synced_wiki?
||
wiki_sync_needed?
(
scheduled_time
))
end
# Returns whether repository is pending verification check
#
# This will check for missing verification checksum sha
#
# @return [Boolean] whether repository is pending verification
def
repository_verification_pending?
self
.
repository_verification_checksum_sha
.
nil?
end
# Returns whether wiki is pending verification check
#
# This will check for missing verification checksum sha
#
# @return [Boolean] whether wiki is pending verification
def
wiki_verification_pending?
self
.
wiki_verification_checksum_sha
.
nil?
end
# Returns wheter verification is pending for either wiki or repository
#
# This will check for missing verification checksum sha for both wiki and repository
#
# @return [Boolean] whether verification is pending for either wiki or repository
def
verification_pending?
repository_verification_pending?
||
wiki_verification_pending?
end
...
...
@@ -214,16 +229,22 @@ class Geo::ProjectRegistry < Geo::BaseRegistry
end
# Flag the repository to be re-checked
#
# This operation happens only in the database and the recheck will be triggered after by the cron job
def
flag_repository_for_recheck!
self
.
update
(
repository_verification_checksum_sha:
nil
,
last_repository_verification_failure:
nil
,
repository_checksum_mismatch:
false
)
end
# Flag the repository to be re-synced
#
# This operation happens only in the database and the resync will be triggered after by the cron job
def
flag_repository_for_resync!
repository_updated!
(
:repository
,
Time
.
now
)
end
# Flag the repository to perform a full re-download
#
# This operation happens only in the database and the forced re-download will be triggered after by the cron job
def
flag_repository_for_redownload!
self
.
update
(
resync_repository:
true
,
force_to_redownload_repository:
true
)
end
...
...
@@ -235,7 +256,7 @@ class Geo::ProjectRegistry < Geo::BaseRegistry
#
# @return [Boolean] whether the registry is candidate for a re-download
def
candidate_for_redownload?
self
.
repository_retry_count
&&
self
.
repository_retry_count
>
=
1
self
.
repository_retry_count
&&
self
.
repository_retry_count
>
1
end
private
...
...
ee/spec/models/geo/project_registry_spec.rb
View file @
4abecc72
...
...
@@ -762,4 +762,117 @@ describe Geo::ProjectRegistry do
end
end
end
describe
'#repository_verification_pending?'
do
it
'returns true when outdated'
do
registry
=
create
(
:geo_project_registry
,
:repository_verification_outdated
)
expect
(
registry
.
repository_verification_pending?
).
to
be_truthy
end
it
'returns true when we are missing checksum sha'
do
registry
=
create
(
:geo_project_registry
,
:repository_verification_failed
)
expect
(
registry
.
repository_verification_pending?
).
to
be_truthy
end
it
'returns false when checksum is present'
do
registry
=
create
(
:geo_project_registry
,
:repository_verified
)
expect
(
registry
.
repository_verification_pending?
).
to
be_falsey
end
end
describe
'#wiki_verification_pending?'
do
it
'returns true when outdated'
do
registry
=
create
(
:geo_project_registry
,
:wiki_verification_outdated
)
expect
(
registry
.
wiki_verification_pending?
).
to
be_truthy
end
it
'returns true when we are missing checksum sha'
do
registry
=
create
(
:geo_project_registry
,
:wiki_verification_failed
)
expect
(
registry
.
wiki_verification_pending?
).
to
be_truthy
end
it
'returns false when checksum is present'
do
registry
=
create
(
:geo_project_registry
,
:wiki_verified
)
expect
(
registry
.
wiki_verification_pending?
).
to
be_falsey
end
end
describe
'verification_pending?'
do
it
'returns true when either wiki or repository verification is pending'
do
repo_registry
=
create
(
:geo_project_registry
,
:repository_verification_outdated
)
wiki_registry
=
create
(
:geo_project_registry
,
:wiki_verification_failed
)
expect
(
repo_registry
.
verification_pending?
).
to
be_truthy
expect
(
wiki_registry
.
verification_pending?
).
to
be_truthy
end
it
'returns false when both wiki and repository verification is present'
do
registry
=
create
(
:geo_project_registry
,
:repository_verified
,
:wiki_verified
)
expect
(
registry
.
verification_pending?
).
to
be_falsey
end
end
describe
'#flag_repository_for_recheck!'
do
it
'modified record to a recheck state'
do
registry
=
create
(
:geo_project_registry
,
:repository_verified
)
registry
.
flag_repository_for_recheck!
expect
(
registry
).
to
have_attributes
(
repository_verification_checksum_sha:
nil
,
last_repository_verification_failure:
nil
,
repository_checksum_mismatch:
false
)
end
end
describe
'#flag_repository_for_resync!'
do
it
'modified record to a resync state'
do
registry
=
create
(
:geo_project_registry
,
:synced
)
registry
.
flag_repository_for_resync!
expect
(
registry
).
to
have_attributes
(
resync_repository:
true
,
repository_verification_checksum_sha:
nil
,
last_repository_verification_failure:
nil
,
repository_checksum_mismatch:
false
,
repository_verification_retry_count:
nil
,
repository_retry_count:
nil
,
repository_retry_at:
nil
)
end
end
describe
'#flag_repository_for_redownload!'
do
it
'modified record to a recheck state'
do
registry
=
create
(
:geo_project_registry
,
:repository_verified
)
registry
.
flag_repository_for_redownload!
expect
(
registry
).
to
have_attributes
(
resync_repository:
true
,
force_to_redownload_repository:
true
)
end
end
describe
'#candidate_for_redownload?'
do
it
'returns false when repository_retry_count is 1 or less'
do
registry
=
create
(
:geo_project_registry
,
:sync_failed
)
expect
(
registry
.
candidate_for_redownload?
).
to
be_falsey
end
it
'returns true when repository_retry_count is > 1'
do
registry
=
create
(
:geo_project_registry
,
:sync_failed
,
repository_retry_count:
2
)
expect
(
registry
.
candidate_for_redownload?
).
to
be_truthy
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