Commit faa95ba4 authored by James Lopez's avatar James Lopez

fix users update service

parent 7188975c
...@@ -11,10 +11,12 @@ module Users ...@@ -11,10 +11,12 @@ module Users
def execute(validate: true, &block) def execute(validate: true, &block)
yield(@user) if block_given? yield(@user) if block_given?
user_exists = @user.persisted?
assign_attributes(&block) assign_attributes(&block)
if @user.save(validate: validate) if @user.save(validate: validate)
notify_success notify_success(user_exists)
else else
error(@user.errors.full_messages.uniq.join('. ')) error(@user.errors.full_messages.uniq.join('. '))
end end
...@@ -30,8 +32,8 @@ module Users ...@@ -30,8 +32,8 @@ module Users
private private
def notify_success def notify_success(user_exists)
notify_new_user(@user, nil) unless @user.persisted? notify_new_user(@user, nil) unless user_exists
success success
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment