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
bf03dc08
Commit
bf03dc08
authored
Mar 19, 2019
by
Rémy Coutable
Committed by
Robert Speicher
Mar 22, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[EE] Extract EE-specific code from group_projects_finder_spec.rb
Signed-off-by:
Rémy Coutable
<
remy@rymai.me
>
parent
ae370279
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
54 additions
and
39 deletions
+54
-39
ee/spec/finders/group_projects_finder_spec.rb
ee/spec/finders/group_projects_finder_spec.rb
+29
-0
spec/finders/group_projects_finder_spec.rb
spec/finders/group_projects_finder_spec.rb
+1
-39
spec/support/shared_contexts/finders/group_projects_finder_shared_contexts.rb
...contexts/finders/group_projects_finder_shared_contexts.rb
+24
-0
No files found.
ee/spec/finders/group_projects_finder_spec.rb
0 → 100644
View file @
bf03dc08
require
'spec_helper'
describe
GroupProjectsFinder
do
include_context
'GroupProjectsFinder context'
subject
{
finder
.
execute
}
describe
'with an auditor current user'
do
let
(
:current_user
)
{
create
(
:user
,
:auditor
)
}
context
'only shared'
do
let
(
:options
)
{
{
only_shared:
true
}
}
it
{
is_expected
.
to
eq
([
shared_project_3
,
shared_project_2
,
shared_project_1
])
}
end
context
'only owned'
do
let
(
:options
)
{
{
only_owned:
true
}
}
it
{
is_expected
.
to
eq
([
private_project
,
public_project
])
}
end
context
'all'
do
subject
{
described_class
.
new
(
group:
group
,
current_user:
current_user
).
execute
}
it
{
is_expected
.
to
eq
([
shared_project_3
,
shared_project_2
,
shared_project_1
,
private_project
,
public_project
])
}
end
end
end
spec/finders/group_projects_finder_spec.rb
View file @
bf03dc08
require
'spec_helper'
describe
GroupProjectsFinder
do
let
(
:group
)
{
create
(
:group
)
}
let
(
:subgroup
)
{
create
(
:group
,
parent:
group
)
}
let
(
:current_user
)
{
create
(
:user
)
}
let
(
:options
)
{
{}
}
let
(
:finder
)
{
described_class
.
new
(
group:
group
,
current_user:
current_user
,
options:
options
)
}
let!
(
:public_project
)
{
create
(
:project
,
:public
,
group:
group
,
path:
'1'
)
}
let!
(
:private_project
)
{
create
(
:project
,
:private
,
group:
group
,
path:
'2'
)
}
let!
(
:shared_project_1
)
{
create
(
:project
,
:public
,
path:
'3'
)
}
let!
(
:shared_project_2
)
{
create
(
:project
,
:private
,
path:
'4'
)
}
let!
(
:shared_project_3
)
{
create
(
:project
,
:internal
,
path:
'5'
)
}
let!
(
:subgroup_project
)
{
create
(
:project
,
:public
,
path:
'6'
,
group:
subgroup
)
}
let!
(
:subgroup_private_project
)
{
create
(
:project
,
:private
,
path:
'7'
,
group:
subgroup
)
}
before
do
shared_project_1
.
project_group_links
.
create
(
group_access:
Gitlab
::
Access
::
MAINTAINER
,
group:
group
)
shared_project_2
.
project_group_links
.
create
(
group_access:
Gitlab
::
Access
::
MAINTAINER
,
group:
group
)
shared_project_3
.
project_group_links
.
create
(
group_access:
Gitlab
::
Access
::
MAINTAINER
,
group:
group
)
end
include_context
'GroupProjectsFinder context'
subject
{
finder
.
execute
}
...
...
@@ -162,25 +143,6 @@ describe GroupProjectsFinder do
end
end
describe
'with an auditor current user'
do
let
(
:current_user
)
{
create
(
:user
,
:auditor
)
}
context
"only shared"
do
let
(
:options
)
{
{
only_shared:
true
}
}
it
{
is_expected
.
to
eq
([
shared_project_3
,
shared_project_2
,
shared_project_1
])
}
end
context
"only owned"
do
let
(
:options
)
{
{
only_owned:
true
}
}
it
{
is_expected
.
to
eq
([
private_project
,
public_project
])
}
end
context
"all"
do
subject
{
described_class
.
new
(
group:
group
,
current_user:
current_user
).
execute
}
it
{
is_expected
.
to
eq
([
shared_project_3
,
shared_project_2
,
shared_project_1
,
private_project
,
public_project
])
}
end
end
describe
"no user"
do
context
"only shared"
do
let
(
:options
)
{
{
only_shared:
true
}
}
...
...
spec/support/shared_contexts/finders/group_projects_finder_shared_contexts.rb
0 → 100644
View file @
bf03dc08
require
'spec_helper'
RSpec
.
shared_context
'GroupProjectsFinder context'
do
let
(
:group
)
{
create
(
:group
)
}
let
(
:subgroup
)
{
create
(
:group
,
parent:
group
)
}
let
(
:current_user
)
{
create
(
:user
)
}
let
(
:options
)
{
{}
}
let
(
:finder
)
{
described_class
.
new
(
group:
group
,
current_user:
current_user
,
options:
options
)
}
let!
(
:public_project
)
{
create
(
:project
,
:public
,
group:
group
,
path:
'1'
)
}
let!
(
:private_project
)
{
create
(
:project
,
:private
,
group:
group
,
path:
'2'
)
}
let!
(
:shared_project_1
)
{
create
(
:project
,
:public
,
path:
'3'
)
}
let!
(
:shared_project_2
)
{
create
(
:project
,
:private
,
path:
'4'
)
}
let!
(
:shared_project_3
)
{
create
(
:project
,
:internal
,
path:
'5'
)
}
let!
(
:subgroup_project
)
{
create
(
:project
,
:public
,
path:
'6'
,
group:
subgroup
)
}
let!
(
:subgroup_private_project
)
{
create
(
:project
,
:private
,
path:
'7'
,
group:
subgroup
)
}
before
do
shared_project_1
.
project_group_links
.
create
(
group_access:
Gitlab
::
Access
::
MAINTAINER
,
group:
group
)
shared_project_2
.
project_group_links
.
create
(
group_access:
Gitlab
::
Access
::
MAINTAINER
,
group:
group
)
shared_project_3
.
project_group_links
.
create
(
group_access:
Gitlab
::
Access
::
MAINTAINER
,
group:
group
)
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