about summary refs log tree commit diff
path: root/app/lib
diff options
context:
space:
mode:
authorLevi Bard <taktaktaktaktaktaktaktaktaktak@gmail.com>2018-04-08 13:43:10 +0200
committerEugen Rochko <eugen@zeonfederated.com>2018-04-08 13:43:10 +0200
commitcd0eaa349ca5d7e53e2ed246e70e99fc61c98370 (patch)
tree1d1f099ad6bcb3be4bd6b11343e4d915b623a286 /app/lib
parent1364e9e4ae1fb12a1c970795f1d0afd651c7cfe2 (diff)
Enable updating additional account information from user preferences via rest api (#6789)
* Enable updating additional account information from user preferences via rest api
Resolves #6553

* Pacify rubocop

* Decoerce incoming settings in UserSettingsDecorator

* Create user preferences hash directly from incoming credentials instead of going through ActionController::Parameters

* Clean up user preferences update

* Use ActiveModel::Type::Boolean instead of manually checking stringified number equivalence
Diffstat (limited to 'app/lib')
-rw-r--r--app/lib/user_settings_decorator.rb4
1 files changed, 2 insertions, 2 deletions
diff --git a/app/lib/user_settings_decorator.rb b/app/lib/user_settings_decorator.rb
index 4d6f19467..9260a81bc 100644
--- a/app/lib/user_settings_decorator.rb
+++ b/app/lib/user_settings_decorator.rb
@@ -83,7 +83,7 @@ class UserSettingsDecorator
   end
 
   def boolean_cast_setting(key)
-    settings[key] == '1'
+    ActiveModel::Type::Boolean.new.cast(settings[key])
   end
 
   def coerced_settings(key)
@@ -91,7 +91,7 @@ class UserSettingsDecorator
   end
 
   def coerce_values(params_hash)
-    params_hash.transform_values { |x| x == '1' }
+    params_hash.transform_values { |x| ActiveModel::Type::Boolean.new.cast(x) }
   end
 
   def change?(key)