Commit ecf90a8e authored by Gabriel Mazetto's avatar Gabriel Mazetto Committed by Douglas Barbosa Alexandre

Geo: Added `All` tab in Geo Nodes > Projects

parent 0c90b5a9
......@@ -16,8 +16,10 @@ class Admin::Geo::ProjectsController < Admin::ApplicationController
finder.failed_projects.page(params[:page])
when 'pending'
finder.pending_projects.page(params[:page])
else
when 'synced'
finder.synced_projects.page(params[:page])
else
finder.all_projects.page(params[:page])
end
end
......
......@@ -7,6 +7,12 @@ module Geo
# synchronization, as we are concerned in filtering for displaying rather then
# filtering for processing.
class ProjectRegistryStatusFinder < RegistryFinder
# Returns all project registry
#
def all_projects
Geo::ProjectRegistry.with_routes
end
# Returns any project registry which project is fully synced
#
# We consider fully synced any project without pending actions
......@@ -21,7 +27,7 @@ module Geo
no_repository_resync
.and(no_repository_sync_failure)
.and(repository_verified)
).includes(project: :route).includes(project: { namespace: :route })
).with_routes
end
# rubocop: enable CodeReuse/ActiveRecord
......@@ -43,7 +49,7 @@ module Geo
.and(flagged_for_resync
.or(repository_pending_verification
.and(repository_without_verification_failure_before)))
).includes(project: :route).includes(project: { namespace: :route })
).with_routes
end
# rubocop: enable CodeReuse/ActiveRecord
......@@ -60,7 +66,7 @@ module Geo
repository_sync_failed
.or(repository_verification_failed)
.or(repository_checksum_mismatch)
).includes(project: :route).includes(project: { namespace: :route })
).with_routes
end
# rubocop: enable CodeReuse/ActiveRecord
......@@ -70,9 +76,7 @@ module Geo
# for performance reasons.
# rubocop: disable CodeReuse/ActiveRecord
def never_synced_projects
Geo::ProjectRegistry.where(last_repository_successful_sync_at: nil)
.includes(project: :route)
.includes(project: { namespace: :route })
Geo::ProjectRegistry.where(last_repository_successful_sync_at: nil).with_routes
end
# rubocop: enable CodeReuse/ActiveRecord
......
# frozen_string_literal: true
module EE
module GeoHelper
STATUS_ICON_NAMES_BY_STATE = {
synced: 'check',
pending: 'clock-o',
failed: 'exclamation-triangle',
never: 'circle-o'
}.freeze
def node_vue_list_properties
version, revision =
if ::Gitlab::Geo.primary?
......@@ -74,5 +83,48 @@ module EE
title: title,
data: data
end
def project_registry_status(project_registry)
status_type = case project_registry.synchronization_state
when :failed then
'status-type-failure'
when :synced then
'status-type-success'
end
content_tag(:div, class: "project-status-content #{status_type}") do
icon = project_registry_status_icon(project_registry)
text = project_registry_status_text(project_registry)
[icon, text].join(' ').html_safe
end
end
def project_registry_status_icon(project_registry)
icon(STATUS_ICON_NAMES_BY_STATE.fetch(project_registry.synchronization_state, 'exclamation-triangle'))
end
def project_registry_status_text(project_registry)
case project_registry.synchronization_state
when :never
s_('Geo|Not synced yet')
when :failed
s_('Geo|Failed')
when :pending
if project_registry.pending_synchronization?
s_('Geo|Pending synchronization')
elsif project_registry.pending_verification?
s_('Geo|Pending verification')
else
# should never reach this state, unless we introduce new behavior
s_('Geo|Unknown state')
end
when :synced
s_('Geo|In sync')
else
# should never reach this state, unless we introduce new behavior
s_('Geo|Unknown state')
end
end
end
end
......@@ -33,6 +33,7 @@ class Geo::ProjectRegistry < Geo::BaseRegistry
scope :verification_failed_wikis, -> { where.not(last_wiki_verification_failure: nil) }
scope :repository_checksum_mismatch, -> { where(repository_checksum_mismatch: true) }
scope :wiki_checksum_mismatch, -> { where(wiki_checksum_mismatch: true) }
scope :with_routes, -> { includes(project: :route).includes(project: { namespace: :route }) }
def self.failed
repository_sync_failed = arel_table[:repository_retry_count].gt(0)
......@@ -201,15 +202,19 @@ class Geo::ProjectRegistry < Geo::BaseRegistry
self.wiki_verification_checksum_sha.nil?
end
# Returns wheter verification is pending for either wiki or repository
# Returns whether 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?
def pending_verification?
repository_verification_pending? || wiki_verification_pending?
end
def pending_synchronization?
resync_repository? || resync_wiki?
end
def syncs_since_gc
Gitlab::Redis::SharedState.with { |redis| redis.get(fetches_since_gc_redis_key).to_i }
end
......@@ -274,8 +279,42 @@ class Geo::ProjectRegistry < Geo::BaseRegistry
self.repository_retry_count && self.repository_retry_count > 1
end
# Returns a synchronization state based on existing attribute values
#
# It takes into account things like if a successful replication has been done
# if there are pending actions or existing errors
#
# @return [Symbol] :never, :failed:, :pending or :synced
def synchronization_state
return :never if has_never_attempted_any_operation?
return :failed if has_failed_operation?
return :pending if has_pending_operation?
:synced
end
private
# Whether any operation has ever been attempted
#
# This is intended to determine if it's a brand new registry that has never tried to sync before
def has_never_attempted_any_operation?
last_repository_successful_sync_at.nil? && last_repository_synced_at.nil?
end
# Whether there is a pending synchronization or verification
#
# This check is intended to be used as part of the #synchronization_state
# It does omit previous checks as they are intended to be done in sequence.
def has_pending_operation?
resync_repository || repository_verification_checksum_sha.nil?
end
# Whether a synchronization or verification failed
def has_failed_operation?
repository_retry_count || last_repository_verification_failure || repository_checksum_mismatch
end
def fetches_since_gc_redis_key
"projects/#{project_id}/fetches_since_gc"
end
......
- @registries.each do |project_registry|
.card.project-card.prepend-top-15
.card-header{ id: "project-#{project_registry.project_id}-header" }
.d-flex
- if project_registry.project.nil?
= render partial: 'removed', locals: { project_registry: project_registry }
- else
%strong.header-text-primary.flex-fill
= link_to project_registry.project.full_name, admin_namespace_project_path(project_registry.project.namespace, project_registry.project)
- unless project_registry.pending_verification?
= link_to(recheck_admin_geo_project_path(project_registry), method: :post, class: 'btn btn-default btn-sm mr-2') do
= s_('Geo|Recheck')
- unless project_registry.resync_repository?
= link_to(resync_admin_geo_project_path(project_registry), method: :post, class: 'btn btn-default-primary btn-sm') do
= s_('Geo|Resync')
= render partial: "registry_#{project_registry.synchronization_state}", locals: { project_registry: project_registry }
= paginate @registries, theme: 'gitlab'
......@@ -8,65 +8,11 @@
%strong.header-text-primary.flex-fill
= link_to project_registry.project.full_name, admin_namespace_project_path(project_registry.project.namespace, project_registry.project)
- if project_registry.candidate_for_redownload?
= link_to(force_redownload_admin_geo_project_path(project_registry), method: :post, class: 'btn btn-outline btn-sm mr-2') do
= link_to(force_redownload_admin_geo_project_path(project_registry), method: :post, class: 'btn btn-default btn-sm mr-2') do
= s_('Geo|Redownload')
= link_to(resync_admin_geo_project_path(project_registry), method: :post, class: 'btn btn-outline-primary btn-sm') do
= link_to(resync_admin_geo_project_path(project_registry), method: :post, class: 'btn btn-default-primary btn-sm') do
= s_('Geo|Resync')
.card-body
.container.project-container
.row
.col-sm.project-status-container
.project-status-title.text-muted
= s_('Geo|Status')
.project-status-content.status-type-failure
= s_('Geo|Failed')
.col-sm.project-status-container
.project-status-title.text-muted
= s_('Geo|Next sync scheduled at')
.project-status-content
- if project_registry.repository_retry_at
= distance_of_time_in_words(Time.now, project_registry.repository_retry_at)
- else
= s_('Geo|Waiting for scheduler')
.col-sm.project-status-container
.project-status-title.text-muted
= s_('Geo|Last sync attempt')
.project-status-content
- if project_registry.last_repository_synced_at
= time_ago_with_tooltip(project_registry.last_repository_synced_at, placement: 'bottom')
- else
= s_('Geo|Waiting for scheduler')
.col-sm.project-status-container
.project-status-title.text-muted
= s_('Geo|Retry count')
.project-status-content
= project_registry.repository_retry_count.nil? ? 0 : project_registry.repository_retry_count
.project-card-errors
.card-header.bg-transparent.border-bottom-0.border-top
%button.btn.btn-link.btn-card-header.collapsed.d-flex{ type: 'button',
data: { toggle: 'collapse', target: "#project-errors-#{project_registry.project_id}" },
'aria-expanded' => 'false',
'aria-controls' => "project-errors-#{project_registry.project_id}" }
= sprite_icon('chevron-down', size: 18, css_class: 'append-right-5 card-expand-icon')
= sprite_icon('chevron-up', size: 18, css_class: 'append-right-5 card-collapse-icon')
.header-text-secondary
More
.collapse{ id: "project-errors-#{project_registry.project_id}",
'aria-labelledby' => "project-#{project_registry.project_id}-header" }
.card-body
.container.project-container
%ul.unstyled-list.errors-list
- if project_registry.last_repository_sync_failure
%li.p-0.d-flex
= sprite_icon('warning', size: 18, css_class: 'error-icon')
%span.error-text.prepend-left-5
= s_('Geo|Synchronization failed - %{error}') % { error: project_registry.last_repository_sync_failure }
- if project_registry.last_repository_verification_failure
%li.p-0.d-flex
= sprite_icon('warning', size: 18, css_class: 'error-icon')
%span.error-text.prepend-left-5
= s_('Geo|Verification failed - %{error}') % { error: project_registry.last_repository_verification_failure }
= render partial: 'registry_failed', locals: { project_registry: project_registry }
= paginate @registries, theme: 'gitlab'
......@@ -8,37 +8,6 @@
%strong.header-text-primary.flex-fill
= link_to project_registry.project.full_name, admin_namespace_project_path(project_registry.project.namespace, project_registry.project)
.card-body
.container.project-container
.row
.col-sm.project-status-container
.project-status-title.text-muted
= s_('Geo|Next sync scheduled at')
.project-status-content
- if project_registry.repository_retry_at
= distance_of_time_in_words(Time.now, project_registry.repository_retry_at)
- else
= s_('Geo|Waiting for scheduler')
.col-sm.project-status-container
.project-status-title.text-muted
= s_('Geo|Last sync attempt')
.project-status-content
- if project_registry.last_repository_synced_at
= time_ago_with_tooltip(project_registry.last_repository_synced_at, placement: 'bottom')
- else
= s_('Geo|Waiting for scheduler')
.col-sm.project-status-container
.project-status-title.text-muted
= s_('Geo|Retry counts')
.project-status-content
= project_registry.repository_retry_count
.col-sm.project-status-container
.project-status-title.text-muted
= s_('Geo|Error message')
.project-status-content.font-weight-bold
- if project_registry
= project_registry.last_repository_sync_failure
- else
= s_('Geo|No errors')
= render partial: 'registry_never', locals: { project_registry: project_registry }
= paginate @registries, theme: 'gitlab'
......@@ -7,42 +7,13 @@
- else
%strong.header-text-primary.flex-fill
= link_to project_registry.project.full_name, admin_namespace_project_path(project_registry.project.namespace, project_registry.project)
- unless project_registry.verification_pending?
= link_to(recheck_admin_geo_project_path(project_registry), method: :post, class: 'btn btn-outline btn-sm mr-2') do
- unless project_registry.pending_verification?
= link_to(recheck_admin_geo_project_path(project_registry), method: :post, class: 'btn btn-default btn-sm mr-2') do
= s_('Geo|Recheck')
- unless project_registry.resync_repository?
= link_to(resync_admin_geo_project_path(project_registry), method: :post, class: 'btn btn-outline-primary btn-sm') do
= link_to(resync_admin_geo_project_path(project_registry), method: :post, class: 'btn btn-default-primary btn-sm') do
= s_('Geo|Resync')
.card-body
.container.project-container
.row
.col-sm.project-status-container
.project-status-title.text-muted
= s_('Geo|Status')
.project-status-content
- if project_registry.resync_repository?
= s_('Geo|Pending synchronization')
- elsif project_registry.verification_pending?
= s_('Geo|Pending verification')
- else
= s_('Geo|Unknown state') # should never reach this state, unless we introduce new behavior
.col-sm.project-status-container
.project-status-title.text-muted
= s_('Geo|Next sync scheduled at')
.project-status-content
- if project_registry.repository_retry_at
= distance_of_time_in_words(Time.now, project_registry.repository_retry_at)
- else
= s_('Geo|Waiting for scheduler')
.col-sm.project-status-container
.project-status-title.text-muted
= s_('Geo|Last sync attempt')
.project-status-content
- if project_registry.last_repository_synced_at
= time_ago_with_tooltip(project_registry.last_repository_synced_at, placement: 'bottom')
- else
= s_('Geo|Never')
.col-sm.d-sm-none.d-md-block
= render partial: 'registry_pending', locals: { project_registry: project_registry }
= paginate @registries, theme: 'gitlab'
.card-body
.container.project-container
.row
.col-sm.project-status-container
.project-status-title.text-muted
= s_('Geo|Status')
= project_registry_status(project_registry)
.col-sm.project-status-container
.project-status-title.text-muted
= s_('Geo|Next sync scheduled at')
.project-status-content
- if project_registry.repository_retry_at
= distance_of_time_in_words(Time.now, project_registry.repository_retry_at)
- else
= s_('Geo|Waiting for scheduler')
.col-sm.project-status-container
.project-status-title.text-muted
= s_('Geo|Last sync attempt')
.project-status-content
- if project_registry.last_repository_synced_at
= time_ago_with_tooltip(project_registry.last_repository_synced_at, placement: 'bottom')
- else
= s_('Geo|Waiting for scheduler')
.col-sm.project-status-container
.project-status-title.text-muted
= s_('Geo|Retry count')
.project-status-content
= project_registry.repository_retry_count.nil? ? 0 : project_registry.repository_retry_count
.project-card-errors
.card-header.bg-transparent.border-bottom-0.border-top
%button.btn.btn-link.btn-card-header.collapsed.d-flex{ type: 'button',
data: { toggle: 'collapse', target: "#project-errors-#{project_registry.project_id}" },
'aria-expanded' => 'false',
'aria-controls' => "project-errors-#{project_registry.project_id}" }
= sprite_icon('chevron-down', size: 18, css_class: 'append-right-5 card-expand-icon')
= sprite_icon('chevron-up', size: 18, css_class: 'append-right-5 card-collapse-icon')
.header-text-secondary
More
.collapse{ id: "project-errors-#{project_registry.project_id}",
'aria-labelledby' => "project-#{project_registry.project_id}-header" }
.card-body
.container.project-container
%ul.unstyled-list.errors-list
- if project_registry.last_repository_sync_failure
%li.p-0.d-flex
= sprite_icon('warning', size: 18, css_class: 'error-icon')
%span.error-text.prepend-left-5
= s_('Geo|Synchronization failed - %{error}') % { error: project_registry.last_repository_sync_failure }
- if project_registry.last_repository_verification_failure
%li.p-0.d-flex
= sprite_icon('warning', size: 18, css_class: 'error-icon')
%span.error-text.prepend-left-5
= s_('Geo|Verification failed - %{error}') % { error: project_registry.last_repository_verification_failure }
.card-body
.container.project-container
.row
.col-sm.project-status-container
.project-status-title.text-muted
= s_('Geo|Status')
= project_registry_status(project_registry)
.col-sm.project-status-container
.project-status-title.text-muted
= s_('Geo|Next sync scheduled at')
.project-status-content
- if project_registry.repository_retry_at
= distance_of_time_in_words(Time.now, project_registry.repository_retry_at)
- else
= s_('Geo|Waiting for scheduler')
.col-sm.project-status-container
.project-status-title.text-muted
= s_('Geo|Last sync attempt')
.project-status-content
- if project_registry.last_repository_synced_at
= time_ago_with_tooltip(project_registry.last_repository_synced_at, placement: 'bottom')
- else
= s_('Geo|Waiting for scheduler')
.col-sm.project-status-container
.project-status-title.text-muted
= s_('Geo|Retry counts')
.project-status-content
= project_registry.repository_retry_count.nil? ? 0 : project_registry.repository_retry_count
- if project_registry.last_repository_sync_failure || project_registry.last_repository_verification_failure
.project-card-errors
.card-header.bg-transparent.border-bottom-0.border-top
%button.btn.btn-link.btn-card-header.collapsed.d-flex{ type: 'button',
data: { toggle: 'collapse', target: "#project-errors-#{project_registry.project_id}" },
'aria-expanded' => 'false',
'aria-controls' => "project-errors-#{project_registry.project_id}" }
= sprite_icon('chevron-down', size: 18, css_class: 'append-right-5 card-expand-icon')
= sprite_icon('chevron-up', size: 18, css_class: 'append-right-5 card-collapse-icon')
.header-text-secondary
More
.collapse{ id: "project-errors-#{project_registry.project_id}",
'aria-labelledby' => "project-#{project_registry.project_id}-header" }
.card-body
.container.project-container
%ul.unstyled-list.errors-list
- if project_registry.last_repository_sync_failure
%li.p-0.d-flex
= sprite_icon('warning', size: 18, css_class: 'error-icon')
%span.error-text.prepend-left-5
= s_('Geo|Synchronization failed - %{error}') % { error: project_registry.last_repository_sync_failure }
- if project_registry.last_repository_verification_failure
%li.p-0.d-flex
= sprite_icon('warning', size: 18, css_class: 'error-icon')
%span.error-text.prepend-left-5
= s_('Geo|Verification failed - %{error}') % { error: project_registry.last_repository_verification_failure }
.card-body
.container.project-container
.row
.col-sm.project-status-container
.project-status-title.text-muted
= s_('Geo|Status')
= project_registry_status(project_registry)
.col-sm.project-status-container
.project-status-title.text-muted
= s_('Geo|Next sync scheduled at')
.project-status-content
- if project_registry.repository_retry_at
= distance_of_time_in_words(Time.now, project_registry.repository_retry_at)
- else
= s_('Geo|Waiting for scheduler')
.col-sm.project-status-container
.project-status-title.text-muted
= s_('Geo|Last sync attempt')
.project-status-content
- if project_registry.last_repository_synced_at
= time_ago_with_tooltip(project_registry.last_repository_synced_at, placement: 'bottom')
- else
= s_('Geo|Never')
.col-sm.d-sm-none.d-md-block
.card-body
.container.project-container
.row
.col-sm.project-status-container
.project-status-title.text-muted
= s_('Geo|Status')
= project_registry_status(project_registry)
.col-sm.project-status-container
.project-status-title.text-muted
= s_('Geo|Last successful sync')
.project-status-content
- if project_registry.last_repository_successful_sync_at
= time_ago_with_tooltip(project_registry.last_repository_successful_sync_at, placement: 'bottom')
- else
= s_('Geo|Never')
.col-sm.project-status-container
.project-status-title.text-muted
= s_('Geo|Last time verified')
.project-status-content
- if project_registry.last_repository_check_at
= time_ago_with_tooltip(project_registry.last_repository_check_at, placement: 'bottom')
- else
= s_('Geo|Never')
.col-sm.d-sm-none.d-md-block
......@@ -7,35 +7,11 @@
- else
%strong.header-text-primary.flex-fill
= link_to project_registry.project.full_name, admin_namespace_project_path(project_registry.project.namespace, project_registry.project)
= link_to(recheck_admin_geo_project_path(project_registry), method: :post, class: 'btn btn-outline btn-sm mr-2') do
= link_to(recheck_admin_geo_project_path(project_registry), method: :post, class: 'btn btn-default btn-sm mr-2') do
= s_('Geo|Recheck')
= link_to(resync_admin_geo_project_path(project_registry), method: :post, class: 'btn btn-outline-primary btn-sm') do
= link_to(resync_admin_geo_project_path(project_registry), method: :post, class: 'btn btn-default-primary btn-sm') do
= s_('Geo|Resync')
.card-body
.container.project-container
.row
.col-sm.project-status-container
.project-status-title.text-muted
= s_('Geo|Status')
.project-status-content
= s_('Geo|In sync')
.col-sm.project-status-container
.project-status-title.text-muted
= s_('Geo|Last successful sync')
.project-status-content
- if project_registry.last_repository_successful_sync_at
= time_ago_with_tooltip(project_registry.last_repository_successful_sync_at, placement: 'bottom')
- else
= s_('Geo|Never')
.col-sm.project-status-container
.project-status-title.text-muted
= s_('Geo|Last time verified')
.project-status-content
- if project_registry.last_repository_check_at
= time_ago_with_tooltip(project_registry.last_repository_check_at, placement: 'bottom')
- else
= s_('Geo|Never')
.col-sm.d-sm-none.d-md-block
= render partial: 'registry_synced', locals: { project_registry: project_registry }
= paginate @registries, theme: 'gitlab'
......@@ -9,6 +9,9 @@
- opts = params[:sync_status].present? ? {} : { page: admin_geo_projects_path }
= nav_link(opts) do
= link_to admin_geo_projects_path do
= s_('Geo|All')
= nav_link(html_options: { class: active_when(params[:sync_status] == 'synced') }) do
= link_to admin_geo_projects_path(sync_status: 'synced') do
= s_('Geo|Synced')
= nav_link(html_options: { class: active_when(params[:sync_status] == 'pending') }) do
= link_to admin_geo_projects_path(sync_status: 'pending') do
......@@ -27,5 +30,7 @@
= render(partial: 'failed')
- when 'pending'
= render(partial: 'pending')
- else
- when 'synced'
= render(partial: 'synced')
- else
= render(partial: 'all')
---
title: 'Geo: Added `All` tab in Geo Nodes > Projects'
merge_request: 7745
author:
type: added
......@@ -24,13 +24,18 @@ describe Admin::Geo::ProjectsController, :geo do
it_behaves_like 'license required'
context 'with a valid license' do
render_views
before do
allow(Gitlab::Geo).to receive(:license_allows?).and_return(true)
end
it 'renders synced template when no extra get params is specified' do
expect(subject).to have_gitlab_http_status(200)
expect(subject).to render_template(:index, partial: :synced)
context 'without sync_status specified' do
it 'renders all template when no extra get params is specified' do
expect(subject).to have_gitlab_http_status(200)
expect(subject).to render_template(:index)
expect(subject).to render_template(partial: 'admin/geo/projects/_all')
end
end
context 'with sync_status=pending' do
......@@ -38,7 +43,8 @@ describe Admin::Geo::ProjectsController, :geo do
it 'renders pending template' do
expect(subject).to have_gitlab_http_status(200)
expect(subject).to render_template(:index, partial: :pending)
expect(subject).to render_template(:index)
expect(subject).to render_template(partial: 'admin/geo/projects/_pending')
end
end
......@@ -47,7 +53,8 @@ describe Admin::Geo::ProjectsController, :geo do
it 'renders failed template' do
expect(subject).to have_gitlab_http_status(200)
expect(subject).to render_template(:index, partial: :failed)
expect(subject).to render_template(:index)
expect(subject).to render_template(partial: 'admin/geo/projects/_failed')
end
end
......@@ -56,7 +63,18 @@ describe Admin::Geo::ProjectsController, :geo do
it 'renders failed template' do
expect(subject).to have_gitlab_http_status(200)
expect(subject).to render_template(:index, partial: :never)
expect(subject).to render_template(:index)
expect(subject).to render_template(partial: 'admin/geo/projects/_never')
end
end
context 'with sync_status=synced' do
subject { get :index, sync_status: 'synced' }
it 'renders synced template' do
expect(subject).to have_gitlab_http_status(200)
expect(subject).to render_template(:index)
expect(subject).to render_template(partial: 'admin/geo/projects/_synced')
end
end
end
......@@ -105,7 +123,7 @@ describe Admin::Geo::ProjectsController, :geo do
it 'flags registry for recheck' do
expect(subject).to redirect_to(admin_geo_projects_path)
expect(flash[:notice]).to include('is scheduled for re-check')
expect(synced_registry.reload.verification_pending?).to be_truthy
expect(synced_registry.reload.pending_verification?).to be_truthy
end
end
end
......
......@@ -25,6 +25,17 @@ describe Geo::ProjectRegistryStatusFinder, :geo do
stub_current_geo_node(secondary)
end
describe '#all_projects' do
it 'returns all registries' do
result = subject.all_projects
expect(result).to contain_exactly(synced_registry, synced_and_verified_registry, sync_pending_registry,
sync_failed_registry, verify_outdated_registry, verify_failed_registry,
verify_checksum_mismatch_registry, never_synced_registry,
never_synced_registry_with_failure)
end
end
describe '#synced_projects' do
it 'returns only synced registry' do
result = subject.synced_projects
......
......@@ -821,19 +821,35 @@ describe Geo::ProjectRegistry do
end
end
describe 'verification_pending?' do
describe 'pending_verification?' 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
expect(repo_registry.pending_verification?).to be_truthy
expect(wiki_registry.pending_verification?).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
expect(registry.pending_verification?).to be_falsey
end
end
describe 'pending_synchronization?' do
it 'returns true when either wiki or repository synchronization is pending' do
repo_registry = create(:geo_project_registry)
wiki_registry = create(:geo_project_registry)
expect(repo_registry.pending_synchronization?).to be_truthy
expect(wiki_registry.pending_synchronization?).to be_truthy
end
it 'returns false when both wiki and repository synchronization is present' do
registry = create(:geo_project_registry, :synced)
expect(registry.pending_synchronization?).to be_falsey
end
end
......@@ -893,4 +909,30 @@ describe Geo::ProjectRegistry do
expect(registry.candidate_for_redownload?).to be_truthy
end
end
describe '#synchronization_state' do
it 'returns :never when no attempt to sync has ever been done' do
registry = create(:geo_project_registry)
expect(registry.synchronization_state).to eq(:never)
end
it 'returns :failed when there is an existing error logged' do
registry = create(:geo_project_registry, :sync_failed)
expect(registry.synchronization_state).to eq(:failed)
end
it 'returns :pending when there is an existing error logged' do
registry = create(:geo_project_registry, :synced, :repository_dirty)
expect(registry.synchronization_state).to eq(:pending)
end
it 'returns :synced when its fully synced and there is no pending action or existing error' do
registry = create(:geo_project_registry, :synced, :repository_verified)
expect(registry.synchronization_state).to eq(:synced)
end
end
end
......@@ -3643,13 +3643,13 @@ msgstr ""
msgid "Geo|%{name} is scheduled for re-sync"
msgstr ""
msgid "Geo|All projects"
msgid "Geo|All"
msgstr ""
msgid "Geo|Could not remove tracking entry for an existing project."
msgid "Geo|All projects"
msgstr ""
msgid "Geo|Error message"
msgid "Geo|Could not remove tracking entry for an existing project."
msgstr ""
msgid "Geo|Failed"
......@@ -3679,7 +3679,7 @@ msgstr ""
msgid "Geo|Next sync scheduled at"
msgstr ""
msgid "Geo|No errors"
msgid "Geo|Not synced yet"
msgstr ""
msgid "Geo|Pending"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment