2019-07-25 05:24:42 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-05-03 12:55:14 +00:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2018-07-05 06:32:05 +00:00
|
|
|
describe 'Project remote mirror', :feature do
|
2018-05-03 12:55:14 +00:00
|
|
|
let(:project) { create(:project, :repository, :remote_mirror) }
|
|
|
|
let(:remote_mirror) { project.remote_mirrors.first }
|
|
|
|
let(:user) { create(:user) }
|
|
|
|
|
|
|
|
describe 'On a project', :js do
|
|
|
|
before do
|
2018-07-11 14:36:08 +00:00
|
|
|
project.add_maintainer(user)
|
2018-05-03 12:55:14 +00:00
|
|
|
sign_in user
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when last_error is present but last_update_at is not' do
|
|
|
|
it 'renders error message without timstamp' do
|
2018-07-02 10:43:06 +00:00
|
|
|
remote_mirror.update(last_error: 'Some new error', last_update_at: nil)
|
2018-05-03 12:55:14 +00:00
|
|
|
|
|
|
|
visit project_mirror_path(project)
|
|
|
|
|
2018-08-03 12:06:15 +00:00
|
|
|
expect_mirror_to_have_error_and_timeago('Never')
|
2018-05-03 12:55:14 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when last_error and last_update_at are present' do
|
|
|
|
it 'renders error message with timestamp' do
|
2018-07-02 10:43:06 +00:00
|
|
|
remote_mirror.update(last_error: 'Some new error', last_update_at: Time.now - 5.minutes)
|
2018-05-03 12:55:14 +00:00
|
|
|
|
|
|
|
visit project_mirror_path(project)
|
|
|
|
|
2018-08-03 12:06:15 +00:00
|
|
|
expect_mirror_to_have_error_and_timeago('5 minutes ago')
|
2018-05-03 12:55:14 +00:00
|
|
|
end
|
|
|
|
end
|
2018-08-03 12:06:15 +00:00
|
|
|
|
|
|
|
def expect_mirror_to_have_error_and_timeago(timeago)
|
|
|
|
row = first('.js-mirrors-table-body tr')
|
|
|
|
expect(row).to have_content('Error')
|
|
|
|
expect(row).to have_content(timeago)
|
|
|
|
end
|
2018-05-03 12:55:14 +00:00
|
|
|
end
|
|
|
|
end
|