diff options
author | Robert Speicher <rspeicher@gmail.com> | 2015-06-10 18:19:06 -0400 |
---|---|---|
committer | Robert Speicher <rspeicher@gmail.com> | 2015-06-13 17:59:12 -0400 |
commit | 1562f017b6305eeef2ac83e370660699d8789965 (patch) | |
tree | 8a5e5638db6a504195e15e3a951b68183414bf43 /spec/controllers/profiles/preferences_controller_spec.rb | |
parent | fb5271ddf11be8074d5882b86a4b4dfec12150d4 (diff) | |
download | gitlab-ce-1562f017b6305eeef2ac83e370660699d8789965.tar.gz |
Spec the failure cases for PreferencesController#update
Diffstat (limited to 'spec/controllers/profiles/preferences_controller_spec.rb')
-rw-r--r-- | spec/controllers/profiles/preferences_controller_spec.rb | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/spec/controllers/profiles/preferences_controller_spec.rb b/spec/controllers/profiles/preferences_controller_spec.rb index 646aa0320b2..1f0943c93d8 100644 --- a/spec/controllers/profiles/preferences_controller_spec.rb +++ b/spec/controllers/profiles/preferences_controller_spec.rb @@ -51,8 +51,24 @@ describe Profiles::PreferencesController do end end - context 'on unsuccessful update' do - # TODO (rspeicher): Can this happen? + context 'on failed update' do + it 'sets the flash' do + expect(user).to receive(:update_attributes).and_return(false) + + go + + expect(flash[:alert]).to eq('Failed to save preferences.') + end + end + + context 'on invalid dashboard setting' do + it 'sets the flash' do + prefs = {dashboard: 'invalid'} + + go params: prefs + + expect(flash[:alert]).to match(/\AFailed to save preferences \(.+\)\.\z/) + end end context 'as js' do |