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
3f335fad
Commit
3f335fad
authored
Feb 28, 2018
by
Tiago Botelho
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Change notification recipient from mirror user to project owners and masters
parent
6bcd8805
Changes
11
Show whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
94 additions
and
34 deletions
+94
-34
app/mailers/emails/projects.rb
app/mailers/emails/projects.rb
+3
-3
app/views/notify/mirror_was_hard_failed_email.html.haml
app/views/notify/mirror_was_hard_failed_email.html.haml
+0
-7
app/views/notify/mirror_was_hard_failed_email.text.erb
app/views/notify/mirror_was_hard_failed_email.text.erb
+0
-7
ee/app/models/ee/project/import_status_state_machine.rb
ee/app/models/ee/project/import_status_state_machine.rb
+3
-1
ee/app/services/ee/notification_service.rb
ee/app/services/ee/notification_service.rb
+7
-3
ee/app/views/notify/mirror_was_hard_failed_email.html.haml
ee/app/views/notify/mirror_was_hard_failed_email.html.haml
+8
-0
ee/app/views/notify/mirror_was_hard_failed_email.text.erb
ee/app/views/notify/mirror_was_hard_failed_email.text.erb
+5
-0
ee/app/workers/repository_update_mirror_worker.rb
ee/app/workers/repository_update_mirror_worker.rb
+2
-3
ee/spec/models/project_spec.rb
ee/spec/models/project_spec.rb
+11
-0
ee/spec/services/ee/notification_service_spec.rb
ee/spec/services/ee/notification_service_spec.rb
+54
-8
spec/mailers/notify_spec.rb
spec/mailers/notify_spec.rb
+1
-2
No files found.
app/mailers/emails/projects.rb
View file @
3f335fad
...
@@ -40,11 +40,11 @@ module Emails
...
@@ -40,11 +40,11 @@ module Emails
end
end
def
mirror_was_hard_failed_email
(
project_id
,
user_id
)
def
mirror_was_hard_failed_email
(
project_id
,
user_id
)
@user
=
User
.
find
(
user_id
)
@project
=
Project
.
find
(
project_id
)
@project
=
Project
.
find
(
project_id
)
user
=
User
.
find
(
user_id
)
mail
(
to:
@
user
.
notification_email
,
mail
(
to:
user
.
notification_email
,
subject:
subject
(
'
Pull
mirroring paused'
))
subject:
subject
(
'
Repository
mirroring paused'
))
end
end
end
end
end
end
app/views/notify/mirror_was_hard_failed_email.html.haml
deleted
100644 → 0
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
deleted
100644 → 0
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 @
3f335fad
...
@@ -21,7 +21,9 @@ module EE
...
@@ -21,7 +21,9 @@ module EE
end
end
after_transition
started: :failed
do
|
project
,
_
|
after_transition
started: :failed
do
|
project
,
_
|
::
NotificationService
.
new
.
mirror_was_hard_failed
(
project
)
if
project
.
mirror?
if
project
.
mirror?
&&
project
.
mirror_hard_failed?
::
NotificationService
.
new
.
mirror_was_hard_failed
(
project
)
end
end
end
after_transition
[
:scheduled
,
:started
]
=>
[
:finished
,
:failed
]
do
|
project
,
_
|
after_transition
[
:scheduled
,
:started
]
=>
[
:finished
,
:failed
]
do
|
project
,
_
|
...
...
ee/app/services/ee/notification_service.rb
View file @
3f335fad
...
@@ -24,11 +24,15 @@ module EE
...
@@ -24,11 +24,15 @@ module EE
end
end
def
mirror_was_hard_failed
(
project
)
def
mirror_was_hard_failed
(
project
)
re
turn
unless
project
.
mirror_hard_failed?
re
cipients
=
project
.
members
.
owners_and_masters
recepient
=
project
.
mirror_user
unless
recipients
.
present?
recipients
=
project
.
group
.
members
.
owners_and_masters
end
mailer
.
mirror_was_hard_failed_email
(
project
.
id
,
recepient
.
id
).
deliver_later
recipients
.
each
do
|
recipient
|
mailer
.
mirror_was_hard_failed_email
(
project
.
id
,
recipient
.
user
.
id
).
deliver_later
end
end
end
end
end
end
end
ee/app/views/notify/mirror_was_hard_failed_email.html.haml
0 → 100644
View file @
3f335fad
%p
Repository mirroring on
#{
@project
.
full_path
}
has been paused due to too many failures. The last failure was:
%pre
=
@project
.
import_error
%p
To resume mirroring update your
#{
link_to
(
"repository mirroring settings"
,
project_settings_repository_path
(
@project
))
}
.
ee/app/views/notify/mirror_was_hard_failed_email.text.erb
0 → 100644
View file @
3f335fad
Repository mirroring on
<%=
@project
.
full_path
%>
has been paused due to too many failures. The last failure was:
<%=
@project
.
import_error
%>
To resume mirroring update your repository settings at
<%=
project_settings_repository_url
(
@project
)
%>
.
ee/app/workers/repository_update_mirror_worker.rb
View file @
3f335fad
...
@@ -62,10 +62,9 @@ class RepositoryUpdateMirrorWorker
...
@@ -62,10 +62,9 @@ class RepositoryUpdateMirrorWorker
end
end
def
fail_mirror
(
project
,
message
)
def
fail_mirror
(
project
,
message
)
error_message
=
"Mirror update for
#{
project
.
full_path
}
failed with the following message:
#{
message
}
"
project
.
mark_import_as_failed
(
message
)
project
.
mark_import_as_failed
(
error_message
)
Rails
.
logger
.
error
(
error_message
)
Rails
.
logger
.
error
(
"Mirror update for
#{
project
.
full_path
}
failed with the following message:
#{
message
}
"
)
Gitlab
::
Metrics
.
add_event
(
:mirrors_failed
,
path:
project
.
full_path
)
Gitlab
::
Metrics
.
add_event
(
:mirrors_failed
,
path:
project
.
full_path
)
end
end
...
...
ee/spec/models/project_spec.rb
View file @
3f335fad
...
@@ -102,6 +102,17 @@ describe Project do
...
@@ -102,6 +102,17 @@ describe Project do
end
end
end
end
describe
'hard failing a mirror'
do
it
'sends a notification'
do
project
=
create
(
:project
,
:mirror
,
:import_started
)
project
.
mirror_data
.
update_attributes
(
retry_count:
Gitlab
::
Mirror
::
MAX_RETRY
)
expect_any_instance_of
(
EE
::
NotificationService
).
to
receive
(
:mirror_was_hard_failed
).
with
(
project
)
project
.
import_fail
end
end
describe
'#push_rule'
do
describe
'#push_rule'
do
let
(
:project
)
{
create
(
:project
,
push_rule:
create
(
:push_rule
))
}
let
(
:project
)
{
create
(
:project
,
push_rule:
create
(
:push_rule
))
}
...
...
ee/spec/services/ee/notification_service_spec.rb
View file @
3f335fad
...
@@ -123,20 +123,66 @@ describe EE::NotificationService, :mailer do
...
@@ -123,20 +123,66 @@ describe EE::NotificationService, :mailer do
describe
'mirror hard failed'
do
describe
'mirror hard failed'
do
let
(
:user
)
{
create
(
:user
)
}
let
(
:user
)
{
create
(
:user
)
}
it
'does not send email when mirror is not hard failed'
do
context
'when user is owner'
do
project
=
create
(
:project
,
:mirror
)
it
'sends email'
do
project
=
create
(
:project
,
:mirror
,
:import_hard_failed
)
expect
(
Notify
).
not_to
receive
(
:mirror_was_hard_failed_email
)
expect
(
Notify
).
to
receive
(
:mirror_was_hard_failed_email
).
with
(
project
.
id
,
project
.
owner
.
id
).
and_call_original
subject
.
mirror_was_hard_failed
(
project
)
end
end
context
'when user is master'
do
it
'sends email'
do
project
=
create
(
:project
,
:mirror
,
:import_hard_failed
)
project
.
add_master
(
user
)
expect
(
Notify
).
to
receive
(
:mirror_was_hard_failed_email
).
with
(
project
.
id
,
project
.
owner
.
id
).
and_call_original
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
context
'when user is not owner nor master'
do
it
'does not send email'
do
project
=
create
(
:project
,
:mirror
,
:import_hard_failed
)
project
.
add_developer
(
user
)
expect
(
Notify
).
not_to
receive
(
:mirror_was_hard_failed_email
).
with
(
project
.
id
,
user
.
id
).
and_call_original
expect
(
Notify
).
to
receive
(
:mirror_was_hard_failed_email
).
with
(
project
.
id
,
project
.
creator
.
id
).
and_call_original
subject
.
mirror_was_hard_failed
(
project
)
subject
.
mirror_was_hard_failed
(
project
)
end
end
it
'sends email to mirror user when mirror hard failed'
do
context
'when user is group owner'
do
project
=
create
(
:project
,
:mirror
,
:import_hard_failed
,
mirror_user:
user
)
it
'sends email'
do
group
=
create
(
:group
,
:public
)
do
|
group
|
group
.
add_owner
(
user
)
end
project
=
create
(
:project
,
:mirror
,
:import_hard_failed
,
namespace:
group
)
expect
(
Notify
).
to
receive
(
:mirror_was_hard_failed_email
).
with
(
project
.
id
,
user
.
id
).
and_call_original
expect
(
Notify
).
to
receive
(
:mirror_was_hard_failed_email
).
with
(
project
.
id
,
user
.
id
).
and_call_original
subject
.
mirror_was_hard_failed
(
project
)
subject
.
mirror_was_hard_failed
(
project
)
end
end
end
end
context
'when user is group master'
do
it
'sends email'
do
group
=
create
(
:group
,
:public
)
do
|
group
|
group
.
add_master
(
user
)
end
project
=
create
(
:project
,
:mirror
,
:import_hard_failed
,
namespace:
group
)
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
end
end
end
spec/mailers/notify_spec.rb
View file @
3f335fad
...
@@ -1429,8 +1429,7 @@ describe Notify do
...
@@ -1429,8 +1429,7 @@ describe Notify do
it_behaves_like
"a user cannot unsubscribe through footer link"
it_behaves_like
"a user cannot unsubscribe through footer link"
it
'has the correct subject and body'
do
it
'has the correct subject and body'
do
is_expected
.
to
have_subject
(
"
#{
project
.
name
}
| Pull mirroring paused"
)
is_expected
.
to
have_subject
(
"
#{
project
.
name
}
| Repository mirroring paused"
)
is_expected
.
to
have_html_escaped_body_text
(
project
.
import_url
)
is_expected
.
to
have_html_escaped_body_text
(
project
.
full_path
)
is_expected
.
to
have_html_escaped_body_text
(
project
.
full_path
)
end
end
end
end
...
...
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