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
0b39b9ab
Unverified
Commit
0b39b9ab
authored
1 year ago
by
Matt Jankowski
Committed by
GitHub
1 year ago
Browse files
Options
Downloads
Patches
Plain Diff
Speed-up on `BackupService` spec (#25527)
parent
6ac271c2
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
spec/services/backup_service_spec.rb
+47
-34
47 additions, 34 deletions
spec/services/backup_service_spec.rb
with
47 additions
and
34 deletions
spec/services/backup_service_spec.rb
+
47
−
34
View file @
0b39b9ab
...
...
@@ -30,7 +30,7 @@ RSpec.describe BackupService, type: :service do
it
'stores them as expected'
do
service_call
json
=
Oj
.
load
(
read_zip_file
(
backup
,
'actor.json'
)
)
json
=
export_json
(
:actor
)
avatar_path
=
json
.
dig
(
'icon'
,
'url'
)
header_path
=
json
.
dig
(
'image'
,
'url'
)
...
...
@@ -42,47 +42,60 @@ RSpec.describe BackupService, type: :service do
end
end
it
'marks the backup as processed'
do
expect
{
service_call
}.
to
change
(
backup
,
:processed
).
from
(
false
).
to
(
true
)
it
'marks the backup as processed and exports files'
do
expect
{
service_call
}.
to
process_backup
expect_outbox_export
expect_likes_export
expect_bookmarks_export
end
it
'exports outbox.json as expected'
do
service_call
def
process_backup
change
(
backup
,
:processed
).
from
(
false
).
to
(
true
)
end
json
=
Oj
.
load
(
read_zip_file
(
backup
,
'outbox.json'
))
expect
(
json
[
'@context'
]).
to_not
be_nil
expect
(
json
[
'type'
]).
to
eq
'OrderedCollection'
expect
(
json
[
'totalItems'
]).
to
eq
2
expect
(
json
[
'orderedItems'
][
0
][
'@context'
]).
to
be_nil
expect
(
json
[
'orderedItems'
][
0
]).
to
include
({
'type'
=>
'Create'
,
'object'
=>
include
({
'id'
=>
ActivityPub
::
TagManager
.
instance
.
uri_for
(
status
),
'content'
=>
'<p>Hello</p>'
,
}),
})
expect
(
json
[
'orderedItems'
][
1
]).
to
include
({
'type'
=>
'Create'
,
'object'
=>
include
({
'id'
=>
ActivityPub
::
TagManager
.
instance
.
uri_for
(
private_status
),
'content'
=>
'<p>secret</p>'
,
}),
})
def
expect_outbox_export
json
=
export_json
(
:outbox
)
aggregate_failures
do
expect
(
json
[
'@context'
]).
to_not
be_nil
expect
(
json
[
'type'
]).
to
eq
'OrderedCollection'
expect
(
json
[
'totalItems'
]).
to
eq
2
expect
(
json
[
'orderedItems'
][
0
][
'@context'
]).
to
be_nil
expect
(
json
[
'orderedItems'
][
0
]).
to
include_create_item
(
status
)
expect
(
json
[
'orderedItems'
][
1
]).
to
include_create_item
(
private_status
)
end
end
def
expect_likes_export
json
=
export_json
(
:likes
)
aggregate_failures
do
expect
(
json
[
'type'
]).
to
eq
'OrderedCollection'
expect
(
json
[
'orderedItems'
]).
to
eq
[
ActivityPub
::
TagManager
.
instance
.
uri_for
(
favourite
.
status
)]
end
end
it
'exports likes.json as expected'
do
service_call
def
expect_bookmarks_export
json
=
export_json
(
:bookmarks
)
json
=
Oj
.
load
(
read_zip_file
(
backup
,
'likes.json'
))
expect
(
json
[
'type'
]).
to
eq
'OrderedCollection'
expect
(
json
[
'orderedItems'
]).
to
eq
[
ActivityPub
::
TagManager
.
instance
.
uri_for
(
favourite
.
status
)]
aggregate_failures
do
expect
(
json
[
'type'
]).
to
eq
'OrderedCollection'
expect
(
json
[
'orderedItems'
]).
to
eq
[
ActivityPub
::
TagManager
.
instance
.
uri_for
(
bookmark
.
status
)]
end
end
it
'exports bookmarks.json as expected'
do
service_call
def
export_json
(
type
)
Oj
.
load
(
read_zip_file
(
backup
,
"
#{
type
}
.json"
))
end
json
=
Oj
.
load
(
read_zip_file
(
backup
,
'bookmarks.json'
))
expect
(
json
[
'type'
]).
to
eq
'OrderedCollection'
expect
(
json
[
'orderedItems'
]).
to
eq
[
ActivityPub
::
TagManager
.
instance
.
uri_for
(
bookmark
.
status
)]
def
include_create_item
(
status
)
include
({
'type'
=>
'Create'
,
'object'
=>
include
({
'id'
=>
ActivityPub
::
TagManager
.
instance
.
uri_for
(
status
),
'content'
=>
"<p>
#{
status
.
text
}
</p>"
,
}),
})
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