about summary refs log tree commit diff
path: root/spec
diff options
context:
space:
mode:
Diffstat (limited to 'spec')
-rw-r--r--spec/controllers/settings/preferences_controller_spec.rb2
-rw-r--r--spec/models/status_spec.rb12
-rw-r--r--spec/models/user_spec.rb6
3 files changed, 19 insertions, 1 deletions
diff --git a/spec/controllers/settings/preferences_controller_spec.rb b/spec/controllers/settings/preferences_controller_spec.rb
index 432e35cd4..6805a2ce0 100644
--- a/spec/controllers/settings/preferences_controller_spec.rb
+++ b/spec/controllers/settings/preferences_controller_spec.rb
@@ -18,7 +18,7 @@ describe Settings::PreferencesController do
 
   describe 'PUT #update' do
     it 'updates the user record' do
-      put :update, params: { user: { locale: 'en', allowed_languages: ['es', 'fr'] } }
+      put :update, params: { user: { locale: 'en', allowed_languages: ['es', 'fr', ''] } }
 
       expect(response).to redirect_to(settings_preferences_path)
       user.reload
diff --git a/spec/models/status_spec.rb b/spec/models/status_spec.rb
index 0c0b16829..721951030 100644
--- a/spec/models/status_spec.rb
+++ b/spec/models/status_spec.rb
@@ -265,6 +265,18 @@ RSpec.describe Status, type: :model do
           expect(results).not_to include(fr_status)
         end
 
+        it 'includes all languages when user does not have a setting' do
+          user = Fabricate(:user, allowed_languages: [])
+          @account.update(user: user)
+
+          en_status = Fabricate(:status, language: 'en')
+          es_status = Fabricate(:status, language: 'es')
+
+          results = Status.as_public_timeline(@account)
+          expect(results).to include(en_status)
+          expect(results).to include(es_status)
+        end
+
         it 'includes all languages when account does not have a user' do
           expect(@account.user).to be_nil
           en_status = Fabricate(:status, language: 'en')
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