about summary refs log tree commit diff
path: root/spec/models/user_spec.rb
diff options
context:
space:
mode:
authorMatt Jankowski <mjankowski@thoughtbot.com>2017-05-07 21:32:52 -0400
committerEugen Rochko <eugen@zeonfederated.com>2017-05-08 03:32:52 +0200
commitbba537a7bebe11be4b1e4a7e126a34cd27b73678 (patch)
tree940ae93f632bfa1cd99d525d0fde9bb3523fe5c7 /spec/models/user_spec.rb
parent0291b73de7e2fca7f5c137de4427800c02d7a233 (diff)
Improve allowed language handling (#2897)
* Dont allow empty value in user allowed languages

* Sanitize language input to reject blank values in array
Diffstat (limited to 'spec/models/user_spec.rb')
-rw-r--r--spec/models/user_spec.rb6
1 files changed, 6 insertions, 0 deletions
diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb
index fffd92e3d..04c39de3b 100644
--- a/spec/models/user_spec.rb
+++ b/spec/models/user_spec.rb
@@ -22,6 +22,12 @@ RSpec.describe User, type: :model do
       user.valid?
       expect(user).to model_have_error_on_field(:email)
     end
+
+    it 'cleans out empty string from languages' do
+      user = Fabricate.build(:user, allowed_languages: [''])
+      user.valid?
+      expect(user.allowed_languages).to eq []
+    end
   end
 
   describe 'settings' do