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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
2f381e5e
Commit
2f381e5e
authored
Mar 19, 2019
by
Rémy Coutable
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[CE] Reduce differences with EE in issues_finder_spec.rb
Signed-off-by:
Rémy Coutable
<
remy@rymai.me
>
parent
30a4e553
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
87 additions
and
37 deletions
+87
-37
spec/finders/issues_finder_spec.rb
spec/finders/issues_finder_spec.rb
+43
-37
spec/support/shared_contexts/finders/issues_finder_shared_contexts.rb
.../shared_contexts/finders/issues_finder_shared_contexts.rb
+44
-0
No files found.
spec/finders/issues_finder_spec.rb
View file @
2f381e5e
require
'spec_helper'
require
'spec_helper'
describe
IssuesFinder
do
describe
IssuesFinder
do
set
(
:user
)
{
create
(
:user
)
}
include_context
'IssuesFinder context'
set
(
:user2
)
{
create
(
:user
)
}
set
(
:group
)
{
create
(
:group
)
}
set
(
:subgroup
)
{
create
(
:group
,
parent:
group
)
}
set
(
:project1
)
{
create
(
:project
,
group:
group
)
}
set
(
:project2
)
{
create
(
:project
)
}
set
(
:project3
)
{
create
(
:project
,
group:
subgroup
)
}
set
(
:milestone
)
{
create
(
:milestone
,
project:
project1
)
}
set
(
:label
)
{
create
(
:label
,
project:
project2
)
}
set
(
:issue1
)
{
create
(
:issue
,
author:
user
,
assignees:
[
user
],
project:
project1
,
milestone:
milestone
,
title:
'gitlab'
,
created_at:
1
.
week
.
ago
,
updated_at:
1
.
week
.
ago
)
}
set
(
:issue2
)
{
create
(
:issue
,
author:
user
,
assignees:
[
user
],
project:
project2
,
description:
'gitlab'
,
created_at:
1
.
week
.
from_now
,
updated_at:
1
.
week
.
from_now
)
}
set
(
:issue3
)
{
create
(
:issue
,
author:
user2
,
assignees:
[
user2
],
project:
project2
,
title:
'tanuki'
,
description:
'tanuki'
,
created_at:
2
.
weeks
.
from_now
,
updated_at:
2
.
weeks
.
from_now
)
}
set
(
:issue4
)
{
create
(
:issue
,
project:
project3
)
}
set
(
:award_emoji1
)
{
create
(
:award_emoji
,
name:
'thumbsup'
,
user:
user
,
awardable:
issue1
)
}
set
(
:award_emoji2
)
{
create
(
:award_emoji
,
name:
'thumbsup'
,
user:
user2
,
awardable:
issue2
)
}
set
(
:award_emoji3
)
{
create
(
:award_emoji
,
name:
'thumbsdown'
,
user:
user
,
awardable:
issue3
)
}
describe
'#execute'
do
describe
'#execute'
do
let!
(
:closed_issue
)
{
create
(
:issue
,
author:
user2
,
assignees:
[
user2
],
project:
project2
,
state:
'closed'
)
}
include_context
'IssuesFinder#execute context'
let!
(
:label_link
)
{
create
(
:label_link
,
label:
label
,
target:
issue2
)
}
let
(
:search_user
)
{
user
}
let
(
:params
)
{
{}
}
let
(
:issues
)
{
described_class
.
new
(
search_user
,
params
.
reverse_merge
(
scope:
scope
,
state:
'opened'
)).
execute
}
before
(
:context
)
do
project1
.
add_maintainer
(
user
)
project2
.
add_developer
(
user
)
project2
.
add_developer
(
user2
)
project3
.
add_developer
(
user
)
issue1
issue2
issue3
issue4
award_emoji1
award_emoji2
award_emoji3
end
context
'scope: all'
do
context
'scope: all'
do
let
(
:scope
)
{
'all'
}
let
(
:scope
)
{
'all'
}
...
@@ -56,6 +21,21 @@ describe IssuesFinder do
...
@@ -56,6 +21,21 @@ describe IssuesFinder do
end
end
end
end
context
'filtering by assignee usernames'
do
set
(
:user3
)
{
create
(
:user
)
}
let
(
:params
)
{
{
assignee_username:
[
user2
.
username
,
user3
.
username
]
}
}
before
do
project2
.
add_developer
(
user3
)
issue3
.
assignees
=
[
user2
,
user3
]
end
it
'returns issues assigned to those users'
do
expect
(
issues
).
to
contain_exactly
(
issue3
)
end
end
context
'filtering by no assignee'
do
context
'filtering by no assignee'
do
let
(
:params
)
{
{
assignee_id:
'None'
}
}
let
(
:params
)
{
{
assignee_id:
'None'
}
}
...
@@ -643,6 +623,16 @@ describe IssuesFinder do
...
@@ -643,6 +623,16 @@ describe IssuesFinder do
expect
(
subject
).
to
include
(
public_issue
,
confidential_issue
)
expect
(
subject
).
to
include
(
public_issue
,
confidential_issue
)
end
end
end
end
context
'for an admin'
do
let
(
:admin_user
)
{
create
(
:user
,
:admin
)
}
subject
{
described_class
.
new
(
admin_user
,
params
).
with_confidentiality_access_check
}
it
'returns all issues'
do
expect
(
subject
).
to
include
(
public_issue
,
confidential_issue
)
end
end
end
end
context
'when searching within a specific project'
do
context
'when searching within a specific project'
do
...
@@ -710,6 +700,22 @@ describe IssuesFinder do
...
@@ -710,6 +700,22 @@ describe IssuesFinder do
subject
subject
end
end
end
end
context
'for an admin'
do
let
(
:admin_user
)
{
create
(
:user
,
:admin
)
}
subject
{
described_class
.
new
(
admin_user
,
params
).
with_confidentiality_access_check
}
it
'returns all issues'
do
expect
(
subject
).
to
include
(
public_issue
,
confidential_issue
)
end
it
'does not filter by confidentiality'
do
expect
(
Issue
).
not_to
receive
(
:where
).
with
(
a_string_matching
(
'confidential'
),
anything
)
subject
end
end
end
end
end
end
...
...
spec/support/shared_contexts/finders/issues_finder_shared_contexts.rb
0 → 100644
View file @
2f381e5e
require
'spec_helper'
RSpec
.
shared_context
'IssuesFinder context'
do
set
(
:user
)
{
create
(
:user
)
}
set
(
:user2
)
{
create
(
:user
)
}
set
(
:group
)
{
create
(
:group
)
}
set
(
:subgroup
)
{
create
(
:group
,
parent:
group
)
}
set
(
:project1
)
{
create
(
:project
,
group:
group
)
}
set
(
:project2
)
{
create
(
:project
)
}
set
(
:project3
)
{
create
(
:project
,
group:
subgroup
)
}
set
(
:milestone
)
{
create
(
:milestone
,
project:
project1
)
}
set
(
:label
)
{
create
(
:label
,
project:
project2
)
}
set
(
:issue1
)
{
create
(
:issue
,
author:
user
,
assignees:
[
user
],
project:
project1
,
milestone:
milestone
,
title:
'gitlab'
,
created_at:
1
.
week
.
ago
,
updated_at:
1
.
week
.
ago
)
}
set
(
:issue2
)
{
create
(
:issue
,
author:
user
,
assignees:
[
user
],
project:
project2
,
description:
'gitlab'
,
created_at:
1
.
week
.
from_now
,
updated_at:
1
.
week
.
from_now
)
}
set
(
:issue3
)
{
create
(
:issue
,
author:
user2
,
assignees:
[
user2
],
project:
project2
,
title:
'tanuki'
,
description:
'tanuki'
,
created_at:
2
.
weeks
.
from_now
,
updated_at:
2
.
weeks
.
from_now
)
}
set
(
:issue4
)
{
create
(
:issue
,
project:
project3
)
}
set
(
:award_emoji1
)
{
create
(
:award_emoji
,
name:
'thumbsup'
,
user:
user
,
awardable:
issue1
)
}
set
(
:award_emoji2
)
{
create
(
:award_emoji
,
name:
'thumbsup'
,
user:
user2
,
awardable:
issue2
)
}
set
(
:award_emoji3
)
{
create
(
:award_emoji
,
name:
'thumbsdown'
,
user:
user
,
awardable:
issue3
)
}
end
RSpec
.
shared_context
'IssuesFinder#execute context'
do
let!
(
:closed_issue
)
{
create
(
:issue
,
author:
user2
,
assignees:
[
user2
],
project:
project2
,
state:
'closed'
)
}
let!
(
:label_link
)
{
create
(
:label_link
,
label:
label
,
target:
issue2
)
}
let
(
:search_user
)
{
user
}
let
(
:params
)
{
{}
}
let
(
:issues
)
{
described_class
.
new
(
search_user
,
params
.
reverse_merge
(
scope:
scope
,
state:
'opened'
)).
execute
}
before
(
:context
)
do
project1
.
add_maintainer
(
user
)
project2
.
add_developer
(
user
)
project2
.
add_developer
(
user2
)
project3
.
add_developer
(
user
)
issue1
issue2
issue3
issue4
award_emoji1
award_emoji2
award_emoji3
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