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
b67aa714
Commit
b67aa714
authored
Apr 14, 2020
by
Dylan Griffith
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'cablett-spam-test-refactor' into 'master'
Spam test refactor See merge request gitlab-org/gitlab!29114
parents
9c1a10f1
9a86927d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
23 deletions
+17
-23
spec/services/issues/create_service_spec.rb
spec/services/issues/create_service_spec.rb
+17
-23
No files found.
spec/services/issues/create_service_spec.rb
View file @
b67aa714
...
@@ -368,10 +368,12 @@ describe Issues::CreateService do
...
@@ -368,10 +368,12 @@ describe Issues::CreateService do
end
end
context
'checking spam'
do
context
'checking spam'
do
let
(
:title
)
{
'Legit issue'
}
let
(
:description
)
{
'please fix'
}
let
(
:opts
)
do
let
(
:opts
)
do
{
{
title:
'Awesome issue'
,
title:
title
,
description:
'please fix'
,
description:
description
,
request:
double
(
:request
,
env:
{})
request:
double
(
:request
,
env:
{})
}
}
end
end
...
@@ -382,7 +384,7 @@ describe Issues::CreateService do
...
@@ -382,7 +384,7 @@ describe Issues::CreateService do
context
'when recaptcha was verified'
do
context
'when recaptcha was verified'
do
let
(
:log_user
)
{
user
}
let
(
:log_user
)
{
user
}
let
(
:spam_logs
)
{
create_list
(
:spam_log
,
2
,
user:
log_user
,
title:
'Awesome issue'
)
}
let
(
:spam_logs
)
{
create_list
(
:spam_log
,
2
,
user:
log_user
,
title:
title
)
}
let
(
:target_spam_log
)
{
spam_logs
.
last
}
let
(
:target_spam_log
)
{
spam_logs
.
last
}
before
do
before
do
...
@@ -396,7 +398,7 @@ describe Issues::CreateService do
...
@@ -396,7 +398,7 @@ describe Issues::CreateService do
expect
(
issue
).
not_to
be_spam
expect
(
issue
).
not_to
be_spam
end
end
it
'
issue is valid
'
do
it
'
creates a valid issue
'
do
expect
(
issue
).
to
be_valid
expect
(
issue
).
to
be_valid
end
end
...
@@ -405,14 +407,14 @@ describe Issues::CreateService do
...
@@ -405,14 +407,14 @@ describe Issues::CreateService do
end
end
it
'marks related spam_log as recaptcha_verified'
do
it
'marks related spam_log as recaptcha_verified'
do
expect
{
issue
}.
to
change
{
SpamLog
.
last
.
recaptcha_verified
}.
from
(
false
).
to
(
true
)
expect
{
issue
}.
to
change
{
target_spam_log
.
reload
.
recaptcha_verified
}.
from
(
false
).
to
(
true
)
end
end
context
'when spam log does not belong to a user'
do
context
'when spam log does not belong to a user'
do
let
(
:log_user
)
{
create
(
:user
)
}
let
(
:log_user
)
{
create
(
:user
)
}
it
'does not mark spam_log as recaptcha_verified'
do
it
'does not mark spam_log as recaptcha_verified'
do
expect
{
issue
}.
not_to
change
{
SpamLog
.
last
.
recaptcha_verified
}
expect
{
issue
}.
not_to
change
{
target_spam_log
.
reload
.
recaptcha_verified
}
end
end
end
end
end
end
...
@@ -431,8 +433,8 @@ describe Issues::CreateService do
...
@@ -431,8 +433,8 @@ describe Issues::CreateService do
end
end
end
end
context
'when
issuables_recaptcha_enabled feature flag is tru
e'
do
context
'when
allow_possible_spam feature flag is fals
e'
do
it
'marks
an
issue as spam'
do
it
'marks
the
issue as spam'
do
expect
(
issue
).
to
be_spam
expect
(
issue
).
to
be_spam
end
end
...
@@ -442,34 +444,26 @@ describe Issues::CreateService do
...
@@ -442,34 +444,26 @@ describe Issues::CreateService do
it
'creates a new spam_log'
do
it
'creates a new spam_log'
do
expect
{
issue
}
expect
{
issue
}
.
to
have_spam_log
(
title:
issue
.
title
,
description:
issue
.
description
,
user_id:
user
.
id
,
noteable_type:
'Issue'
)
.
to
have_spam_log
(
title:
title
,
description:
description
,
user_id:
user
.
id
,
noteable_type:
'Issue'
)
end
it
'assigns a spam_log to the issue'
do
expect
(
issue
.
spam_log
).
to
eq
(
SpamLog
.
last
)
end
end
end
end
context
'when
issuable_recaptcha_enabled feature flag is fals
e'
do
context
'when
allow_possible_spam feature flag is tru
e'
do
before
do
before
do
stub_feature_flags
(
allow_possible_spam:
true
)
stub_feature_flags
(
allow_possible_spam:
true
)
end
end
it
'does not mark
an
issue as spam'
do
it
'does not mark
the
issue as spam'
do
expect
(
issue
).
not_to
be_spam
expect
(
issue
).
not_to
be_spam
end
end
it
'
accepts the issue as valid
'
do
it
'
creates a valid issue
'
do
expect
(
issue
).
to
be_valid
expect
(
issue
).
to
be_valid
end
end
it
'creates a new spam_log'
do
it
'creates a new spam_log'
do
expect
{
issue
}
expect
{
issue
}
.
to
have_spam_log
(
title:
issue
.
title
,
description:
issue
.
description
,
user_id:
user
.
id
,
noteable_type:
'Issue'
)
.
to
have_spam_log
(
title:
title
,
description:
description
,
user_id:
user
.
id
,
noteable_type:
'Issue'
)
end
it
'assigns a spam_log to an issue'
do
expect
(
issue
.
spam_log
).
to
eq
(
SpamLog
.
last
)
end
end
end
end
end
end
...
@@ -485,8 +479,8 @@ describe Issues::CreateService do
...
@@ -485,8 +479,8 @@ describe Issues::CreateService do
expect
(
issue
).
not_to
be_spam
expect
(
issue
).
not_to
be_spam
end
end
it
'
an issue is valid
'
do
it
'
creates a valid issue
'
do
expect
(
issue
.
valid?
).
to
be_truthy
expect
(
issue
).
to
be_valid
end
end
it
'does not assign a spam_log to an issue'
do
it
'does not assign a spam_log to an issue'
do
...
...
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