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
6bcd8805
Commit
6bcd8805
authored
Feb 27, 2018
by
Tiago Botelho
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adds email templates for when mirror was hard failed
parent
eeeb2d38
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
68 additions
and
10 deletions
+68
-10
app/mailers/emails/projects.rb
app/mailers/emails/projects.rb
+4
-4
app/views/notify/mirror_was_hard_failed_email.html.haml
app/views/notify/mirror_was_hard_failed_email.html.haml
+7
-0
app/views/notify/mirror_was_hard_failed_email.text.erb
app/views/notify/mirror_was_hard_failed_email.text.erb
+7
-0
ee/app/models/ee/project/import_status_state_machine.rb
ee/app/models/ee/project/import_status_state_machine.rb
+5
-4
ee/app/services/ee/notification_service.rb
ee/app/services/ee/notification_service.rb
+4
-2
ee/changelogs/unreleased/1123-mirroring-notifies-when-hard-failed.yml
...s/unreleased/1123-mirroring-notifies-when-hard-failed.yml
+5
-0
ee/spec/services/ee/notification_service_spec.rb
ee/spec/services/ee/notification_service_spec.rb
+20
-0
spec/mailers/notify_spec.rb
spec/mailers/notify_spec.rb
+16
-0
No files found.
app/mailers/emails/projects.rb
View file @
6bcd8805
...
...
@@ -39,12 +39,12 @@ module Emails
subject:
@message
.
subject
)
end
def
mirror_
hard_failed
(
project_id
,
user_id
)
@
current_user
=
@user
=
User
.
find
user_id
@project
=
Project
.
find
project_id
def
mirror_
was_hard_failed_email
(
project_id
,
user_id
)
@
user
=
User
.
find
(
user_id
)
@project
=
Project
.
find
(
project_id
)
mail
(
to:
@user
.
notification_email
,
subject:
subject
(
'
Mirror hard fail
ed'
))
subject:
subject
(
'
Pull mirroring paus
ed'
))
end
end
end
app/views/notify/mirror_was_hard_failed_email.html.haml
0 → 100644
View file @
6bcd8805
%p
Mirroring from
#{
@project
.
import_url
}
to
#{
@project
.
full_path
}
failed with the following error:
%p
=
@project
.
import_error
.
try
(
:strip
)
Repository mirroring has been paused due to too many failed attempts, and can be resumed by a project admin.
app/views/notify/mirror_was_hard_failed_email.text.erb
0 → 100644
View file @
6bcd8805
Mirroring from
<%=
@project
.
import_url
%>
to
<%=
@project
.
full_path
%>
failed with the following error:
<%=
@project
.
import_error
.
try
(
:strip
)
%>
Repository mirroring has been paused due to too many failed attempts, and can be resumed by a project admin.
ee/app/models/ee/project/import_status_state_machine.rb
View file @
6bcd8805
...
...
@@ -20,11 +20,12 @@ module EE
end
end
after_transition
started: :failed
do
|
project
,
_
|
::
NotificationService
.
new
.
mirror_was_hard_failed
(
project
)
if
project
.
mirror?
end
after_transition
[
:scheduled
,
:started
]
=>
[
:finished
,
:failed
]
do
|
project
,
_
|
if
project
.
mirror?
::
Gitlab
::
Mirror
.
decrement_capacity
(
project
.
id
)
::
NotificationService
.
new
.
mirror_was_hard_failed
(
project
)
end
::
Gitlab
::
Mirror
.
decrement_capacity
(
project
.
id
)
if
project
.
mirror?
end
before_transition
started: :failed
do
|
project
,
_
|
...
...
ee/app/services/ee/notification_service.rb
View file @
6bcd8805
...
...
@@ -20,13 +20,15 @@ module EE
return
if
note
.
author
==
support_bot
return
unless
issue
.
subscribed?
(
support_bot
,
issue
.
project
)
Notify
.
service_desk_new_note_email
(
issue
.
id
,
note
.
id
).
deliver_later
mailer
.
service_desk_new_note_email
(
issue
.
id
,
note
.
id
).
deliver_later
end
def
mirror_was_hard_failed
(
project
)
return
unless
project
.
mirror_hard_failed?
recepient
=
project
.
mirror_user
mailer
.
mirror_
hard_failed
(
project
.
id
,
recepient
.
id
).
deliver_later
mailer
.
mirror_
was_hard_failed_email
(
project
.
id
,
recepient
.
id
).
deliver_later
end
end
end
ee/changelogs/unreleased/1123-mirroring-notifies-when-hard-failed.yml
0 → 100644
View file @
6bcd8805
---
title
:
Repository mirroring notifies when hard failed
merge_request
:
4699
author
:
type
:
added
ee/spec/services/ee/notification_service_spec.rb
View file @
6bcd8805
...
...
@@ -119,4 +119,24 @@ describe EE::NotificationService, :mailer do
end
end
end
describe
'mirror hard failed'
do
let
(
:user
)
{
create
(
:user
)
}
it
'does not send email when mirror is not hard failed'
do
project
=
create
(
:project
,
:mirror
)
expect
(
Notify
).
not_to
receive
(
:mirror_was_hard_failed_email
)
subject
.
mirror_was_hard_failed
(
project
)
end
it
'sends email to mirror user when mirror hard failed'
do
project
=
create
(
:project
,
:mirror
,
:import_hard_failed
,
mirror_user:
user
)
expect
(
Notify
).
to
receive
(
:mirror_was_hard_failed_email
).
with
(
project
.
id
,
user
.
id
).
and_call_original
subject
.
mirror_was_hard_failed
(
project
)
end
end
end
spec/mailers/notify_spec.rb
View file @
6bcd8805
...
...
@@ -1419,6 +1419,22 @@ describe Notify do
end
end
describe
'mirror was hard failed'
do
let
(
:project
)
{
create
(
:project
,
:mirror
,
:import_hard_failed
)
}
subject
{
described_class
.
mirror_was_hard_failed_email
(
project
.
id
,
user
.
id
)
}
it_behaves_like
'an email sent from GitLab'
it_behaves_like
'it should not have Gmail Actions links'
it_behaves_like
"a user cannot unsubscribe through footer link"
it
'has the correct subject and body'
do
is_expected
.
to
have_subject
(
"
#{
project
.
name
}
| Pull mirroring paused"
)
is_expected
.
to
have_html_escaped_body_text
(
project
.
import_url
)
is_expected
.
to
have_html_escaped_body_text
(
project
.
full_path
)
end
end
describe
'admin notification'
do
let
(
:example_site_path
)
{
root_path
}
let
(
:user
)
{
create
(
:user
)
}
...
...
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