diff options
author | Alex Denisov <1101.debian@gmail.com> | 2012-09-16 20:51:04 +0400 |
---|---|---|
committer | Alex Denisov <1101.debian@gmail.com> | 2012-09-16 20:51:04 +0400 |
commit | 549c4c2202307608773a10d8ce9a7dc978537de4 (patch) | |
tree | dfaee2e6f03e4f3c84878f5ae9323bfade7f5bac /lib/api/milestones.rb | |
parent | caef9ed1121a16ca0cc78715695daaa974271bfd (diff) |
API attributes refactored
Diffstat (limited to 'lib/api/milestones.rb')
-rw-r--r-- | lib/api/milestones.rb | 18 |
1 files changed, 4 insertions, 14 deletions
diff --git a/lib/api/milestones.rb b/lib/api/milestones.rb index 4b0424ba444..d5d3347a724 100644 --- a/lib/api/milestones.rb +++ b/lib/api/milestones.rb @@ -36,12 +36,8 @@ module Gitlab # Example Request: # POST /projects/:id/milestones post ":id/milestones" do - @milestone = user_project.milestones.new( - title: params[:title], - description: params[:description], - due_date: params[:due_date] - ) - + attrs = existed_attributes [:title, :description, :due_date] + @milestone = user_project.milestones.new attrs if @milestone.save present @milestone, with: Entities::Milestone else @@ -64,14 +60,8 @@ module Gitlab authorize! :admin_milestone, user_project @milestone = user_project.milestones.find(params[:milestone_id]) - parameters = { - title: (params[:title] || @milestone.title), - description: (params[:description] || @milestone.description), - due_date: (params[:due_date] || @milestone.due_date), - closed: (params[:closed] || @milestone.closed) - } - - if @milestone.update_attributes(parameters) + attrs = existed_attributes [:title, :description, :due_date, :closed] + if @milestone.update_attributes attrs present @milestone, with: Entities::Milestone else not_found! |