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
e191eb67
Commit
e191eb67
authored
Jun 20, 2017
by
Douglas Barbosa Alexandre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Does not return dirty projects on Geo::ProjectRegistry.synced
parent
8593cf86
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
52 additions
and
1 deletion
+52
-1
app/models/geo/project_registry.rb
app/models/geo/project_registry.rb
+5
-1
spec/models/geo/project_registry_spec.rb
spec/models/geo/project_registry_spec.rb
+47
-0
No files found.
app/models/geo/project_registry.rb
View file @
e191eb67
...
...
@@ -5,5 +5,9 @@ class Geo::ProjectRegistry < Geo::BaseRegistry
scope
:dirty
,
->
{
where
(
arel_table
[
:resync_repository
].
eq
(
true
).
or
(
arel_table
[
:resync_wiki
].
eq
(
true
)))
}
scope
:failed
,
->
{
where
.
not
(
last_repository_synced_at:
nil
).
where
(
last_repository_successful_sync_at:
nil
)
}
scope
:synced
,
->
{
where
.
not
(
last_repository_synced_at:
nil
,
last_repository_successful_sync_at:
nil
)
}
def
self
.
synced
where
.
not
(
last_repository_synced_at:
nil
,
last_repository_successful_sync_at:
nil
)
.
where
(
resync_repository:
false
,
resync_wiki:
false
)
end
end
spec/models/geo/project_registry_spec.rb
View file @
e191eb67
...
...
@@ -8,4 +8,51 @@ describe Geo::ProjectRegistry, models: true do
describe
'validations'
do
it
{
is_expected
.
to
validate_presence_of
(
:project
)
}
end
describe
'.synced'
do
let
(
:project
)
{
create
(
:empty_project
)
}
let
(
:synced_at
)
{
Time
.
now
}
it
'does not return dirty projects'
do
Geo
::
ProjectRegistry
.
create
(
project:
project
,
last_repository_synced_at:
synced_at
,
last_repository_successful_sync_at:
synced_at
,
last_wiki_synced_at:
synced_at
,
last_wiki_successful_sync_at:
synced_at
,
resync_repository:
true
,
resync_wiki:
true
)
expect
(
described_class
.
synced
).
to
be_empty
end
it
'does not return projects where last attempt to sync failed'
do
Geo
::
ProjectRegistry
.
create
(
project:
project
,
last_repository_synced_at:
synced_at
,
last_repository_successful_sync_at:
nil
,
last_wiki_synced_at:
synced_at
,
last_wiki_successful_sync_at:
nil
,
resync_repository:
true
,
resync_wiki:
true
)
expect
(
described_class
.
synced
).
to
be_empty
end
it
'returns synced projects'
do
registry
=
Geo
::
ProjectRegistry
.
create
(
project:
project
,
last_repository_synced_at:
synced_at
,
last_repository_successful_sync_at:
synced_at
,
last_wiki_synced_at:
synced_at
,
last_wiki_successful_sync_at:
synced_at
,
resync_repository:
false
,
resync_wiki:
false
)
expect
(
described_class
.
synced
).
to
match_array
([
registry
])
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