diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2014-04-02 14:54:41 +0400 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2014-04-02 14:54:41 +0400 |
commit | c4e81ed9de6a5bbfe089e9b61ca0400167e489f3 (patch) | |
tree | d1b73c0f36b4f7117108c9f7cfb2b53b4f3e754f /lib/api/issues.rb | |
parent | cfd9fd30d60c5a880785acda27e9f3d55b17e4ef (diff) |
Move update issue code to separate service
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Diffstat (limited to 'lib/api/issues.rb')
-rw-r--r-- | lib/api/issues.rb | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/lib/api/issues.rb b/lib/api/issues.rb index 169c58b0075..f50be3a815d 100644 --- a/lib/api/issues.rb +++ b/lib/api/issues.rb @@ -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 |