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
b99bc6d3
Commit
b99bc6d3
authored
Jun 19, 2018
by
James Lopez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add group finder spec and logic
parent
e0c06470
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
54 additions
and
0 deletions
+54
-0
lib/gitlab/import_export/group_project_finder.rb
lib/gitlab/import_export/group_project_finder.rb
+33
-0
spec/lib/gitlab/import_export/group_project_finder_spec.rb
spec/lib/gitlab/import_export/group_project_finder_spec.rb
+21
-0
No files found.
lib/gitlab/import_export/group_project_finder.rb
0 → 100644
View file @
b99bc6d3
module
Gitlab
module
ImportExport
class
GroupProjectFinder
def
self
.
find
(
*
args
)
new
(
*
args
).
find
end
def
initialize
(
klass
,
attributes
)
@klass
=
klass
@attributes
=
attributes
@group_id
=
@attributes
[
'group_id'
]
@project_id
=
@attributes
[
'project_id'
]
end
def
find
@klass
.
where
(
where_clause
)
end
private
def
where_clause
@attributes
.
except
(
'group_id'
,
'project_id'
).
map
do
|
key
,
value
|
table
[
key
].
eq
(
value
).
and
(
table
[
:group_id
].
eq
(
@group_id
))
.
or
(
table
[
key
].
eq
(
value
).
and
(
table
[
:project_id
].
eq
(
@project_id
)))
end
.
reduce
(
:or
)
end
def
table
@table
||=
@klass
.
arel_table
end
end
end
end
spec/lib/gitlab/import_export/group_project_finder_spec.rb
0 → 100644
View file @
b99bc6d3
require
'spec_helper'
describe
Gitlab
::
ImportExport
::
GroupProjectFinder
do
let
(
:project
)
do
create
(
:project
,
:builds_disabled
,
:issues_disabled
,
name:
'project'
,
path:
'project'
,
group:
create
(
:group
))
end
it
'finds the right group label'
do
group_label
=
create
(
:group_label
,
'name'
:
'group label'
,
'group'
:
project
.
group
)
expect
(
described_class
.
find
(
Label
,
title:
'group label'
,
'project_id'
:
project
.
id
,
'group_id'
:
project
.
group
.
id
)).
to
eq
([
group_label
])
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