Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlejandro Rodríguez <alejorro70@gmail.com>2018-12-05 18:22:52 +0300
committerAlejandro Rodríguez <alejorro70@gmail.com>2018-12-12 05:08:17 +0300
commitb65cb237cee0b1a8dfdc21a09f2b181d0edf5bde (patch)
treedffc212c6e7ca84c1e61ec1625e53548c0b6de18 /spec/models/remote_mirror_spec.rb
parent80eebd8e33c5f2f26bc0fdd233d9d92c51edd242 (diff)
Send a notification email on mirror update errors
The email is sent to project maintainers containing the last mirror update error. This will allow maintainers to set alarms and react accordingly.
Diffstat (limited to 'spec/models/remote_mirror_spec.rb')
-rw-r--r--spec/models/remote_mirror_spec.rb39
1 files changed, 38 insertions, 1 deletions
diff --git a/spec/models/remote_mirror_spec.rb b/spec/models/remote_mirror_spec.rb
index b12ca79847c..5d3c25062d5 100644
--- a/spec/models/remote_mirror_spec.rb
+++ b/spec/models/remote_mirror_spec.rb
@@ -1,6 +1,6 @@
require 'rails_helper'
-describe RemoteMirror do
+describe RemoteMirror, :mailer do
include GitHelpers
describe 'URL validation' do
@@ -137,6 +137,43 @@ describe RemoteMirror do
end
end
+ describe '#mark_as_failed' do
+ let(:remote_mirror) { create(:remote_mirror) }
+ let(:error_message) { 'http://user:pass@test.com/root/repoC.git/' }
+ let(:sanitized_error_message) { 'http://*****:*****@test.com/root/repoC.git/' }
+
+ subject do
+ remote_mirror.update_start
+ remote_mirror.mark_as_failed(error_message)
+ end
+
+ it 'sets the update_status to failed' do
+ subject
+
+ expect(remote_mirror.reload.update_status).to eq('failed')
+ end
+
+ it 'saves the sanitized error' do
+ subject
+
+ expect(remote_mirror.last_error).to eq(sanitized_error_message)
+ end
+
+ context 'notifications' do
+ let(:user) { create(:user) }
+
+ before do
+ remote_mirror.project.add_maintainer(user)
+ end
+
+ it 'notifies the project maintainers' do
+ perform_enqueued_jobs { subject }
+
+ should_email(user)
+ end
+ end
+ end
+
context 'when remote mirror gets destroyed' do
it 'removes remote' do
mirror = create_mirror(url: 'http://foo:bar@test.com')