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
Jérome Perrin
gitlab-ce
Commits
c4e81ed9
Commit
c4e81ed9
authored
Apr 02, 2014
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move update issue code to separate service
Signed-off-by:
Dmitriy Zaporozhets
<
dmitriy.zaporozhets@gmail.com
>
parent
cfd9fd30
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
74 additions
and
28 deletions
+74
-28
app/controllers/projects/issues_controller.rb
app/controllers/projects/issues_controller.rb
+1
-2
app/observers/issue_observer.rb
app/observers/issue_observer.rb
+0
-10
app/services/issues/base_service.rb
app/services/issues/base_service.rb
+19
-0
app/services/issues/create_service.rb
app/services/issues/create_service.rb
+0
-6
app/services/issues/update_service.rb
app/services/issues/update_service.rb
+19
-0
lib/api/issues.rb
lib/api/issues.rb
+10
-10
spec/services/issues/create_service_spec.rb
spec/services/issues/create_service_spec.rb
+1
-0
spec/services/issues/update_service_spec.rb
spec/services/issues/update_service_spec.rb
+24
-0
No files found.
app/controllers/projects/issues_controller.rb
View file @
c4e81ed9
...
...
@@ -74,8 +74,7 @@ class Projects::IssuesController < Projects::ApplicationController
end
def
update
@issue
.
update_attributes
(
params
[
:issue
])
@issue
.
reset_events_cache
@issue
=
Issues
::
UpdateService
.
new
(
project
,
current_user
,
params
[
:issue
]).
execute
(
issue
)
respond_to
do
|
format
|
format
.
js
...
...
app/observers/issue_observer.rb
View file @
c4e81ed9
...
...
@@ -12,16 +12,6 @@ class IssueObserver < BaseObserver
execute_hooks
(
issue
)
end
def
after_update
(
issue
)
if
issue
.
is_being_reassigned?
notification
.
reassigned_issue
(
issue
,
current_user
)
create_assignee_note
(
issue
)
end
issue
.
notice_added_references
(
issue
.
project
,
current_user
)
execute_hooks
(
issue
)
end
protected
# Create issue note with service comment like 'Status changed to closed'
...
...
app/services/issues/base_service.rb
0 → 100644
View file @
c4e81ed9
module
Issues
class
BaseService
<
::
BaseService
private
# Create issue note with service comment like 'Status changed to closed'
def
create_note
(
issue
)
Note
.
create_status_change_note
(
issue
,
issue
.
project
,
current_user
,
issue
.
state
,
current_commit
)
end
def
create_assignee_note
(
issue
)
Note
.
create_assignee_change_note
(
issue
,
issue
.
project
,
current_user
,
issue
.
assignee
)
end
def
execute_hooks
(
issue
)
issue
.
project
.
execute_hooks
(
issue
.
to_hook_data
,
:issue_hooks
)
end
end
end
app/services/issues/create_service.rb
View file @
c4e81ed9
...
...
@@ -13,11 +13,5 @@ module Issues
issue
end
private
def
execute_hooks
(
issue
)
issue
.
project
.
execute_hooks
(
issue
.
to_hook_data
,
:issue_hooks
)
end
end
end
app/services/issues/update_service.rb
0 → 100644
View file @
c4e81ed9
module
Issues
class
UpdateService
<
BaseService
def
execute
(
issue
)
if
issue
.
update_attributes
(
params
)
issue
.
reset_events_cache
if
issue
.
is_being_reassigned?
notification
.
reassigned_issue
(
issue
,
current_user
)
create_assignee_note
(
issue
)
end
issue
.
notice_added_references
(
issue
.
project
,
current_user
)
execute_hooks
(
issue
)
end
issue
end
end
end
lib/api/issues.rb
View file @
c4e81ed9
...
...
@@ -74,18 +74,18 @@ module API
# Example Request:
# PUT /projects/:id/issues/:issue_id
put
":id/issues/:issue_id"
do
set_current_user_for_thread
do
@issue
=
user_project
.
issues
.
find
(
params
[
:issue_id
])
authorize!
:modify_issue
,
@issue
issue
=
user_project
.
issues
.
find
(
params
[
:issue_id
])
authorize!
:modify_issue
,
issue
attrs
=
attributes_for_keys
[
:title
,
:description
,
:assignee_id
,
:milestone_id
,
:state_event
]
attrs
[
:label_list
]
=
params
[
:labels
]
if
params
[
:labels
].
present?
attrs
=
attributes_for_keys
[
:title
,
:description
,
:assignee_id
,
:milestone_id
,
:state_event
]
attrs
[
:label_list
]
=
params
[
:labels
]
if
params
[
:labels
].
present?
issue
=
::
Issues
::
UpdateService
.
new
(
user_project
,
current_user
,
attrs
).
execute
(
issue
)
if
@issue
.
update_attributes
attrs
present
@issue
,
with:
Entities
::
Issue
else
not_found!
end
if
issue
.
valid?
present
issue
,
with:
Entities
::
Issue
else
not_found!
end
end
...
...
spec/services/issues/create_service_spec.rb
View file @
c4e81ed9
...
...
@@ -17,6 +17,7 @@ describe Issues::CreateService do
end
it
{
@issue
.
should
be_valid
}
it
{
@issue
.
title
.
should
==
'Awesome issue'
}
end
end
end
spec/services/issues/update_service_spec.rb
0 → 100644
View file @
c4e81ed9
require
'spec_helper'
describe
Issues
::
UpdateService
do
let
(
:project
)
{
create
(
:empty_project
)
}
let
(
:user
)
{
create
(
:user
)
}
let
(
:issue
)
{
create
(
:issue
)
}
describe
:execute
do
context
"valid params"
do
before
do
project
.
team
<<
[
user
,
:master
]
opts
=
{
title:
'New title'
,
description:
'Also please fix'
}
@issue
=
Issues
::
UpdateService
.
new
(
project
,
user
,
opts
).
execute
(
issue
)
end
it
{
@issue
.
should
be_valid
}
it
{
@issue
.
title
.
should
==
'New title'
}
end
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