Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
mastodon
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Pierre Boudes
mastodon
Commits
e835198b
Unverified
Commit
e835198b
authored
1 year ago
by
Matt Jankowski
Committed by
GitHub
1 year ago
Browse files
Options
Downloads
Patches
Plain Diff
Combine assertions in api/v1/notifications spec (#25486)
parent
155ec185
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
spec/controllers/api/v1/notifications_controller_spec.rb
+20
-31
20 additions, 31 deletions
spec/controllers/api/v1/notifications_controller_spec.rb
with
20 additions
and
31 deletions
spec/controllers/api/v1/notifications_controller_spec.rb
+
20
−
31
View file @
e835198b
...
...
@@ -67,24 +67,13 @@ RSpec.describe Api::V1::NotificationsController do
get
:index
end
it
'returns
http success'
do
it
'returns
expected notification types'
,
:aggregate_failures
do
expect
(
response
).
to
have_http_status
(
200
)
end
it
'includes reblog'
do
expect
(
body_as_json
.
pluck
(
:type
)).
to
include
'reblog'
end
it
'includes mention'
do
expect
(
body_as_json
.
pluck
(
:type
)).
to
include
'mention'
end
it
'includes favourite'
do
expect
(
body_as_json
.
pluck
(
:type
)).
to
include
'favourite'
end
it
'includes follow'
do
expect
(
body_as_json
.
pluck
(
:type
)).
to
include
'follow'
expect
(
body_json_types
).
to
include
'reblog'
expect
(
body_json_types
).
to
include
'mention'
expect
(
body_json_types
).
to
include
'favourite'
expect
(
body_json_types
).
to
include
'follow'
end
end
...
...
@@ -93,12 +82,14 @@ RSpec.describe Api::V1::NotificationsController do
get
:index
,
params:
{
account_id:
third
.
account
.
id
}
end
it
'returns
http success'
do
it
'returns
only notifications from specified user'
,
:aggregate_failures
do
expect
(
response
).
to
have_http_status
(
200
)
expect
(
body_json_account_ids
.
uniq
).
to
eq
[
third
.
account
.
id
.
to_s
]
end
it
'returns only notifications from specified user'
do
expect
(
body_as_json
.
map
{
|
x
|
x
[
:account
][
:id
]
}
.
uniq
).
to
eq
[
third
.
account
.
id
.
to_s
]
def
body_json_account_ids
body_as_json
.
map
{
|
x
|
x
[
:account
][
:id
]
}
end
end
...
...
@@ -107,27 +98,23 @@ RSpec.describe Api::V1::NotificationsController do
get
:index
,
params:
{
account_id:
'foo'
}
end
it
'returns
http success'
do
it
'returns
nothing'
,
:aggregate_failures
do
expect
(
response
).
to
have_http_status
(
200
)
end
it
'returns nothing'
do
expect
(
body_as_json
.
size
).
to
eq
0
end
end
describe
'with exclude
d
_types param'
do
describe
'with exclude_types param'
do
before
do
get
:index
,
params:
{
exclude_types:
%w(mention)
}
end
it
'returns
http success'
do
it
'returns
everything but excluded type'
,
:aggregate_failures
do
expect
(
response
).
to
have_http_status
(
200
)
end
it
'returns everything but excluded type'
do
expect
(
body_as_json
.
size
).
to_not
eq
0
expect
(
body_
as_
json
.
pluck
(
:
type
)
.
uniq
).
to_not
include
'mention'
expect
(
body_json
_
type
s
.
uniq
).
to_not
include
'mention'
end
end
...
...
@@ -136,13 +123,15 @@ RSpec.describe Api::V1::NotificationsController do
get
:index
,
params:
{
types:
%w(mention)
}
end
it
'returns
http success'
do
it
'returns
only requested type'
,
:aggregate_failures
do
expect
(
response
).
to
have_http_status
(
200
)
end
it
'returns only requested type'
do
expect
(
body_as_json
.
pluck
(
:type
).
uniq
).
to
eq
[
'mention'
]
expect
(
body_json_types
.
uniq
).
to
eq
[
'mention'
]
end
end
def
body_json_types
body_as_json
.
pluck
(
:type
)
end
end
end
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment