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
42f7a58b
Commit
42f7a58b
authored
Sep 12, 2017
by
James Lopez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor email service to log events and added specs
parent
e738b80a
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
17 additions
and
0 deletions
+17
-0
app/services/emails/base_service.rb
app/services/emails/base_service.rb
+5
-0
app/services/emails/create_service.rb
app/services/emails/create_service.rb
+2
-0
app/services/emails/destroy_service.rb
app/services/emails/destroy_service.rb
+2
-0
spec/services/emails/create_service_spec.rb
spec/services/emails/create_service_spec.rb
+4
-0
spec/services/emails/destroy_service_spec.rb
spec/services/emails/destroy_service_spec.rb
+4
-0
No files found.
app/services/emails/base_service.rb
View file @
42f7a58b
...
...
@@ -5,5 +5,10 @@ module Emails
@user
=
user
@email
=
opts
[
:email
]
end
def
log_audit_event
(
options
=
{})
AuditEventService
.
new
(
@current_user
,
@user
,
options
)
.
for_email
(
@email
).
security_event
end
end
end
app/services/emails/create_service.rb
View file @
42f7a58b
...
...
@@ -2,6 +2,8 @@ module Emails
class
CreateService
<
::
Emails
::
BaseService
def
execute
@user
.
emails
.
create
(
email:
@email
)
log_audit_event
(
action: :create
)
end
end
end
app/services/emails/destroy_service.rb
View file @
42f7a58b
...
...
@@ -2,6 +2,8 @@ module Emails
class
DestroyService
<
::
Emails
::
BaseService
def
execute
Email
.
find_by_email!
(
@email
).
destroy
&&
update_secondary_emails!
log_audit_event
(
action: :destroy
)
end
private
...
...
spec/services/emails/create_service_spec.rb
View file @
42f7a58b
...
...
@@ -17,5 +17,9 @@ describe Emails::CreateService do
expect
(
user
.
emails
).
to
eq
(
Email
.
where
(
opts
))
end
it
'registers a security event'
do
expect
{
service
.
execute
}.
to
change
{
SecurityEvent
.
count
}.
by
(
1
)
end
end
end
spec/services/emails/destroy_service_spec.rb
View file @
42f7a58b
...
...
@@ -10,5 +10,9 @@ describe Emails::DestroyService do
it
'removes an email'
do
expect
{
service
.
execute
}.
to
change
{
user
.
emails
.
count
}.
by
(
-
1
)
end
it
'registers a security event'
do
expect
{
service
.
execute
}.
to
change
{
SecurityEvent
.
count
}.
by
(
1
)
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