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
795ba752
Commit
795ba752
authored
Feb 07, 2020
by
charlieablett
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rename `HamService.mark_as_ham!` to execute
parent
becf7b82
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
8 additions
and
8 deletions
+8
-8
app/controllers/admin/spam_logs_controller.rb
app/controllers/admin/spam_logs_controller.rb
+1
-1
app/services/spam/ham_service.rb
app/services/spam/ham_service.rb
+1
-1
spec/services/spam/ham_service_spec.rb
spec/services/spam/ham_service_spec.rb
+6
-6
No files found.
app/controllers/admin/spam_logs_controller.rb
View file @
795ba752
...
...
@@ -24,7 +24,7 @@ class Admin::SpamLogsController < Admin::ApplicationController
def
mark_as_ham
spam_log
=
SpamLog
.
find
(
params
[
:id
])
if
Spam
::
HamService
.
new
(
spam_log
).
mark_as_ham!
if
Spam
::
HamService
.
new
(
spam_log
).
execute
redirect_to
admin_spam_logs_path
,
notice:
_
(
'Spam log successfully submitted as ham.'
)
else
redirect_to
admin_spam_logs_path
,
alert:
_
(
'Error with Akismet. Please check the logs for more info.'
)
...
...
app/services/spam/ham_service.rb
View file @
795ba752
...
...
@@ -8,7 +8,7 @@ module Spam
@spam_log
=
spam_log
end
def
mark_as_ham!
def
execute
if
akismet
.
submit_ham
spam_log
.
update_attribute
(
:submitted_as_ham
,
true
)
else
...
...
spec/services/spam/ham_service_spec.rb
View file @
795ba752
...
...
@@ -13,18 +13,18 @@ describe Spam::HamService do
allow
(
Spam
::
AkismetService
).
to
receive
(
:new
).
and_return
fake_akismet_service
end
describe
'#
mark_as_ham!
'
do
describe
'#
execute
'
do
context
'AkismetService returns false (Akismet cannot be reached, etc)'
do
before
do
allow
(
fake_akismet_service
).
to
receive
(
:submit_ham
).
and_return
false
end
it
'returns false'
do
expect
(
subject
.
mark_as_ham!
).
to
be_falsey
expect
(
subject
.
execute
).
to
be_falsey
end
it
'does not update the record'
do
expect
{
subject
.
mark_as_ham!
}.
not_to
change
{
spam_log
.
submitted_as_ham
}
expect
{
subject
.
execute
}.
not_to
change
{
spam_log
.
submitted_as_ham
}
end
context
'if spam log record has already been marked as spam'
do
...
...
@@ -33,7 +33,7 @@ describe Spam::HamService do
end
it
'does not update the record'
do
expect
{
subject
.
mark_as_ham!
}.
not_to
change
{
spam_log
.
submitted_as_ham
}
expect
{
subject
.
execute
}.
not_to
change
{
spam_log
.
submitted_as_ham
}
end
end
end
...
...
@@ -45,11 +45,11 @@ describe Spam::HamService do
end
it
'returns true'
do
expect
(
subject
.
mark_as_ham!
).
to
be_truthy
expect
(
subject
.
execute
).
to
be_truthy
end
it
'updates the record'
do
expect
{
subject
.
mark_as_ham!
}.
to
change
{
spam_log
.
submitted_as_ham
}.
from
(
false
).
to
(
true
)
expect
{
subject
.
execute
}.
to
change
{
spam_log
.
submitted_as_ham
}.
from
(
false
).
to
(
true
)
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