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
433ef188
Commit
433ef188
authored
Jul 07, 2017
by
Douglas Barbosa Alexandre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor Geo::ProjectSyncWorker
parent
24b04198
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
52 additions
and
2 deletions
+52
-2
app/models/geo/project_registry.rb
app/models/geo/project_registry.rb
+8
-0
app/workers/geo/project_sync_worker.rb
app/workers/geo/project_sync_worker.rb
+2
-2
spec/models/geo/project_registry_spec.rb
spec/models/geo/project_registry_spec.rb
+42
-0
No files found.
app/models/geo/project_registry.rb
View file @
433ef188
...
...
@@ -11,6 +11,14 @@ class Geo::ProjectRegistry < Geo::BaseRegistry
.
where
(
resync_repository:
false
,
resync_wiki:
false
)
end
def
resync_repository?
resync_repository
||
last_repository_successful_sync_at
.
nil?
end
def
resync_wiki?
resync_wiki
||
last_wiki_successful_sync_at
.
nil?
end
def
repository_synced_since?
(
timestamp
)
last_repository_synced_at
&&
last_repository_synced_at
>
timestamp
end
...
...
app/workers/geo/project_sync_worker.rb
View file @
433ef188
...
...
@@ -25,12 +25,12 @@ module Geo
def
sync_repository?
(
registry
,
scheduled_time
)
!
registry
.
repository_synced_since?
(
scheduled_time
)
&&
(
registry
.
resync_repository?
||
registry
.
last_repository_successful_sync_at
.
nil?
)
registry
.
resync_repository?
end
def
sync_wiki?
(
registry
,
scheduled_time
)
!
registry
.
wiki_synced_since?
(
scheduled_time
)
&&
(
registry
.
resync_wiki?
||
registry
.
last_wiki_successful_sync_at
.
nil?
)
registry
.
resync_wiki?
end
end
end
spec/models/geo/project_registry_spec.rb
View file @
433ef188
...
...
@@ -32,6 +32,48 @@ describe Geo::ProjectRegistry, models: true do
end
end
describe
'#resync_repository?'
do
it
'returns true when resync_repository is true'
do
subject
.
resync_repository
=
true
expect
(
subject
.
resync_repository
).
to
be
true
end
it
'returns true when last_repository_successful_sync_at is nil'
do
subject
.
last_repository_successful_sync_at
=
nil
expect
(
subject
.
resync_repository
).
to
be
true
end
it
'returns false when resync_repository is false and last_repository_successful_sync_at is present'
do
subject
.
resync_repository
=
false
subject
.
last_repository_successful_sync_at
=
Time
.
now
expect
(
subject
.
resync_repository
).
to
be
false
end
end
describe
'#resync_wiki?'
do
it
'returns true when resync_wiki is true'
do
subject
.
resync_wiki
=
true
expect
(
subject
.
resync_wiki
).
to
be
true
end
it
'returns true when last_wiki_successful_sync_at is nil'
do
subject
.
last_wiki_successful_sync_at
=
nil
expect
(
subject
.
resync_wiki
).
to
be
true
end
it
'returns false when resync_wiki is false and last_wiki_successful_sync_at is present'
do
subject
.
resync_wiki
=
false
subject
.
last_wiki_successful_sync_at
=
Time
.
now
expect
(
subject
.
resync_wiki
).
to
be
false
end
end
describe
'#repository_synced_since?'
do
it
'returns false when last_repository_synced_at is nil'
do
subject
.
last_repository_synced_at
=
nil
...
...
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