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
44449c7b
Commit
44449c7b
authored
Mar 22, 2019
by
GitLab Bot
Browse files
Options
Browse Files
Download
Plain Diff
Automatic merge of gitlab-org/gitlab-ce master
parents
a898b0a7
322c14be
Changes
11
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
600 additions
and
614 deletions
+600
-614
spec/finders/group_projects_finder_spec.rb
spec/finders/group_projects_finder_spec.rb
+1
-20
spec/finders/issues_finder_spec.rb
spec/finders/issues_finder_spec.rb
+2
-37
spec/finders/merge_requests_finder_spec.rb
spec/finders/merge_requests_finder_spec.rb
+45
-94
spec/finders/snippets_finder_spec.rb
spec/finders/snippets_finder_spec.rb
+91
-124
spec/finders/users_finder_spec.rb
spec/finders/users_finder_spec.rb
+14
-17
spec/support/shared_contexts/finders/group_projects_finder_shared_contexts.rb
...contexts/finders/group_projects_finder_shared_contexts.rb
+24
-0
spec/support/shared_contexts/finders/issues_finder_shared_contexts.rb
.../shared_contexts/finders/issues_finder_shared_contexts.rb
+44
-0
spec/support/shared_contexts/finders/merge_requests_finder_shared_contexts.rb
...contexts/finders/merge_requests_finder_shared_contexts.rb
+65
-0
spec/support/shared_contexts/finders/users_finder_shared_contexts.rb
...t/shared_contexts/finders/users_finder_shared_contexts.rb
+8
-0
spec/support/shared_examples/snippet_visibility.rb
spec/support/shared_examples/snippet_visibility.rb
+0
-322
spec/support/shared_examples/snippet_visibility_shared_examples.rb
...ort/shared_examples/snippet_visibility_shared_examples.rb
+306
-0
No files found.
spec/finders/group_projects_finder_spec.rb
View file @
44449c7b
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
}
...
...
spec/finders/issues_finder_spec.rb
View file @
44449c7b
require
'spec_helper'
describe
IssuesFinder
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
)
}
include_context
'IssuesFinder context'
describe
'#execute'
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
include_context
'IssuesFinder#execute context'
context
'scope: all'
do
let
(
:scope
)
{
'all'
}
...
...
spec/finders/merge_requests_finder_spec.rb
View file @
44449c7b
This diff is collapsed.
Click to expand it.
spec/finders/snippets_finder_spec.rb
View file @
44449c7b
This diff is collapsed.
Click to expand it.
spec/finders/users_finder_spec.rb
View file @
44449c7b
...
...
@@ -2,10 +2,7 @@ require 'spec_helper'
describe
UsersFinder
do
describe
'#execute'
do
let!
(
:user1
)
{
create
(
:user
,
username:
'johndoe'
)
}
let!
(
:user2
)
{
create
(
:user
,
:blocked
,
username:
'notsorandom'
)
}
let!
(
:external_user
)
{
create
(
:user
,
:external
)
}
let!
(
:omniauth_user
)
{
create
(
:omniauth_user
,
provider:
'twitter'
,
extern_uid:
'123456'
)
}
include_context
'UsersFinder#execute filter by project context'
context
'with a normal user'
do
let
(
:user
)
{
create
(
:user
)
}
...
...
@@ -13,43 +10,43 @@ describe UsersFinder do
it
'returns all users'
do
users
=
described_class
.
new
(
user
).
execute
expect
(
users
).
to
contain_exactly
(
user
,
user1
,
user2
,
omniauth_user
)
expect
(
users
).
to
contain_exactly
(
user
,
normal_user
,
blocked_user
,
omniauth_user
)
end
it
'filters by username'
do
users
=
described_class
.
new
(
user
,
username:
'johndoe'
).
execute
expect
(
users
).
to
contain_exactly
(
user1
)
expect
(
users
).
to
contain_exactly
(
normal_user
)
end
it
'filters by username (case insensitive)'
do
users
=
described_class
.
new
(
user
,
username:
'joHNdoE'
).
execute
expect
(
users
).
to
contain_exactly
(
user1
)
expect
(
users
).
to
contain_exactly
(
normal_user
)
end
it
'filters by search'
do
users
=
described_class
.
new
(
user
,
search:
'orando'
).
execute
expect
(
users
).
to
contain_exactly
(
user2
)
expect
(
users
).
to
contain_exactly
(
blocked_user
)
end
it
'filters by blocked users'
do
users
=
described_class
.
new
(
user
,
blocked:
true
).
execute
expect
(
users
).
to
contain_exactly
(
user2
)
expect
(
users
).
to
contain_exactly
(
blocked_user
)
end
it
'filters by active users'
do
users
=
described_class
.
new
(
user
,
active:
true
).
execute
expect
(
users
).
to
contain_exactly
(
user
,
user1
,
omniauth_user
)
expect
(
users
).
to
contain_exactly
(
user
,
normal_user
,
omniauth_user
)
end
it
'returns no external users'
do
users
=
described_class
.
new
(
user
,
external:
true
).
execute
expect
(
users
).
to
contain_exactly
(
user
,
user1
,
user2
,
omniauth_user
)
expect
(
users
).
to
contain_exactly
(
user
,
normal_user
,
blocked_user
,
omniauth_user
)
end
context
'with LDAP users'
do
...
...
@@ -85,7 +82,7 @@ describe UsersFinder do
custom_attributes:
{
foo:
'bar'
}
).
execute
expect
(
users
).
to
contain_exactly
(
user
,
user1
,
user2
,
omniauth_user
)
expect
(
users
).
to
contain_exactly
(
user
,
normal_user
,
blocked_user
,
omniauth_user
)
end
end
...
...
@@ -101,20 +98,20 @@ describe UsersFinder do
it
'returns all users'
do
users
=
described_class
.
new
(
admin
).
execute
expect
(
users
).
to
contain_exactly
(
admin
,
user1
,
user2
,
external_user
,
omniauth_user
)
expect
(
users
).
to
contain_exactly
(
admin
,
normal_user
,
blocked_user
,
external_user
,
omniauth_user
)
end
it
'filters by custom attributes'
do
create
:user_custom_attribute
,
user:
user1
,
key:
'foo'
,
value:
'foo'
create
:user_custom_attribute
,
user:
user1
,
key:
'bar'
,
value:
'bar'
create
:user_custom_attribute
,
user:
user2
,
key:
'foo'
,
value:
'foo'
create
:user_custom_attribute
,
user:
normal_user
,
key:
'foo'
,
value:
'foo'
create
:user_custom_attribute
,
user:
normal_user
,
key:
'bar'
,
value:
'bar'
create
:user_custom_attribute
,
user:
blocked_user
,
key:
'foo'
,
value:
'foo'
users
=
described_class
.
new
(
admin
,
custom_attributes:
{
foo:
'foo'
,
bar:
'bar'
}
).
execute
expect
(
users
).
to
contain_exactly
(
user1
)
expect
(
users
).
to
contain_exactly
(
normal_user
)
end
end
end
...
...
spec/support/shared_contexts/finders/group_projects_finder_shared_contexts.rb
0 → 100644
View file @
44449c7b
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
spec/support/shared_contexts/finders/issues_finder_shared_contexts.rb
0 → 100644
View file @
44449c7b
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
spec/support/shared_contexts/finders/merge_requests_finder_shared_contexts.rb
0 → 100644
View file @
44449c7b
require
'spec_helper'
RSpec
.
shared_context
'MergeRequestsFinder multiple projects with merge requests context'
do
include
ProjectForksHelper
# We need to explicitly permit Gitaly N+1s because of the specs that use
# :request_store. Gitaly N+1 detection is only enabled when :request_store is,
# but we don't care about potential N+1s when we're just creating several
# projects in the setup phase.
def
allow_gitaly_n_plus_1
Gitlab
::
GitalyClient
.
allow_n_plus_1_calls
do
yield
end
end
set
(
:user
)
{
create
(
:user
)
}
set
(
:user2
)
{
create
(
:user
)
}
set
(
:group
)
{
create
(
:group
)
}
set
(
:subgroup
)
{
create
(
:group
,
parent:
group
)
}
set
(
:project1
)
do
allow_gitaly_n_plus_1
{
create
(
:project
,
:public
,
group:
group
)
}
end
# We cannot use `set` here otherwise we get:
# Failure/Error: allow(RepositoryForkWorker).to receive(:perform_async).and_return(true)
# The use of doubles or partial doubles from rspec-mocks outside of the per-test lifecycle is not supported.
let
(
:project2
)
do
allow_gitaly_n_plus_1
do
fork_project
(
project1
,
user
)
end
end
let
(
:project3
)
do
allow_gitaly_n_plus_1
do
fork_project
(
project1
,
user
).
tap
do
|
project
|
project
.
update!
(
archived:
true
)
end
end
end
set
(
:project4
)
do
allow_gitaly_n_plus_1
{
create
(
:project
,
:repository
,
group:
subgroup
)
}
end
set
(
:project5
)
do
allow_gitaly_n_plus_1
{
create
(
:project
,
group:
subgroup
)
}
end
set
(
:project6
)
do
allow_gitaly_n_plus_1
{
create
(
:project
,
group:
subgroup
)
}
end
let!
(
:merge_request1
)
{
create
(
:merge_request
,
author:
user
,
source_project:
project2
,
target_project:
project1
,
target_branch:
'merged-target'
)
}
let!
(
:merge_request2
)
{
create
(
:merge_request
,
:conflict
,
author:
user
,
source_project:
project2
,
target_project:
project1
,
state:
'closed'
)
}
let!
(
:merge_request3
)
{
create
(
:merge_request
,
:simple
,
author:
user
,
source_project:
project2
,
target_project:
project2
,
state:
'locked'
,
title:
'thing WIP thing'
)
}
let!
(
:merge_request4
)
{
create
(
:merge_request
,
:simple
,
author:
user
,
source_project:
project3
,
target_project:
project3
,
title:
'WIP thing'
)
}
let!
(
:merge_request5
)
{
create
(
:merge_request
,
:simple
,
author:
user
,
source_project:
project4
,
target_project:
project4
,
title:
'[WIP]'
)
}
before
do
project1
.
add_maintainer
(
user
)
project2
.
add_developer
(
user
)
project3
.
add_developer
(
user
)
project4
.
add_developer
(
user
)
project5
.
add_developer
(
user
)
project6
.
add_developer
(
user
)
project2
.
add_developer
(
user2
)
end
end
spec/support/shared_contexts/finders/users_finder_shared_contexts.rb
0 → 100644
View file @
44449c7b
require
'spec_helper'
RSpec
.
shared_context
'UsersFinder#execute filter by project context'
do
set
(
:normal_user
)
{
create
(
:user
,
username:
'johndoe'
)
}
set
(
:blocked_user
)
{
create
(
:user
,
:blocked
,
username:
'notsorandom'
)
}
set
(
:external_user
)
{
create
(
:user
,
:external
)
}
set
(
:omniauth_user
)
{
create
(
:omniauth_user
,
provider:
'twitter'
,
extern_uid:
'123456'
)
}
end
spec/support/shared_examples/snippet_visibility.rb
deleted
100644 → 0
View file @
a898b0a7
This diff is collapsed.
Click to expand it.
spec/support/shared_examples/snippet_visibility_shared_examples.rb
0 → 100644
View file @
44449c7b
This diff is collapsed.
Click to expand it.
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