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
053a2c68
Commit
053a2c68
authored
Aug 23, 2017
by
Douglas Barbosa Alexandre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix Geo::ProjectRegistry.failed to count projects where wiki sync failed
parent
a240dbab
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
52 additions
and
1 deletion
+52
-1
app/models/geo/project_registry.rb
app/models/geo/project_registry.rb
+10
-1
spec/factories/geo/project_registry.rb
spec/factories/geo/project_registry.rb
+18
-0
spec/models/geo/project_registry_spec.rb
spec/models/geo/project_registry_spec.rb
+24
-0
No files found.
app/models/geo/project_registry.rb
View file @
053a2c68
...
...
@@ -4,7 +4,16 @@ class Geo::ProjectRegistry < Geo::BaseRegistry
validates
:project
,
presence:
true
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
)
}
def
self
.
failed
repository_sync_failed
=
arel_table
[
:last_repository_synced_at
].
not_eq
(
nil
)
.
and
(
arel_table
[
:last_repository_successful_sync_at
].
eq
(
nil
))
wiki_sync_failed
=
arel_table
[
:last_wiki_synced_at
].
not_eq
(
nil
)
.
and
(
arel_table
[
:last_wiki_successful_sync_at
].
eq
(
nil
))
where
(
repository_sync_failed
.
or
(
wiki_sync_failed
))
end
def
self
.
synced
where
.
not
(
last_repository_synced_at:
nil
,
last_repository_successful_sync_at:
nil
)
...
...
spec/factories/geo/project_registry.rb
View file @
053a2c68
...
...
@@ -40,5 +40,23 @@ FactoryGirl.define do
resync_repository
true
resync_wiki
true
end
trait
:repository_sync_failed
do
last_repository_synced_at
{
5
.
days
.
ago
}
last_repository_successful_sync_at
nil
last_wiki_synced_at
{
5
.
days
.
ago
}
last_wiki_successful_sync_at
{
5
.
days
.
ago
}
resync_repository
true
resync_wiki
false
end
trait
:wiki_sync_failed
do
last_repository_synced_at
{
5
.
days
.
ago
}
last_repository_successful_sync_at
{
5
.
days
.
ago
}
last_wiki_synced_at
{
5
.
days
.
ago
}
last_wiki_successful_sync_at
nil
resync_repository
false
resync_wiki
true
end
end
end
spec/models/geo/project_registry_spec.rb
View file @
053a2c68
...
...
@@ -9,6 +9,30 @@ describe Geo::ProjectRegistry do
it
{
is_expected
.
to
validate_presence_of
(
:project
)
}
end
describe
'.failed'
do
let
(
:project
)
{
create
(
:project
)
}
let
(
:synced_at
)
{
Time
.
now
}
it
'does not return synced projects'
do
create
(
:geo_project_registry
,
:synced
,
project:
project
)
expect
(
described_class
.
failed
).
to
be_empty
end
it
'does not return dirty projects'
do
create
(
:geo_project_registry
,
:synced
,
:dirty
,
project:
project
)
expect
(
described_class
.
synced
).
to
be_empty
end
it
'returns projects where last attempt to sync failed'
do
repository_sync_failed
=
create
(
:geo_project_registry
,
:repository_sync_failed
,
project:
project
)
wiki_sync_failed
=
create
(
:geo_project_registry
,
:wiki_sync_failed
,
project:
project
)
expect
(
described_class
.
failed
).
to
match_array
([
repository_sync_failed
,
wiki_sync_failed
])
end
end
describe
'.synced'
do
let
(
:project
)
{
create
(
:project
)
}
let
(
:synced_at
)
{
Time
.
now
}
...
...
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