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
67cec150
Commit
67cec150
authored
Jan 27, 2017
by
Richard Macklin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add controller spec for Profiles::NotificationsController
parent
e2741630
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
46 additions
and
0 deletions
+46
-0
spec/controllers/profiles/notifications_controller_spec.rb
spec/controllers/profiles/notifications_controller_spec.rb
+46
-0
No files found.
spec/controllers/profiles/notifications_controller_spec.rb
0 → 100644
View file @
67cec150
require
'spec_helper'
describe
Profiles
::
NotificationsController
do
describe
'GET show'
do
it
'renders'
do
user
=
create_user
sign_in
(
user
)
get
:show
expect
(
response
).
to
render_template
:show
end
end
describe
'POST update'
do
it
'updates only permitted attributes'
do
user
=
create_user
sign_in
(
user
)
put
:update
,
user:
{
notification_email:
'new@example.com'
,
admin:
true
}
user
.
reload
expect
(
user
.
notification_email
).
to
eq
(
'new@example.com'
)
expect
(
user
.
admin
).
to
eq
(
false
)
expect
(
controller
).
to
set_flash
[
:notice
].
to
(
'Notification settings saved'
)
end
it
'shows an error message if the params are invalid'
do
user
=
create_user
sign_in
(
user
)
put
:update
,
user:
{
notification_email:
''
}
expect
(
user
.
reload
.
notification_email
).
to
eq
(
'original@example.com'
)
expect
(
controller
).
to
set_flash
[
:alert
].
to
(
'Failed to save new settings'
)
end
end
def
create_user
create
(
:user
)
do
|
user
|
user
.
emails
.
create
(
email:
'original@example.com'
)
user
.
emails
.
create
(
email:
'new@example.com'
)
user
.
update
(
notification_email:
'original@example.com'
)
user
.
save!
end
end
end
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