Change language opt-out to language opt-in (#7823)

* Switch filtered_languages to chosen_languages

* Adjust interface

* Remove unused translations
signup-info-prompt
Eugen Rochko 2018-06-17 13:54:02 +02:00 committed by GitHub
parent 31e5d7efd7
commit 7eec279c7f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
41 changed files with 32 additions and 113 deletions

View File

@ -27,7 +27,7 @@ class Settings::PreferencesController < ApplicationController
def user_params
params.require(:user).permit(
:locale,
filtered_languages: []
chosen_languages: []
)
end

View File

@ -141,7 +141,7 @@ class Account < ApplicationRecord
prefix: true,
allow_nil: true
delegate :filtered_languages, to: :user, prefix: false, allow_nil: true
delegate :chosen_languages, to: :user, prefix: false, allow_nil: true
def local?
domain.nil?

View File

@ -190,8 +190,8 @@ class Status < ApplicationRecord
before_validation :set_local
class << self
def not_in_filtered_languages(account)
where(language: nil).or where.not(language: account.filtered_languages)
def in_chosen_languages(account)
where(language: nil).or where(language: account.chosen_languages)
end
def as_home_timeline(account)
@ -333,7 +333,7 @@ class Status < ApplicationRecord
def filter_timeline_for_account(query, account, local_only)
query = query.not_excluded_by_account(account)
query = query.not_domain_blocked_by_account(account) unless local_only
query = query.not_in_filtered_languages(account) if account.filtered_languages.present?
query = query.in_chosen_languages(account) if account.chosen_languages.present?
query.merge(account_silencing_filter(account))
end

View File

@ -35,6 +35,7 @@
# moderator :boolean default(FALSE), not null
# invite_id :bigint(8)
# remember_token :string
# chosen_languages :string is an Array
#
class User < ApplicationRecord
@ -317,7 +318,9 @@ class User < ApplicationRecord
private
def sanitize_languages
filtered_languages.reject!(&:blank?)
return if chosen_languages.nil?
chosen_languages.reject!(&:blank?)
self.chosen_languages = nil if chosen_languages.empty?
end
def prepare_new_user!

View File

@ -12,7 +12,7 @@
.fields-group
= f.input :locale, collection: I18n.available_locales, wrapper: :with_label, include_blank: false, label_method: lambda { |locale| human_locale(locale) }, selected: I18n.locale
= f.input :filtered_languages, collection: filterable_languages, wrapper: :with_block_label, include_blank: false, label_method: lambda { |locale| human_locale(locale) }, required: false, as: :check_boxes, collection_wrapper_tag: 'ul', item_wrapper_tag: 'li'
= f.input :chosen_languages, collection: filterable_languages.sort, wrapper: :with_block_label, include_blank: false, label_method: lambda { |locale| human_locale(locale) }, required: false, as: :check_boxes, collection_wrapper_tag: 'ul', item_wrapper_tag: 'li'
%h4= t 'preferences.publishing'

View File

@ -23,8 +23,6 @@ ar:
data: ملف CSV تم تصديره مِن مثيل خادوم ماستدون آخر
sessions:
otp: 'قم بإدخال رمز المصادقة بخطوتين الذي قام بتوليده تطبيق جهازك أو إستخدم أحد رموز النفاذ الإحتياطية :'
user:
filtered_languages: سوف يتم تصفية و إخفاء اللغات المختارة من خيوطك العمومية
labels:
account:
fields:
@ -42,7 +40,6 @@ ar:
email: عنوان البريد الإلكتروني
expires_in: تنتهي مدة صلاحيته بعد
fields: واصفات بيانات الملف الشخصي
filtered_languages: اللغات التي تم تصفيتها
header: الرأسية
locale: اللغة
locked: تجميد الحساب

View File

@ -23,8 +23,6 @@ ca:
data: Fitxer CSV exportat des de una altra instància de Mastodon
sessions:
otp: 'Introdueix el codi de dos factors generat per el teu telèfon o utilitza un dels teus codis de recuperació:'
user:
filtered_languages: Les llengües seleccionades s'eliminaran de les línies de temps públiques
labels:
account:
fields:
@ -42,7 +40,6 @@ ca:
email: Adreça de correu electrònic
expires_in: Expira després
fields: Metadades del perfil
filtered_languages: Llengües filtrades
header: Capçalera
locale: Llengua
locked: Fes aquest compte privat

View File

@ -22,8 +22,6 @@ co:
data: Un fugliale CSV da unaltristanza di Mastodon
sessions:
otp: 'Entrate u codice didentificazione à dui fattori nantà u vostru telefuninu, o unu di i vostri codici di ricuperazione:'
user:
filtered_languages: Ùn viderete micca e lingue selezziunate nantà e linee pubbliche
labels:
account:
fields:
@ -40,7 +38,6 @@ co:
email: Indirizzu e-mail
expires_in: Spira dopu à
fields: Metadata di u prufile
filtered_languages: Lingue filtrate
header: Ritrattu di cuprendula
locale: Lingua
locked: Privatizà u contu

View File

@ -22,8 +22,6 @@ de:
data: CSV-Datei, die aus einer anderen Mastodon-Instanz exportiert wurde
sessions:
otp: 'Gib den Zwei-Faktor-Authentisierungscode von deinem Telefon ein oder benutze einen deiner Wiederherstellungscodes:'
user:
filtered_languages: Ausgewählte Sprachen werden aus deinen öffentlichen Zeitleisten gefiltert
labels:
account:
fields:
@ -40,7 +38,6 @@ de:
email: E-Mail-Adresse
expires_in: Gültig bis
fields: Profil-Metadaten
filtered_languages: Gefilterte Sprachen
header: Kopfbild
locale: Sprache
locked: Gesperrtes Profil

View File

@ -24,7 +24,7 @@ en:
sessions:
otp: 'Enter the two-factor code generated by your phone app or use one of your recovery codes:'
user:
filtered_languages: Checked languages will be filtered from public timelines for you
chosen_languages: Only toots in selected languages will be displayed in public timelines. Select nothing to see toots in all languages
labels:
account:
fields:
@ -34,6 +34,7 @@ en:
autofollow: Invite to follow your account
avatar: Avatar
bot: This is a bot account
chosen_languages: Filter languages
confirm_new_password: Confirm new password
confirm_password: Confirm password
current_password: Current password
@ -42,9 +43,8 @@ en:
email: E-mail address
expires_in: Expire after
fields: Profile metadata
filtered_languages: Filtered languages
header: Header
locale: Language
locale: Interface language
locked: Lock account
max_uses: Max number of uses
new_password: New password

View File

@ -22,8 +22,6 @@ eo:
data: CSV-dosiero el alia nodo de Mastodon
sessions:
otp: 'Enmetu la kodon de dufaktora aŭtentigo el via telefono aŭ uzu unu el viaj realiraj kodoj:'
user:
filtered_languages: Markitaj lingvoj estos elfiltritaj de publikaj tempolinioj por vi
labels:
account:
fields:
@ -40,7 +38,6 @@ eo:
email: Retadreso
expires_in: Eksvalidiĝas post
fields: Profilaj metadatumoj
filtered_languages: Filtritaj lingvoj
header: Fonbildo
locale: Lingvo
locked: Ŝlosi konton

View File

@ -19,8 +19,6 @@ es:
data: Archivo CSV exportado desde otra instancia de Mastodon
sessions:
otp: Introduce el código de autenticación de dos factores de tu teléfono o usa uno de tus códigos de recuperación.
user:
filtered_languages: Los idiomas seleccionados dejarán de mostrarse para ti en las líneas de tiempo públicas
labels:
defaults:
avatar: Avatar
@ -31,7 +29,6 @@ es:
display_name: Nombre para mostrar
email: Dirección de correo electrónico
expires_in: Expirar tras
filtered_languages: Idiomas filtrados
header: Img. cabecera
locale: Idioma
locked: Hacer privada esta cuenta

View File

@ -22,8 +22,6 @@ eu:
data: Beste Mastodon instantzia batetik esportatutako CSV fitxategia
sessions:
otp: 'Sartu zure telefonoko aplikazioak sortutako bi faktoreetako kodea, edo erabili zure berreskuratze kodeetako bat:'
user:
filtered_languages: Ez dira aukeratutako hizkuntzak erakutsiko zure denbora-lerro publikoetan
labels:
account:
fields:
@ -40,7 +38,6 @@ eu:
email: E-mail helbidea
expires_in: Iraungitzea
fields: Profilaren metadatuak
filtered_languages: Iragazitako hizkuntzak
header: Goiburua
locale: Hizkuntza
locked: Giltzapetu kontua

View File

@ -23,8 +23,6 @@ fa:
data: پروندهٔ CSV که از سرور ماستدون دیگری برون‌سپاری شده
sessions:
otp: 'کد تأیید دومرحله‌ای که اپ روی تلفن شما ساخته را وارد کنید یا یکی از کدهای بازیابی را به کار ببرید:'
user:
filtered_languages: زبان‌های انتخاب‌شده از فهرست عمومی نوشته‌هایی که می‌بینید حذف می‌شوند
labels:
account:
fields:
@ -42,7 +40,6 @@ fa:
email: نشانی ایمیل
expires_in: تاریخ انقضا
fields: اطلاعات تکمیلی نمایه
filtered_languages: زبان‌های فیلترشده
header: تصویر زمینه
locale: زبان
locked: خصوصی‌کردن حساب

View File

@ -20,8 +20,6 @@ fi:
data: Toisesta Mastodon-instanssista tuotu CSV-tiedosto
sessions:
otp: Syötä puhelimeen saamasi kaksivaiheisen tunnistautumisen koodi tai käytä palautuskoodia.
user:
filtered_languages: Valitut kielet suodatetaan pois julkisilta aikajanoilta
labels:
account:
fields:
@ -36,7 +34,6 @@ fi:
email: Sähköpostiosoite
expires_in: Vanhenee
fields: Profiilin metadata
filtered_languages: Suodatetut kielet
header: Otsakekuva
locale: Kieli
locked: Lukitse tili

View File

@ -22,8 +22,6 @@ fr:
data: Un fichier CSV généré par une autre instance de Mastodon
sessions:
otp: 'Entrez le code dauthentification à deux facteurs généré par votre téléphone ou utilisez un de vos codes de récupération :'
user:
filtered_languages: Les langues sélectionnées seront filtrées hors de vos fils publics pour vous
labels:
account:
fields:
@ -40,7 +38,6 @@ fr:
email: Adresse courriel
expires_in: Expire après
fields: Métadonnées du profil
filtered_languages: Langues filtrées
header: Image den-tête
locale: Langue
locked: Verrouiller le compte

View File

@ -22,8 +22,6 @@ gl:
data: Ficheiro CSV exportado desde outra instancia Mastodon
sessions:
otp: Introduza o código de doble-factor xerado no aplicativo do seu móbil ou utilice un dos seus códigos de recuperación.
user:
filtered_languages: Os idiomas marcados filtraranse das liñas temporais públicas para vostede
labels:
account:
fields:
@ -40,7 +38,6 @@ gl:
email: enderezo correo electrónico
expires_in: Caducidade despois de
fields: Metadatos do perfil
filtered_languages: Idiomas filtrados
header: Cabeceira
locale: Idioma
locked: Protexer conta

View File

@ -19,8 +19,6 @@ he:
data: קובץ CSV שיוצא משרת מסטודון אחר
sessions:
otp: נא להקליד קוד אימות דו-שלבי ממכשירך או קוד אחזור גישה.
user:
filtered_languages: שפות שנבחרו יוסתרו מציר הזמן הציבורי בשבילך
labels:
defaults:
avatar: תמונת פרופיל
@ -31,7 +29,6 @@ he:
display_name: שם להצגה
email: כתובת דוא"ל
expires_in: תפוגה לאחר
filtered_languages: שפות מסוננות
header: ראשה
locale: שפה
locked: הפוך חשבון לפרטי

View File

@ -19,8 +19,6 @@ hu:
data: Egy másik Mastodon szerverről exportált CSV fájl
sessions:
otp: Add meg a Második-faktor kódodat a telefonodról vagy használd az egyik tartalék bejelentkező kódodat.
user:
filtered_languages: A kiválasztott nyelvek nem jelennek majd meg a nyilvános idővonaladon
labels:
defaults:
avatar: Profilkép
@ -31,7 +29,6 @@ hu:
display_name: Megjelenített név
email: E-mail cím
expires_in: Elévül
filtered_languages: Szűrt nyelvek
header: Fejléc
locale: Nyelv
locked: Zárt felhasználói fiók

View File

@ -22,8 +22,6 @@ it:
data: File CSV esportato da un'altra istanza di Mastodon
sessions:
otp: 'Inserisci il codice a due fattori generato dall''app del tuo telefono o usa uno dei codici di recupero:'
user:
filtered_languages: Le lingue selezionate verranno filtrate dalla tua timeline pubblica
labels:
account:
fields:
@ -40,7 +38,6 @@ it:
email: Indirizzo email
expires_in: Scade dopo
fields: Metadati del profilo
filtered_languages: Lingue filtrate
header: Header
locale: Lingua
locked: Blocca account

View File

@ -19,8 +19,6 @@ ja:
data: 他の Mastodon インスタンスからエクスポートしたCSVファイルを選択して下さい
sessions:
otp: '携帯電話のアプリで生成された二段階認証コードを入力するか、リカバリーコードを使用してください:'
user:
filtered_languages: 選択した言語があなたの公開タイムラインから取り除かれます
labels:
account:
fields:
@ -38,7 +36,6 @@ ja:
email: メールアドレス
expires_in: 有効期限
fields: プロフィール補足情報
filtered_languages: 除外する言語
header: ヘッダー
locale: 言語
locked: 承認制アカウントにする

View File

@ -23,8 +23,6 @@ ko:
data: 다른 마스토돈 인스턴스에서 추출된 CSV 파일
sessions:
otp: '휴대전화에서 생성 된 2단계 인증 코드를 입력하거나, 복구 코드 중 하나를 사용하세요:'
user:
filtered_languages: 선택된 언어가 공개 타임라인에서 제외 될 것입니다
labels:
account:
fields:
@ -42,7 +40,6 @@ ko:
email: 이메일 주소
expires_in: 만료시각
fields: 프로필 메타데이터
filtered_languages: 숨긴 언어들
header: 헤더
locale: 언어
locked: 계정 잠금

View File

@ -23,8 +23,6 @@ nl:
data: CSV-bestand dat op een andere Mastodonserver werd geëxporteerd
sessions:
otp: Voer de tweestaps-aanmeldcode vanaf jouw mobiele telefoon in of gebruik een van jouw herstelcodes.
user:
filtered_languages: Geselecteerde talen worden uit de lokale en globale tijdlijn verwijderd
labels:
account:
fields:
@ -42,7 +40,6 @@ nl:
email: E-mailadres
expires_in: Vervalt na
fields: Metadata profiel
filtered_languages: Gefilterde talen
header: Omslagfoto
locale: Taal
locked: Maak account besloten

View File

@ -19,8 +19,6 @@
data: CSV-fil eksportert fra en annen Mastodon-instans
sessions:
otp: Angi tofaktorkoden fra din telefon eller bruk en av dine gjenopprettingskoder.
user:
filtered_languages: Språk som er avhuket vil ikke vises på offentlige tidslinjer fra deg
labels:
defaults:
avatar: Avatar
@ -31,7 +29,6 @@
display_name: Visningsnavn
email: E-postadresse
expires_in: Utløper etter
filtered_languages: Filtrerte språk
header: Overskrift
locale: Språk
locked: Lås konto

View File

@ -23,8 +23,6 @@ oc:
data: Fichièr CSV exportat duna autra instància Mastodon
sessions:
otp: 'Picatz lo còdi dautentificacion en dos temps (Two factor code) de vòstra aplicacion mobil o utilizatz un de vòstres còdis de recuperacion :'
user:
filtered_languages: Las lengas seleccionadas seràn levadas de vòstre flux dactualitat
labels:
account:
fields:
@ -42,7 +40,6 @@ oc:
email: Corrièl
expires_in: Expira aprèp
fields: Metadonada del perfil
filtered_languages: Lengas filtradas
header: Bandièra
locale: Lenga
locked: Far venir lo compte privat

View File

@ -26,8 +26,6 @@ pl:
data: Plik CSV wyeksportowany z innej instancji Mastodona
sessions:
otp: 'Wprowadź kod weryfikacji dwuetapowej z telefonu lub wykorzystaj jeden z kodów zapasowych:'
user:
filtered_languages: Wpisy w wybranych językach nie będą wyświetlać się na publicznych osiach czasu
labels:
account:
fields:
@ -44,7 +42,6 @@ pl:
email: Adres e-mail
expires_in: Wygaśnie po
fields: Metadane profilu
filtered_languages: Filtrowane języki
header: Nagłówek
locale: Język
locked: Ustaw konto jako prywatne

View File

@ -22,8 +22,6 @@ pt-BR:
data: Arquivo CSV exportado de outra instância do Mastodon
sessions:
otp: 'Insira o código de autenticação gerado pelo app no seu celular ou use um dos códigos de recuperação:'
user:
filtered_languages: Selecione os idiomas que devem ser removidos de suas timelines públicas
labels:
account:
fields:
@ -40,7 +38,6 @@ pt-BR:
email: Endereço de e-mail
expires_in: Expira em
fields: Metadados do perfil
filtered_languages: Idiomas filtrados
header: Cabeçalho
locale: Idioma
locked: Trancar conta

View File

@ -19,8 +19,6 @@ pt:
data: Arquivo CSV exportado de outra instância do Mastodon
sessions:
otp: Inserir o código de autenticação de dois factores do teu telemóvel ou usa um dos códigos de recuperação.
user:
filtered_languages: Seleciona os idiomas que devem ser removidos das tuas timelines públicas
labels:
defaults:
avatar: Imagem de Perfil
@ -31,7 +29,6 @@ pt:
display_name: Nome Público
email: Endereço de e-mail
expires_in: Expira em
filtered_languages: Idiomas filtrados
header: Cabeçalho
locale: Idioma
locked: Trancar conta

View File

@ -26,8 +26,6 @@ ru:
data: Файл CSV, экспортированный с другого узла Mastodon
sessions:
otp: 'Введите код двухфакторной аутентификации, сгенерированный в мобильном приложении, или используйте один из Ваших кодов восстановления:'
user:
filtered_languages: Выбранные языки будут убраны из Ваших публичных лет.
labels:
account:
fields:
@ -44,7 +42,6 @@ ru:
email: Адрес e-mail
expires_in: Срок действия
fields: Метаданные профиля
filtered_languages: Фильтруемые языки
header: Заголовок
locale: Язык
locked: Сделать аккаунт закрытым

View File

@ -25,8 +25,6 @@ sk:
data: CSV súbor vyexportovaný z inej Mastodon inštancie
sessions:
otp: 'Napíš sem dvoj-faktorový kód z telefónu, alebo použi jeden z tvojích obnovovacích kódov:'
user:
filtered_languages: Zaškrtnuté jazyky budú pre teba vynechané z verejnej časovej osi
labels:
account:
fields:
@ -44,7 +42,6 @@ sk:
email: Emailová adresa
expires_in: Expirovať po
fields: Metadáta profilu
filtered_languages: Vynechanie jazykov
header: Obrázok v hlavičke
locale: Jazyk
locked: Zamknúť účet

View File

@ -23,8 +23,6 @@ sr-Latn:
data: CSV fajl izvezen sa druge Mastodont instance
sessions:
otp: Unesite dvofaktorski kod sa Vašeg telefona ili koristite jedan od kodova za oporavak.
user:
filtered_languages: Označeni jezici će za Vas biti isfiltrirani sa javnih lajni
labels:
defaults:
avatar: Avatar
@ -35,7 +33,6 @@ sr-Latn:
display_name: Ime za prikaz
email: Adresa e-pošte
expires_in: Ističe nakon
filtered_languages: Filtrirani jezici
header: Zaglavlje
locale: Jezik
locked: Zaključaj nalog

View File

@ -23,8 +23,6 @@ sr:
data: CSV фајл извезен са друге Мастодонт инстанце
sessions:
otp: Унесите двофакторски код са Вашег телефона или користите један од кодова за опоравак.
user:
filtered_languages: Означени језици ће за Вас бити исфилтрирани са јавних лајни
labels:
defaults:
avatar: Аватар
@ -35,7 +33,6 @@ sr:
display_name: Име за приказ
email: Адреса е-поште
expires_in: Истиче након
filtered_languages: Филтрирани језици
header: Заглавље
locale: Језик
locked: Закључај налог

View File

@ -22,8 +22,6 @@ sv:
data: CSV-fil som exporteras från en annan Mastodon-instans
sessions:
otp: 'Ange tvåfaktorkoden genererad från din telefonapp eller använd någon av dina återställningskoder:'
user:
filtered_languages: Kontrollerade språk filtreras från offentliga tidslinjer för dig
labels:
account:
fields:
@ -40,7 +38,6 @@ sv:
email: E-postadress
expires_in: Förfaller efter
fields: Profil-metadata
filtered_languages: Filtrerade språk
header: Bakgrundsbild
locale: Språk
locked: Lås konto

View File

@ -19,8 +19,6 @@ zh-CN:
data: 请上传从其他 Mastodon 实例导出的 CSV 文件
sessions:
otp: 输入你手机应用上生成的双重认证码,或者任意一个恢复代码:
user:
filtered_languages: 被勾选语言的嘟文将不会出现在你的公共时间轴上
labels:
account:
fields:
@ -38,7 +36,6 @@ zh-CN:
email: 电子邮件地址
expires_in: 失效时间
fields: 个人资料附加信息
filtered_languages: 语言过滤
header: 个人资料页横幅图片
locale: 语言
locked: 保护你的帐户(锁嘟)

View File

@ -22,8 +22,6 @@ zh-HK:
data: 自其他服務站匯出的 CSV 檔案
sessions:
otp: 輸入你手機上生成的雙重認證碼,或者任意一個恢復代碼:
user:
filtered_languages: 下面被選擇的語言的文章將不會出現在你的公共時間軸上
labels:
account:
fields:
@ -40,7 +38,6 @@ zh-HK:
email: 電郵地址
expires_in: 失效時間
fields: 資料
filtered_languages: 封鎖下面語言的文章
header: 個人頁面頂部
locale: 語言
locked: 將用戶轉為「私人」

View File

@ -10,8 +10,6 @@ zh-TW:
note: 最多 160 個字元
imports:
data: 自其他服務站匯出的 CSV 檔案
user:
filtered_languages: 下面被選擇的語言的文章將不會出現在你的公共時間軸上。
labels:
defaults:
avatar: 大頭貼
@ -21,7 +19,6 @@ zh-TW:
data: 資料
display_name: 顯示名稱
email: 電子信箱
filtered_languages: 封鎖下面語言的文章
header: 個人頁面頂部
locale: 語言
locked: 將帳號轉為「私密」

View File

@ -0,0 +1,5 @@
class AddChosenLanguagesToUsers < ActiveRecord::Migration[5.2]
def change
add_column :users, :chosen_languages, :string, array: true, null: true, default: nil
end
end

View File

@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 2018_06_15_122121) do
ActiveRecord::Schema.define(version: 2018_06_16_192031) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@ -525,6 +525,7 @@ ActiveRecord::Schema.define(version: 2018_06_15_122121) do
t.boolean "moderator", default: false, null: false
t.bigint "invite_id"
t.string "remember_token"
t.string "chosen_languages", array: true
t.index ["account_id"], name: "index_users_on_account_id"
t.index ["confirmation_token"], name: "index_users_on_confirmation_token", unique: true
t.index ["email"], name: "index_users_on_email", unique: true

View File

@ -18,12 +18,12 @@ describe Settings::PreferencesController do
describe 'PUT #update' do
it 'updates the user record' do
put :update, params: { user: { locale: 'en', filtered_languages: ['es', 'fr', ''] } }
put :update, params: { user: { locale: 'en', chosen_languages: ['es', 'fr', ''] } }
expect(response).to redirect_to(settings_preferences_path)
user.reload
expect(user.locale).to eq 'en'
expect(user.filtered_languages).to eq ['es', 'fr']
expect(user.chosen_languages).to eq ['es', 'fr']
end
it 'updates user settings' do

View File

@ -259,18 +259,18 @@ RSpec.describe Status, type: :model do
end
end
describe '.not_in_filtered_languages' do
describe '.in_chosen_languages' do
context 'for accounts with language filters' do
let(:user) { Fabricate(:user, filtered_languages: ['en']) }
let(:user) { Fabricate(:user, chosen_languages: ['en']) }
it 'does not include statuses in filtered languages' do
status = Fabricate(:status, language: 'en')
expect(Status.not_in_filtered_languages(user.account)).not_to include status
it 'does not include statuses in not in chosen languages' do
status = Fabricate(:status, language: 'de')
expect(Status.in_chosen_languages(user.account)).not_to include status
end
it 'includes status with unknown language' do
status = Fabricate(:status, language: nil)
expect(Status.not_in_filtered_languages(user.account)).to include status
expect(Status.in_chosen_languages(user.account)).to include status
end
end
end
@ -518,7 +518,7 @@ RSpec.describe Status, type: :model do
context 'with language preferences' do
it 'excludes statuses in languages not allowed by the account user' do
user = Fabricate(:user, filtered_languages: [:fr])
user = Fabricate(:user, chosen_languages: [:en, :es])
@account.update(user: user)
en_status = Fabricate(:status, language: 'en')
es_status = Fabricate(:status, language: 'es')
@ -531,7 +531,7 @@ RSpec.describe Status, type: :model do
end
it 'includes all languages when user does not have a setting' do
user = Fabricate(:user, filtered_languages: [])
user = Fabricate(:user, chosen_languages: nil)
@account.update(user: user)
en_status = Fabricate(:status, language: 'en')

View File

@ -41,9 +41,9 @@ RSpec.describe User, type: :model do
end
it 'cleans out empty string from languages' do
user = Fabricate.build(:user, filtered_languages: [''])
user = Fabricate.build(:user, chosen_languages: [''])
user.valid?
expect(user.filtered_languages).to eq []
expect(user.chosen_languages).to eq nil
end
end