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
Jérome Perrin
gitlab-ce
Commits
ef6a4240
Commit
ef6a4240
authored
Jun 15, 2017
by
James Lopez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update notification settings, fix api specs
parent
04bb82c8
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
9 additions
and
6 deletions
+9
-6
app/services/users/update_service.rb
app/services/users/update_service.rb
+1
-1
lib/api/notification_settings.rb
lib/api/notification_settings.rb
+4
-1
lib/api/users.rb
lib/api/users.rb
+3
-1
spec/requests/api/users_spec.rb
spec/requests/api/users_spec.rb
+1
-3
No files found.
app/services/users/update_service.rb
View file @
ef6a4240
...
@@ -10,7 +10,7 @@ module Users
...
@@ -10,7 +10,7 @@ module Users
def
execute
(
skip_authorization:
false
,
&
block
)
def
execute
(
skip_authorization:
false
,
&
block
)
assign_attributes
(
skip_authorization
,
&
block
)
assign_attributes
(
skip_authorization
,
&
block
)
if
@user
.
save
||
!
@user
.
changed?
if
@user
.
save
||
!
@user
.
changed?
&&
@user
.
errors
.
empty?
success
success
else
else
error
(
@user
.
errors
.
full_messages
.
uniq
.
join
(
'. '
))
error
(
@user
.
errors
.
full_messages
.
uniq
.
join
(
'. '
))
...
...
lib/api/notification_settings.rb
View file @
ef6a4240
...
@@ -34,7 +34,10 @@ module API
...
@@ -34,7 +34,10 @@ module API
notification_setting
.
transaction
do
notification_setting
.
transaction
do
new_notification_email
=
params
.
delete
(
:notification_email
)
new_notification_email
=
params
.
delete
(
:notification_email
)
current_user
.
update
(
notification_email:
new_notification_email
)
if
new_notification_email
if
new_notification_email
::
Users
::
UpdateService
.
new
(
current_user
,
current_user
,
notification_email:
new_notification_email
).
execute
end
notification_setting
.
update
(
declared_params
(
include_missing:
false
))
notification_setting
.
update
(
declared_params
(
include_missing:
false
))
end
end
rescue
ArgumentError
=>
e
# catch level enum error
rescue
ArgumentError
=>
e
# catch level enum error
...
...
lib/api/users.rb
View file @
ef6a4240
...
@@ -156,7 +156,9 @@ module API
...
@@ -156,7 +156,9 @@ module API
user_params
[
:password_expires_at
]
=
Time
.
now
if
user_params
[
:password
].
present?
user_params
[
:password_expires_at
]
=
Time
.
now
if
user_params
[
:password
].
present?
if
user
.
update_attributes
(
user_params
.
except
(
:extern_uid
,
:provider
))
result
=
::
Users
::
UpdateService
.
new
(
current_user
,
user
,
user_params
.
except
(
:extern_uid
,
:provider
)).
execute
if
result
[
:status
]
==
:success
present
user
,
with:
Entities
::
UserPublic
present
user
,
with:
Entities
::
UserPublic
else
else
render_validation_error!
(
user
)
render_validation_error!
(
user
)
...
...
spec/requests/api/users_spec.rb
View file @
ef6a4240
...
@@ -374,7 +374,6 @@ describe API::Users do
...
@@ -374,7 +374,6 @@ describe API::Users do
expect
(
response
).
to
have_http_status
(
200
)
expect
(
response
).
to
have_http_status
(
200
)
expect
(
user
.
reload
.
password_expires_at
).
to
be
<=
Time
.
now
expect
(
user
.
reload
.
password_expires_at
).
to
be
<=
Time
.
now
expect
(
AuditEvent
.
count
).
to
eq
(
1
)
end
end
it
"updates user with organization"
do
it
"updates user with organization"
do
...
@@ -406,7 +405,6 @@ describe API::Users do
...
@@ -406,7 +405,6 @@ describe API::Users do
put
api
(
"/users/
#{
user
.
id
}
"
,
admin
),
email:
'new@email.com'
put
api
(
"/users/
#{
user
.
id
}
"
,
admin
),
email:
'new@email.com'
expect
(
response
).
to
have_http_status
(
200
)
expect
(
response
).
to
have_http_status
(
200
)
expect
(
user
.
reload
.
notification_email
).
to
eq
(
'new@email.com'
)
expect
(
user
.
reload
.
notification_email
).
to
eq
(
'new@email.com'
)
expect
(
AuditEvent
.
count
).
to
eq
(
1
)
end
end
it
'updates user with his own username'
do
it
'updates user with his own username'
do
...
@@ -651,7 +649,7 @@ describe API::Users do
...
@@ -651,7 +649,7 @@ describe API::Users do
email_attrs
=
attributes_for
:email
email_attrs
=
attributes_for
:email
expect
do
expect
do
post
api
(
"/users/
#{
user
.
id
}
/emails"
,
admin
),
email_attrs
post
api
(
"/users/
#{
user
.
id
}
/emails"
,
admin
),
email_attrs
end
.
to
change
{
user
.
emails
.
count
}.
by
(
1
)
.
and
change
{
AuditEvent
.
count
}.
by
(
1
)
end
.
to
change
{
user
.
emails
.
count
}.
by
(
1
)
end
end
it
"returns a 400 for invalid ID"
do
it
"returns a 400 for invalid ID"
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