Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Léo-Paul Géneau
gitlab-ce
Commits
42f10974
Commit
42f10974
authored
Jul 08, 2017
by
Stan Hu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add spec for IssuableMetadata module
parent
0a9a33e7
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
59 additions
and
0 deletions
+59
-0
spec/lib/gitlab/issuable_metadata_spec.rb
spec/lib/gitlab/issuable_metadata_spec.rb
+59
-0
No files found.
spec/lib/gitlab/issuable_metadata_spec.rb
0 → 100644
View file @
42f10974
require
'spec_helper'
describe
Gitlab
::
IssuableMetadata
,
lib:
true
do
let
(
:user
)
{
create
(
:user
)
}
let!
(
:project
)
{
create
(
:project
,
:public
,
:repository
,
creator:
user
,
namespace:
user
.
namespace
)
}
subject
{
Class
.
new
{
include
Gitlab
::
IssuableMetadata
}.
new
}
it
'returns an empty Hash if an empty collection is provided'
do
expect
(
subject
.
issuable_meta_data
(
Issue
.
none
,
'Issue'
)).
to
eq
({})
end
context
'issues'
do
let!
(
:issue
)
{
create
(
:issue
,
author:
user
,
project:
project
)
}
let!
(
:closed_issue
)
{
create
(
:issue
,
state: :closed
,
author:
user
,
project:
project
)
}
let!
(
:downvote
)
{
create
(
:award_emoji
,
:downvote
,
awardable:
closed_issue
)
}
let!
(
:upvote
)
{
create
(
:award_emoji
,
:upvote
,
awardable:
issue
)
}
let!
(
:merge_request
)
{
create
(
:merge_request
,
:simple
,
author:
user
,
assignee:
user
,
source_project:
project
,
target_project:
project
,
title:
"Test"
)
}
let!
(
:closing_issues
)
{
create
(
:merge_requests_closing_issues
,
issue:
issue
,
merge_request:
merge_request
)
}
it
'aggregates stats on issues'
do
data
=
subject
.
issuable_meta_data
(
Issue
.
all
,
'Issue'
)
expect
(
data
.
count
).
to
eq
(
2
)
expect
(
data
[
issue
.
id
].
upvotes
).
to
eq
(
1
)
expect
(
data
[
issue
.
id
].
downvotes
).
to
eq
(
0
)
expect
(
data
[
issue
.
id
].
notes_count
).
to
eq
(
0
)
expect
(
data
[
issue
.
id
].
merge_requests_count
).
to
eq
(
1
)
expect
(
data
[
closed_issue
.
id
].
upvotes
).
to
eq
(
0
)
expect
(
data
[
closed_issue
.
id
].
downvotes
).
to
eq
(
1
)
expect
(
data
[
closed_issue
.
id
].
notes_count
).
to
eq
(
0
)
expect
(
data
[
closed_issue
.
id
].
merge_requests_count
).
to
eq
(
0
)
end
end
context
'merge requests'
do
let!
(
:merge_request
)
{
create
(
:merge_request
,
:simple
,
author:
user
,
assignee:
user
,
source_project:
project
,
target_project:
project
,
title:
"Test"
)
}
let!
(
:merge_request_closed
)
{
create
(
:merge_request
,
state:
"closed"
,
source_project:
project
,
target_project:
project
,
title:
"Closed Test"
)
}
let!
(
:downvote
)
{
create
(
:award_emoji
,
:downvote
,
awardable:
merge_request
)
}
let!
(
:upvote
)
{
create
(
:award_emoji
,
:upvote
,
awardable:
merge_request
)
}
let!
(
:note
)
{
create
(
:note_on_merge_request
,
author:
user
,
project:
project
,
noteable:
merge_request
,
note:
"a comment on a MR"
)
}
it
'aggregates stats on merge requests'
do
data
=
subject
.
issuable_meta_data
(
MergeRequest
.
all
,
'MergeRequest'
)
expect
(
data
.
count
).
to
eq
(
2
)
expect
(
data
[
merge_request
.
id
].
upvotes
).
to
eq
(
1
)
expect
(
data
[
merge_request
.
id
].
downvotes
).
to
eq
(
1
)
expect
(
data
[
merge_request
.
id
].
notes_count
).
to
eq
(
1
)
expect
(
data
[
merge_request
.
id
].
merge_requests_count
).
to
eq
(
0
)
expect
(
data
[
merge_request_closed
.
id
].
upvotes
).
to
eq
(
0
)
expect
(
data
[
merge_request_closed
.
id
].
downvotes
).
to
eq
(
0
)
expect
(
data
[
merge_request_closed
.
id
].
notes_count
).
to
eq
(
0
)
expect
(
data
[
merge_request_closed
.
id
].
merge_requests_count
).
to
eq
(
0
)
end
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment