Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
M
mastofe
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
Container Registry
Model registry
Operate
Environments
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
KokaKiwi
mastofe
Commits
d55f2072
Commit
d55f2072
authored
7 years ago
by
Akihiko Odaki (@fn_aki@pawoo.net)
Committed by
Eugen Rochko
7 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Cover Export more (#3840)
parent
cf6fe4f8
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/fabricators/media_attachment_fabricator.rb
+1
-0
1 addition, 0 deletions
spec/fabricators/media_attachment_fabricator.rb
spec/models/export_spec.rb
+38
-11
38 additions, 11 deletions
spec/models/export_spec.rb
with
39 additions
and
11 deletions
spec/fabricators/media_attachment_fabricator.rb
+
1
−
0
View file @
d55f2072
Fabricator
(
:media_attachment
)
do
account
file
{
[
attachment_fixture
([
'attachment.gif'
,
'attachment.jpg'
,
'attachment.webm'
].
sample
),
nil
].
sample
}
end
This diff is collapsed.
Click to expand it.
spec/models/export_spec.rb
+
38
−
11
View file @
d55f2072
require
'rails_helper'
describe
Export
do
describe
'to_csv'
do
before
do
one
=
Account
.
new
(
username:
'one'
,
domain:
'local.host'
)
two
=
Account
.
new
(
username:
'two'
,
domain:
'local.host'
)
accounts
=
[
one
,
two
]
@account
=
double
(
blocking:
accounts
,
muting:
accounts
,
following:
accounts
)
end
let
(
:account
)
{
Fabricate
(
:account
)
}
let
(
:target_accounts
)
do
[
{},
{
username:
'one'
,
domain:
'local.host'
}
].
map
(
&
method
(
:Fabricate
).
curry
(
2
).
call
(
:account
))
end
describe
'to_csv'
do
it
'returns a csv of the blocked accounts'
do
export
=
Export
.
new
(
@account
).
to_blocked_accounts_csv
target_accounts
.
each
(
&
account
.
method
(
:block!
))
export
=
Export
.
new
(
account
).
to_blocked_accounts_csv
results
=
export
.
strip
.
split
expect
(
results
.
size
).
to
eq
2
...
...
@@ -19,7 +18,9 @@ describe Export do
end
it
'returns a csv of the muted accounts'
do
export
=
Export
.
new
(
@account
).
to_muted_accounts_csv
target_accounts
.
each
(
&
account
.
method
(
:mute!
))
export
=
Export
.
new
(
account
).
to_muted_accounts_csv
results
=
export
.
strip
.
split
expect
(
results
.
size
).
to
eq
2
...
...
@@ -27,11 +28,37 @@ describe Export do
end
it
'returns a csv of the following accounts'
do
export
=
Export
.
new
(
@account
).
to_following_accounts_csv
target_accounts
.
each
(
&
account
.
method
(
:follow!
))
export
=
Export
.
new
(
account
).
to_following_accounts_csv
results
=
export
.
strip
.
split
expect
(
results
.
size
).
to
eq
2
expect
(
results
.
first
).
to
eq
'one@local.host'
end
end
describe
'total_storage'
do
it
'returns the total size of the media attachments'
do
media_attachment
=
Fabricate
(
:media_attachment
,
account:
account
)
expect
(
Export
.
new
(
account
).
total_storage
).
to
eq
media_attachment
.
file_file_size
||
0
end
end
describe
'total_follows'
do
it
'returns the total number of the followed accounts'
do
target_accounts
.
each
(
&
account
.
method
(
:follow!
))
expect
(
Export
.
new
(
account
).
total_follows
).
to
eq
2
end
it
'returns the total number of the blocked accounts'
do
target_accounts
.
each
(
&
account
.
method
(
:block!
))
expect
(
Export
.
new
(
account
).
total_blocks
).
to
eq
2
end
it
'returns the total number of the muted accounts'
do
target_accounts
.
each
(
&
account
.
method
(
:mute!
))
expect
(
Export
.
new
(
account
).
total_mutes
).
to
eq
2
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