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
6d15345d
Commit
6d15345d
authored
Apr 30, 2020
by
Jan Provaznik
Committed by
Dmytro Zaporozhets
Apr 30, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Renamed requirement service
* moved under requirement_management
parent
78b68298
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
70 additions
and
68 deletions
+70
-68
ee/app/finders/requirements_finder.rb
ee/app/finders/requirements_finder.rb
+0
-58
ee/app/finders/requirements_management/requirements_finder.rb
...pp/finders/requirements_management/requirements_finder.rb
+60
-0
ee/app/graphql/mutations/requirements/create.rb
ee/app/graphql/mutations/requirements/create.rb
+1
-1
ee/app/graphql/mutations/requirements/update.rb
ee/app/graphql/mutations/requirements/update.rb
+1
-1
ee/app/graphql/resolvers/requirements_resolver.rb
ee/app/graphql/resolvers/requirements_resolver.rb
+1
-1
ee/app/services/requirements_management/create_requirement_service.rb
...ces/requirements_management/create_requirement_service.rb
+2
-2
ee/app/services/requirements_management/update_requirement_service.rb
...ces/requirements_management/update_requirement_service.rb
+2
-2
ee/spec/finders/requirements_management/requirements_finder_spec.rb
...nders/requirements_management/requirements_finder_spec.rb
+1
-1
ee/spec/services/requirements_management/create_requirement_service_spec.rb
...equirements_management/create_requirement_service_spec.rb
+1
-1
ee/spec/services/requirements_management/update_requirement_service_spec.rb
...equirements_management/update_requirement_service_spec.rb
+1
-1
No files found.
ee/app/finders/requirements_finder.rb
deleted
100644 → 0
View file @
78b68298
# frozen_string_literal: true
class
RequirementsFinder
include
Gitlab
::
Utils
::
StrongMemoize
# Params:
# project_id: integer
# iids: integer[]
# state: string[]
# sort: string
def
initialize
(
current_user
,
params
=
{})
@current_user
=
current_user
@params
=
params
end
def
execute
items
=
init_collection
items
=
by_state
(
items
)
items
=
by_iid
(
items
)
sort
(
items
)
end
private
attr_reader
:current_user
,
:params
def
init_collection
return
RequirementsManagement
::
Requirement
.
none
unless
Ability
.
allowed?
(
current_user
,
:read_requirement
,
project
)
project
.
requirements
end
def
by_iid
(
items
)
return
items
unless
params
[
:iids
].
present?
items
.
for_iid
(
params
[
:iids
])
end
def
by_state
(
items
)
return
items
unless
params
[
:state
].
present?
items
.
for_state
(
params
[
:state
])
end
def
project
strong_memoize
(
:project
)
do
::
Project
.
find_by_id
(
params
[
:project_id
])
if
params
[
:project_id
].
present?
end
end
def
sort
(
items
)
sorts
=
RequirementsManagement
::
Requirement
.
simple_sorts
.
keys
sort
=
sorts
.
include?
(
params
[
:sort
])
?
params
[
:sort
]
:
'id_desc'
items
.
order_by
(
sort
)
end
end
ee/app/finders/requirements_management/requirements_finder.rb
0 → 100644
View file @
6d15345d
# frozen_string_literal: true
module
RequirementsManagement
class
RequirementsFinder
include
Gitlab
::
Utils
::
StrongMemoize
# Params:
# project_id: integer
# iids: integer[]
# state: string[]
# sort: string
def
initialize
(
current_user
,
params
=
{})
@current_user
=
current_user
@params
=
params
end
def
execute
items
=
init_collection
items
=
by_state
(
items
)
items
=
by_iid
(
items
)
sort
(
items
)
end
private
attr_reader
:current_user
,
:params
def
init_collection
return
RequirementsManagement
::
Requirement
.
none
unless
Ability
.
allowed?
(
current_user
,
:read_requirement
,
project
)
project
.
requirements
end
def
by_iid
(
items
)
return
items
unless
params
[
:iids
].
present?
items
.
for_iid
(
params
[
:iids
])
end
def
by_state
(
items
)
return
items
unless
params
[
:state
].
present?
items
.
for_state
(
params
[
:state
])
end
def
project
strong_memoize
(
:project
)
do
::
Project
.
find_by_id
(
params
[
:project_id
])
if
params
[
:project_id
].
present?
end
end
def
sort
(
items
)
sorts
=
RequirementsManagement
::
Requirement
.
simple_sorts
.
keys
sort
=
sorts
.
include?
(
params
[
:sort
])
?
params
[
:sort
]
:
'id_desc'
items
.
order_by
(
sort
)
end
end
end
ee/app/graphql/mutations/requirements/create.rb
View file @
6d15345d
...
@@ -26,7 +26,7 @@ module Mutations
...
@@ -26,7 +26,7 @@ module Mutations
project
=
authorized_find!
(
full_path:
project_path
)
project
=
authorized_find!
(
full_path:
project_path
)
validate_flag!
(
project
)
validate_flag!
(
project
)
requirement
=
::
Requirements
::
Create
Service
.
new
(
requirement
=
::
Requirements
Management
::
CreateRequirement
Service
.
new
(
project
,
project
,
context
[
:current_user
],
context
[
:current_user
],
args
args
...
...
ee/app/graphql/mutations/requirements/update.rb
View file @
6d15345d
...
@@ -43,7 +43,7 @@ module Mutations
...
@@ -43,7 +43,7 @@ module Mutations
requirement_iid
=
args
.
delete
(
:iid
)
requirement_iid
=
args
.
delete
(
:iid
)
requirement
=
authorized_find!
(
project_path:
project_path
,
iid:
requirement_iid
)
requirement
=
authorized_find!
(
project_path:
project_path
,
iid:
requirement_iid
)
requirement
=
::
Requirements
::
Update
Service
.
new
(
requirement
=
::
Requirements
Management
::
UpdateRequirement
Service
.
new
(
requirement
.
project
,
requirement
.
project
,
context
[
:current_user
],
context
[
:current_user
],
args
args
...
...
ee/app/graphql/resolvers/requirements_resolver.rb
View file @
6d15345d
...
@@ -31,7 +31,7 @@ module Resolvers
...
@@ -31,7 +31,7 @@ module Resolvers
args
[
:project_id
]
=
project
.
id
args
[
:project_id
]
=
project
.
id
args
[
:iids
]
||=
[
args
[
:iid
]].
compact
args
[
:iids
]
||=
[
args
[
:iid
]].
compact
RequirementsFinder
.
new
(
context
[
:current_user
],
args
).
execute
Requirements
Management
::
Requirements
Finder
.
new
(
context
[
:current_user
],
args
).
execute
end
end
end
end
end
end
ee/app/services/requirements
/create
_service.rb
→
ee/app/services/requirements
_management/create_requirement
_service.rb
View file @
6d15345d
# frozen_string_literal: true
# frozen_string_literal: true
module
Requirements
module
Requirements
Management
class
CreateService
<
BaseService
class
Create
Requirement
Service
<
BaseService
include
Gitlab
::
Allowable
include
Gitlab
::
Allowable
def
execute
def
execute
...
...
ee/app/services/requirements
/update
_service.rb
→
ee/app/services/requirements
_management/update_requirement
_service.rb
View file @
6d15345d
# frozen_string_literal: true
# frozen_string_literal: true
module
Requirements
module
Requirements
Management
class
UpdateService
<
BaseService
class
Update
Requirement
Service
<
BaseService
def
execute
(
requirement
)
def
execute
(
requirement
)
raise
Gitlab
::
Access
::
AccessDeniedError
unless
can?
(
current_user
,
:update_requirement
,
project
)
raise
Gitlab
::
Access
::
AccessDeniedError
unless
can?
(
current_user
,
:update_requirement
,
project
)
...
...
ee/spec/finders/requirements_finder_spec.rb
→
ee/spec/finders/requirements_
management/requirements_
finder_spec.rb
View file @
6d15345d
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
require
'spec_helper'
require
'spec_helper'
describe
RequirementsFinder
do
describe
Requirements
Management
::
Requirements
Finder
do
let_it_be
(
:project
)
{
create
(
:project
)
}
let_it_be
(
:project
)
{
create
(
:project
)
}
let_it_be
(
:project_user
)
{
create
(
:user
).
tap
{
|
u
|
project
.
add_developer
(
u
)
}
}
let_it_be
(
:project_user
)
{
create
(
:user
).
tap
{
|
u
|
project
.
add_developer
(
u
)
}
}
let_it_be
(
:requirement1
)
{
create
(
:requirement
,
project:
project
,
state:
'opened'
,
updated_at:
3
.
days
.
ago
)
}
let_it_be
(
:requirement1
)
{
create
(
:requirement
,
project:
project
,
state:
'opened'
,
updated_at:
3
.
days
.
ago
)
}
...
...
ee/spec/services/requirements
/create
_service_spec.rb
→
ee/spec/services/requirements
_management/create_requirement
_service_spec.rb
View file @
6d15345d
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
require
'spec_helper'
require
'spec_helper'
describe
Requirements
::
Create
Service
do
describe
Requirements
Management
::
CreateRequirement
Service
do
let_it_be
(
:project
)
{
create
(
:project
)}
let_it_be
(
:project
)
{
create
(
:project
)}
let_it_be
(
:user
)
{
create
(
:user
)
}
let_it_be
(
:user
)
{
create
(
:user
)
}
let_it_be
(
:other_user
)
{
create
(
:user
)
}
let_it_be
(
:other_user
)
{
create
(
:user
)
}
...
...
ee/spec/services/requirements
/update
_service_spec.rb
→
ee/spec/services/requirements
_management/update_requirement
_service_spec.rb
View file @
6d15345d
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
require
'spec_helper'
require
'spec_helper'
describe
Requirements
::
Update
Service
do
describe
Requirements
Management
::
UpdateRequirement
Service
do
let_it_be
(
:project
)
{
create
(
:project
)}
let_it_be
(
:project
)
{
create
(
:project
)}
let_it_be
(
:user
)
{
create
(
:user
)
}
let_it_be
(
:user
)
{
create
(
:user
)
}
let_it_be
(
:requirement
)
{
create
(
:requirement
,
project:
project
)
}
let_it_be
(
:requirement
)
{
create
(
:requirement
,
project:
project
)
}
...
...
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