summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorRobert Speicher <rspeicher@gmail.com>2015-06-10 18:19:06 -0400
committerRobert Speicher <rspeicher@gmail.com>2015-06-13 17:59:12 -0400
commit1562f017b6305eeef2ac83e370660699d8789965 (patch)
tree8a5e5638db6a504195e15e3a951b68183414bf43 /app
parentfb5271ddf11be8074d5882b86a4b4dfec12150d4 (diff)
downloadgitlab-ce-1562f017b6305eeef2ac83e370660699d8789965.tar.gz
Spec the failure cases for PreferencesController#update
Diffstat (limited to 'app')
-rw-r--r--app/controllers/profiles/preferences_controller.rb13
1 files changed, 9 insertions, 4 deletions
diff --git a/app/controllers/profiles/preferences_controller.rb b/app/controllers/profiles/preferences_controller.rb
index e43a247f725..538b09ca54d 100644
--- a/app/controllers/profiles/preferences_controller.rb
+++ b/app/controllers/profiles/preferences_controller.rb
@@ -5,10 +5,15 @@ class Profiles::PreferencesController < Profiles::ApplicationController
end
def update
- if @user.update_attributes(preferences_params)
- flash[:notice] = 'Preferences saved.'
- else
- # TODO (rspeicher): There's no validation on these values, so can it fail?
+ begin
+ if @user.update_attributes(preferences_params)
+ flash[:notice] = 'Preferences saved.'
+ else
+ flash[:alert] = 'Failed to save preferences.'
+ end
+ rescue ArgumentError => e
+ # Raised when `dashboard` is given an invalid value.
+ flash[:alert] = "Failed to save preferences (#{e.message})."
end
respond_to do |format|