Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Tatuya Kamada
gitlab-ce
Commits
1562f017
Commit
1562f017
authored
Jun 10, 2015
by
Robert Speicher
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Spec the failure cases for PreferencesController#update
parent
fb5271dd
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
6 deletions
+27
-6
app/controllers/profiles/preferences_controller.rb
app/controllers/profiles/preferences_controller.rb
+9
-4
spec/controllers/profiles/preferences_controller_spec.rb
spec/controllers/profiles/preferences_controller_spec.rb
+18
-2
No files found.
app/controllers/profiles/preferences_controller.rb
View file @
1562f017
...
@@ -5,10 +5,15 @@ class Profiles::PreferencesController < Profiles::ApplicationController
...
@@ -5,10 +5,15 @@ class Profiles::PreferencesController < Profiles::ApplicationController
end
end
def
update
def
update
if
@user
.
update_attributes
(
preferences_params
)
begin
flash
[
:notice
]
=
'Preferences saved.'
if
@user
.
update_attributes
(
preferences_params
)
else
flash
[
:notice
]
=
'Preferences saved.'
# TODO (rspeicher): There's no validation on these values, so can it fail?
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
end
respond_to
do
|
format
|
respond_to
do
|
format
|
...
...
spec/controllers/profiles/preferences_controller_spec.rb
View file @
1562f017
...
@@ -51,8 +51,24 @@ describe Profiles::PreferencesController do
...
@@ -51,8 +51,24 @@ describe Profiles::PreferencesController do
end
end
end
end
context
'on unsuccessful update'
do
context
'on failed update'
do
# TODO (rspeicher): Can this happen?
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
end
context
'as js'
do
context
'as js'
do
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment