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
28b366d0
Commit
28b366d0
authored
6 years ago
by
Shuhei Kitagawa
Committed by
Eugen Rochko
6 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Add missing tests for report.rb (#7324)
parent
ad5d3134
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/models/report_spec.rb
+95
-0
95 additions, 0 deletions
spec/models/report_spec.rb
with
95 additions
and
0 deletions
spec/models/report_spec.rb
+
95
−
0
View file @
28b366d0
...
...
@@ -22,6 +22,101 @@ describe Report do
end
end
describe
'assign_to_self!'
do
subject
{
report
.
assigned_account_id
}
let
(
:report
)
{
Fabricate
(
:report
,
assigned_account_id:
original_account
)
}
let
(
:original_account
)
{
Fabricate
(
:account
)
}
let
(
:current_account
)
{
Fabricate
(
:account
)
}
before
do
report
.
assign_to_self!
(
current_account
)
end
it
'assigns to a given account'
do
is_expected
.
to
eq
current_account
.
id
end
end
describe
'unassign!'
do
subject
{
report
.
assigned_account_id
}
let
(
:report
)
{
Fabricate
(
:report
,
assigned_account_id:
account
.
id
)
}
let
(
:account
)
{
Fabricate
(
:account
)
}
before
do
report
.
unassign!
end
it
'unassigns'
do
is_expected
.
to
be_nil
end
end
describe
'resolve!'
do
subject
(
:report
)
{
Fabricate
(
:report
,
action_taken:
false
,
action_taken_by_account_id:
nil
)
}
let
(
:acting_account
)
{
Fabricate
(
:account
)
}
before
do
report
.
resolve!
(
acting_account
)
end
it
'records action taken'
do
expect
(
report
).
to
have_attributes
(
action_taken:
true
,
action_taken_by_account_id:
acting_account
.
id
)
end
end
describe
'unresolve!'
do
subject
(
:report
)
{
Fabricate
(
:report
,
action_taken:
true
,
action_taken_by_account_id:
acting_account
.
id
)
}
let
(
:acting_account
)
{
Fabricate
(
:account
)
}
before
do
report
.
unresolve!
end
it
'unresolves'
do
expect
(
report
).
to
have_attributes
(
action_taken:
false
,
action_taken_by_account_id:
nil
)
end
end
describe
'unresolved?'
do
subject
{
report
.
unresolved?
}
let
(
:report
)
{
Fabricate
(
:report
,
action_taken:
action_taken
)
}
context
'if action is taken'
do
let
(
:action_taken
)
{
true
}
it
{
is_expected
.
to
be
false
}
end
context
'if action not is taken'
do
let
(
:action_taken
)
{
false
}
it
{
is_expected
.
to
be
true
}
end
end
describe
'history'
do
subject
(
:action_logs
)
{
report
.
history
}
let
(
:report
)
{
Fabricate
(
:report
,
target_account_id:
target_account
.
id
,
status_ids:
[
status
.
id
],
created_at:
3
.
days
.
ago
,
updated_at:
1
.
day
.
ago
)
}
let
(
:target_account
)
{
Fabricate
(
:account
)
}
let
(
:status
)
{
Fabricate
(
:status
)
}
before
do
Fabricate
(
'Admin::ActionLog'
,
target_type:
'Report'
,
account_id:
target_account
.
id
,
target_id:
report
.
id
,
created_at:
2
.
days
.
ago
)
Fabricate
(
'Admin::ActionLog'
,
target_type:
'Account'
,
account_id:
target_account
.
id
,
target_id:
report
.
target_account_id
,
created_at:
2
.
days
.
ago
)
Fabricate
(
'Admin::ActionLog'
,
target_type:
'Status'
,
account_id:
target_account
.
id
,
target_id:
status
.
id
,
created_at:
2
.
days
.
ago
)
end
it
'returns right logs'
do
expect
(
action_logs
.
count
).
to
eq
3
end
end
describe
'validatiions'
do
it
'has a valid fabricator'
do
report
=
Fabricate
(
:report
)
...
...
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