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
0
Merge Requests
0
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
Tatuya Kamada
gitlab-ce
Commits
01ab6d70
Commit
01ab6d70
authored
Apr 21, 2016
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use association search in issuable create service
parent
006d8b26
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
12 deletions
+12
-12
app/services/issuable_base_service.rb
app/services/issuable_base_service.rb
+6
-6
spec/services/issues/create_service_spec.rb
spec/services/issues/create_service_spec.rb
+6
-6
No files found.
app/services/issuable_base_service.rb
View file @
01ab6d70
...
...
@@ -57,10 +57,11 @@ class IssuableBaseService < BaseService
end
def
filter_milestone
return
unless
params
[
:milestone_id
]
milestone_id
=
params
[
:milestone_id
]
return
unless
milestone_id
if
params
[
:milestone_id
]
==
IssuableFinder
::
NONE
||
Milestone
.
find
(
params
[
:milestone_id
]).
try
(
:project
)
!=
project
if
milestone_id
==
IssuableFinder
::
NONE
||
project
.
milestones
.
find_by
(
id:
milestone_id
).
nil?
params
[
:milestone_id
]
=
''
end
end
...
...
@@ -68,9 +69,8 @@ class IssuableBaseService < BaseService
def
filter_labels
return
if
params
[
:label_ids
].
to_a
.
empty?
params
[
:label_ids
].
select!
do
|
label_id
|
Label
.
find
(
label_id
).
try
(
:project
)
==
project
end
params
[
:label_ids
]
=
project
.
labels
.
where
(
id:
params
[
:label_ids
]).
pluck
(
:id
)
end
def
update
(
issuable
)
...
...
spec/services/issues/create_service_spec.rb
View file @
01ab6d70
...
...
@@ -4,13 +4,13 @@ describe Issues::CreateService, services: true do
let
(
:project
)
{
create
(
:empty_project
)
}
let
(
:user
)
{
create
(
:user
)
}
describe
:execute
do
let
(
:issue
)
{
Issues
::
CreateService
.
new
(
project
,
user
,
opts
).
execute
}
describe
'#execute'
do
let
(
:issue
)
{
described_class
.
new
(
project
,
user
,
opts
).
execute
}
context
'
valid params
'
do
context
'
when params are valid
'
do
let
(
:assignee
)
{
create
(
:user
)
}
let
(
:milestone
)
{
create
(
:milestone
,
project:
project
)
}
let
(
:labels
)
{
create_
list
(
:label
,
4
,
project:
project
)
}
let
(
:labels
)
{
create_
pair
(
:label
,
project:
project
)
}
before
do
project
.
team
<<
[
user
,
:master
]
...
...
@@ -45,7 +45,7 @@ describe Issues::CreateService, services: true do
expect
(
Todo
.
where
(
attributes
).
count
).
to
eq
1
end
context
'
label that
belongs to different project'
do
context
'
when label
belongs to different project'
do
let
(
:label
)
{
create
(
:label
)
}
let
(
:opts
)
do
...
...
@@ -59,7 +59,7 @@ describe Issues::CreateService, services: true do
end
end
context
'
milestone that
belongs to different project'
do
context
'
when milestone
belongs to different project'
do
let
(
:milestone
)
{
create
(
:milestone
)
}
let
(
:opts
)
do
...
...
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