Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTomasz Maczukin <tomasz@maczukin.pl>2015-12-31 19:03:11 +0300
committerTomasz Maczukin <tomasz@maczukin.pl>2015-12-31 19:03:11 +0300
commitc5177dd5e2171b047a695802c979cf779522ba8a (patch)
tree2ef3b8c8c301625effe4a7690c8949d1ee2fb95b /lib/api/variables.rb
parent0d014feb1d216e692882976f0d70c3227eaec4ca (diff)
Add missing 'not_found' checks in variables API
Diffstat (limited to 'lib/api/variables.rb')
-rw-r--r--lib/api/variables.rb7
1 files changed, 7 insertions, 0 deletions
diff --git a/lib/api/variables.rb b/lib/api/variables.rb
index c70c7cd9d7b..dac2ba679c7 100644
--- a/lib/api/variables.rb
+++ b/lib/api/variables.rb
@@ -36,6 +36,8 @@ module API
variables.where(key: variable_id)
end
+ return not_found!('Variable') if variables.empty?
+
present variables.first, with: Entities::Variable
end
@@ -51,6 +53,8 @@ module API
put ':id/variables/:variable_id' do
variable = user_project.variables.where(id: params[:variable_id].to_i).first
+ return not_found!('Variable') unless variable
+
variable.key = params[:key]
variable.value = params[:value]
variable.save!
@@ -67,6 +71,9 @@ module API
# DELETE /projects/:id/variables/:variable_id
delete ':id/variables/:variable_id' do
variable = user_project.variables.where(id: params[:variable_id].to_i).first
+
+ return not_found!('Variable') unless variable
+
variable.destroy
end
end