forked from travis-ci/travis-core
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathupdate_user.rb
More file actions
36 lines (29 loc) · 764 Bytes
/
Copy pathupdate_user.rb
File metadata and controls
36 lines (29 loc) · 764 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
module Travis
module Services
class UpdateUser < Base
register :update_user
LOCALES = %w(en es fr ja nb nl pl pt-BR ru de) # TODO how to figure these out
attr_reader :result
def run
@result = current_user.update_attributes!(attributes) if valid_locale?
true
end
def messages
messages = []
if result
messages << { :notice => "Your profile was successfully updated." }
else
messages << { :error => 'Your profile could not be updated.' }
end
messages
end
private
def attributes
params.slice(:locale)
end
def valid_locale?
LOCALES.include?(params[:locale])
end
end
end
end