2019-07-25 05:24:42 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2019-08-29 07:56:52 +00:00
|
|
|
require 'spec_helper'
|
2016-04-13 10:13:53 +00:00
|
|
|
|
2020-06-16 18:09:01 +00:00
|
|
|
RSpec.describe 'Admin uses repository checks', :request_store, :clean_gitlab_redis_shared_state, :do_not_mock_admin_mode do
|
2017-01-22 00:11:19 +00:00
|
|
|
include StubENV
|
|
|
|
|
2020-02-05 18:09:06 +00:00
|
|
|
let(:admin) { create(:admin) }
|
|
|
|
|
2017-01-22 00:11:19 +00:00
|
|
|
before do
|
|
|
|
stub_env('IN_MEMORY_APPLICATION_SETTINGS', 'false')
|
2020-02-05 18:09:06 +00:00
|
|
|
sign_in(admin)
|
2017-01-22 00:11:19 +00:00
|
|
|
end
|
2016-04-13 10:13:53 +00:00
|
|
|
|
2020-02-05 18:09:06 +00:00
|
|
|
context 'when admin mode is disabled' do
|
|
|
|
it 'admin project page requires admin mode' do
|
|
|
|
project = create(:project)
|
|
|
|
visit_admin_project_page(project)
|
2016-04-13 10:13:53 +00:00
|
|
|
|
2020-02-05 18:09:06 +00:00
|
|
|
expect(page).not_to have_css('.repository-check')
|
|
|
|
expect(page).to have_content('Enter Admin Mode')
|
2016-04-13 10:13:53 +00:00
|
|
|
end
|
2020-02-04 18:08:50 +00:00
|
|
|
end
|
2016-04-13 10:13:53 +00:00
|
|
|
|
2020-02-05 18:09:06 +00:00
|
|
|
context 'when admin mode is enabled' do
|
|
|
|
before do
|
|
|
|
gitlab_enable_admin_mode_sign_in(admin)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'to trigger a single check', :js do
|
|
|
|
project = create(:project)
|
|
|
|
visit_admin_project_page(project)
|
|
|
|
|
|
|
|
page.within('.repository-check') do
|
|
|
|
click_button 'Trigger repository check'
|
|
|
|
end
|
2020-02-04 12:09:00 +00:00
|
|
|
|
2020-02-05 18:09:06 +00:00
|
|
|
expect(page).to have_content('Repository check was triggered')
|
2020-02-04 12:09:00 +00:00
|
|
|
end
|
2017-01-22 00:11:19 +00:00
|
|
|
|
2020-02-05 18:09:06 +00:00
|
|
|
it 'to see a single failed repository check', :js do
|
|
|
|
project = create(:project)
|
|
|
|
project.update_columns(
|
|
|
|
last_repository_check_failed: true,
|
|
|
|
last_repository_check_at: Time.now
|
|
|
|
)
|
|
|
|
visit_admin_project_page(project)
|
|
|
|
|
2020-09-21 12:09:34 +00:00
|
|
|
page.within('.gl-alert') do
|
2020-02-05 18:09:06 +00:00
|
|
|
expect(page.text).to match(/Last repository check \(just now\) failed/)
|
|
|
|
end
|
|
|
|
end
|
2016-04-13 10:13:53 +00:00
|
|
|
|
2020-02-05 18:09:06 +00:00
|
|
|
it 'to clear all repository checks', :js do
|
|
|
|
visit repository_admin_application_settings_path
|
2016-04-13 10:13:53 +00:00
|
|
|
|
2020-02-05 18:09:06 +00:00
|
|
|
expect(RepositoryCheck::ClearWorker).to receive(:perform_async)
|
2020-02-04 12:09:00 +00:00
|
|
|
|
2020-02-05 18:09:06 +00:00
|
|
|
accept_confirm { find(:link, 'Clear all repository checks').send_keys(:return) }
|
|
|
|
|
|
|
|
expect(page).to have_content('Started asynchronous removal of all repository check states.')
|
|
|
|
end
|
2016-04-13 10:13:53 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def visit_admin_project_page(project)
|
2017-07-06 16:20:50 +00:00
|
|
|
visit admin_project_path(project)
|
2016-04-13 10:13:53 +00:00
|
|
|
end
|
|
|
|
end
|