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
6bd10192
Commit
6bd10192
authored
7 years ago
by
Eugen
Committed by
GitHub
7 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Add more tests for AtomSerializer (#2096)
parent
0d6c1e9c
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
spec/lib/atom_serializer_spec.rb
+185
-0
185 additions, 0 deletions
spec/lib/atom_serializer_spec.rb
spec/spec_helper.rb
+0
-4
0 additions, 4 deletions
spec/spec_helper.rb
with
185 additions
and
4 deletions
spec/lib/atom_serializer_spec.rb
+
185
−
0
View file @
6bd10192
require
'rails_helper'
require
'rails_helper'
RSpec
.
describe
AtomSerializer
do
RSpec
.
describe
AtomSerializer
do
let
(
:author
)
{
Fabricate
(
:account
,
username:
'Sombra'
,
display_name:
'1337 haxxor'
)
}
let
(
:receiver
)
{
Fabricate
(
:account
,
username:
'Symmetra'
)
}
before
do
stub_request
(
:get
,
"https://cb6e6126.ngrok.io/avatars/original/missing.png"
).
to_return
(
status:
404
)
stub_request
(
:get
,
"https://cb6e6126.ngrok.io/headers/original/missing.png"
).
to_return
(
status:
404
)
end
describe
'#author'
do
describe
'#author'
do
it
'returns dumpable XML with emojis'
do
it
'returns dumpable XML with emojis'
do
account
=
Fabricate
(
:account
,
display_name:
'💩'
)
account
=
Fabricate
(
:account
,
display_name:
'💩'
)
...
@@ -18,4 +26,181 @@ RSpec.describe AtomSerializer do
...
@@ -18,4 +26,181 @@ RSpec.describe AtomSerializer do
expect
(
xml
).
to
match
(
/<poco:displayName>im l33t haxor<\/poco:displayName>/
)
expect
(
xml
).
to
match
(
/<poco:displayName>im l33t haxor<\/poco:displayName>/
)
end
end
end
end
describe
'#entry'
do
describe
'with deleted status'
do
let
(
:entry
)
do
status
=
Fabricate
(
:status
,
account:
author
,
text:
'boop'
)
entry
=
status
.
stream_entry
status
.
destroy
entry
end
it
'returns dumpable XML'
do
xml
=
AtomSerializer
.
render
(
AtomSerializer
.
new
.
entry
(
entry
,
true
))
expect
(
xml
).
to
be_a
String
expect
(
xml
).
to
match
(
/<id>
#{
TagManager
.
instance
.
unique_tag
(
entry
.
created_at
,
entry
.
activity_id
,
'Status'
)
}
<\/id>/
)
end
it
'triggers delete when processed'
do
status
=
double
(
id:
entry
.
activity_id
)
service
=
double
allow
(
Status
).
to
receive
(
:find_by
).
and_return
(
status
)
allow
(
RemoveStatusService
).
to
receive
(
:new
).
and_return
(
service
)
allow
(
service
).
to
receive
(
:call
)
xml
=
AtomSerializer
.
render
(
AtomSerializer
.
new
.
entry
(
entry
,
true
))
ProcessFeedService
.
new
.
call
(
xml
,
author
)
expect
(
service
).
to
have_received
(
:call
).
with
(
status
)
end
end
describe
'with reblog of local user'
do
it
'returns dumpable XML'
it
'creates a reblog'
end
describe
'with reblog of 3rd party user'
do
it
'returns dumpable XML'
it
'creates a reblog with correct author'
end
end
describe
'#follow_salmon'
do
let
(
:xml
)
do
follow
=
Fabricate
(
:follow
,
account:
author
,
target_account:
receiver
)
xml
=
AtomSerializer
.
render
(
AtomSerializer
.
new
.
follow_salmon
(
follow
))
follow
.
destroy
xml
end
it
'returns dumpable XML'
do
expect
(
xml
).
to
be_a
String
end
it
'triggers follow when processed'
do
envelope
=
OStatus2
::
Salmon
.
new
.
pack
(
xml
,
author
.
keypair
)
ProcessInteractionService
.
new
.
call
(
envelope
,
receiver
)
expect
(
author
.
following?
(
receiver
)).
to
be
true
end
end
describe
'#unfollow_salmon'
do
let
(
:xml
)
do
follow
=
Fabricate
(
:follow
,
account:
author
,
target_account:
receiver
)
follow
.
destroy
xml
=
AtomSerializer
.
render
(
AtomSerializer
.
new
.
unfollow_salmon
(
follow
))
author
.
follow!
(
receiver
)
xml
end
it
'returns dumpable XML'
do
expect
(
xml
).
to
be_a
String
end
it
'triggers unfollow when processed'
do
envelope
=
OStatus2
::
Salmon
.
new
.
pack
(
xml
,
author
.
keypair
)
ProcessInteractionService
.
new
.
call
(
envelope
,
receiver
)
expect
(
author
.
following?
(
receiver
)).
to
be
false
end
end
describe
'#favourite_salmon'
do
let
(
:status
)
{
Fabricate
(
:status
,
account:
receiver
,
text:
'Everything by design.'
)
}
let
(
:xml
)
do
favourite
=
Fabricate
(
:favourite
,
account:
author
,
status:
status
)
xml
=
AtomSerializer
.
render
(
AtomSerializer
.
new
.
favourite_salmon
(
favourite
))
favourite
.
destroy
xml
end
it
'returns dumpable XML'
do
expect
(
xml
).
to
be_a
String
end
it
'triggers favourite when processed'
do
envelope
=
OStatus2
::
Salmon
.
new
.
pack
(
xml
,
author
.
keypair
)
ProcessInteractionService
.
new
.
call
(
envelope
,
receiver
)
expect
(
author
.
favourited?
(
status
)).
to
be
true
end
end
describe
'#unfavourite_salmon'
do
let
(
:status
)
{
Fabricate
(
:status
,
account:
receiver
,
text:
'Perfect harmony.'
)
}
let
(
:xml
)
do
favourite
=
Fabricate
(
:favourite
,
account:
author
,
status:
status
)
favourite
.
destroy
xml
=
AtomSerializer
.
render
(
AtomSerializer
.
new
.
unfavourite_salmon
(
favourite
))
Fabricate
(
:favourite
,
account:
author
,
status:
status
)
xml
end
it
'returns dumpable XML'
do
expect
(
xml
).
to
be_a
String
end
it
'triggers unfavourite when processed'
do
envelope
=
OStatus2
::
Salmon
.
new
.
pack
(
xml
,
author
.
keypair
)
ProcessInteractionService
.
new
.
call
(
envelope
,
receiver
)
expect
(
author
.
favourited?
(
status
)).
to
be
false
end
end
describe
'#block_salmon'
do
let
(
:xml
)
do
block
=
Fabricate
(
:block
,
account:
author
,
target_account:
receiver
)
xml
=
AtomSerializer
.
render
(
AtomSerializer
.
new
.
block_salmon
(
block
))
block
.
destroy
xml
end
it
'returns dumpable XML'
do
expect
(
xml
).
to
be_a
String
end
it
'triggers block when processed'
do
envelope
=
OStatus2
::
Salmon
.
new
.
pack
(
xml
,
author
.
keypair
)
ProcessInteractionService
.
new
.
call
(
envelope
,
receiver
)
expect
(
author
.
blocking?
(
receiver
)).
to
be
true
end
end
describe
'#unblock_salmon'
do
let
(
:xml
)
do
block
=
Fabricate
(
:block
,
account:
author
,
target_account:
receiver
)
block
.
destroy
xml
=
AtomSerializer
.
render
(
AtomSerializer
.
new
.
unblock_salmon
(
block
))
author
.
block!
(
receiver
)
xml
end
it
'returns dumpable XML'
do
expect
(
xml
).
to
be_a
String
end
it
'triggers unblock when processed'
do
envelope
=
OStatus2
::
Salmon
.
new
.
pack
(
xml
,
author
.
keypair
)
ProcessInteractionService
.
new
.
call
(
envelope
,
receiver
)
expect
(
author
.
blocking?
(
receiver
)).
to
be
false
end
end
describe
'#follow_request_salmon'
do
it
'returns dumpable XML'
it
'triggers follow request when processed'
end
describe
'#authorize_follow_request_salmon'
do
it
'returns dumpable XML'
it
'creates follow from follow request when processed'
end
describe
'#reject_follow_request_salmon'
do
it
'returns dumpable XML'
it
'deletes follow request when processed'
end
end
end
This diff is collapsed.
Click to expand it.
spec/spec_helper.rb
+
0
−
4
View file @
6bd10192
...
@@ -21,10 +21,6 @@ RSpec.configure do |config|
...
@@ -21,10 +21,6 @@ RSpec.configure do |config|
end
end
end
end
config
.
before
:each
do
stub_request
(
:post
,
'https://fcm.googleapis.com/fcm/send'
).
to_return
(
status:
200
,
body:
''
)
end
config
.
after
:suite
do
config
.
after
:suite
do
FileUtils
.
rm_rf
(
Dir
[
"
#{
Rails
.
root
}
/spec/test_files/"
])
FileUtils
.
rm_rf
(
Dir
[
"
#{
Rails
.
root
}
/spec/test_files/"
])
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