summaryrefslogtreecommitdiff
path: root/lib/api/group_labels.rb
diff options
context:
space:
mode:
authorRobert Schilling <rschilling@student.tugraz.at>2018-09-08 10:36:45 +0200
committerRobert Schilling <rschilling@student.tugraz.at>2019-01-31 13:49:50 +0100
commit82f09a91dd3abae48b74010f541ea50e0190276a (patch)
tree509c57f9f9611ed7e5c0ade54b31d87409fc5272 /lib/api/group_labels.rb
parentf17d10c451138f801176e2bde3f8bc9ba31823e9 (diff)
downloadgitlab-ce-82f09a91dd3abae48b74010f541ea50e0190276a.tar.gz
Incorporate feedback from Nick
Diffstat (limited to 'lib/api/group_labels.rb')
-rw-r--r--lib/api/group_labels.rb10
1 files changed, 3 insertions, 7 deletions
diff --git a/lib/api/group_labels.rb b/lib/api/group_labels.rb
index 35c5a6deca5..fb2d7fedb90 100644
--- a/lib/api/group_labels.rb
+++ b/lib/api/group_labels.rb
@@ -40,7 +40,7 @@ module API
label = ::Labels::CreateService.new(declared_params(include_missing: false)).execute(group: user_group)
- if label.valid?
+ if label.persisted?
present label, with: Entities::Label, current_user: current_user, parent: user_group
else
render_validation_error!(label)
@@ -80,12 +80,8 @@ module API
label = user_group.labels.find_by(title: params[:name])
not_found!('Label not found') unless label
- label_params = declared_params(include_missing: false)
- # Rename new name to the actual label attribute name
- label_params[:name] = label_params.delete(:new_name) if label_params.key?(:new_name)
-
- label = ::Labels::UpdateService.new(label_params).execute(label)
- render_validation_error!(label) unless label.valid?
+ label = ::Labels::UpdateService.new(declared_params(include_missing: false)).execute(label)
+ render_validation_error!(label) if label.changed?
present label, with: Entities::Label, current_user: current_user, parent: user_group
end