From 0de82dd316839ed329504bfbf9bd0f2d3d96e654 Mon Sep 17 00:00:00 2001 From: Akihiko Odaki Date: Sat, 23 Sep 2017 02:33:17 +0900 Subject: Do not filter statuses with unknown languages (#5045) --- app/models/status.rb | 2 +- spec/models/status_spec.rb | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/app/models/status.rb b/app/models/status.rb index 326d128d6..ca261a201 100644 --- a/app/models/status.rb +++ b/app/models/status.rb @@ -146,7 +146,7 @@ class Status < ApplicationRecord class << self def not_in_filtered_languages(account) - where.not(language: account.filtered_languages) + where(language: nil).or where.not(language: account.filtered_languages) end def as_home_timeline(account) diff --git a/spec/models/status_spec.rb b/spec/models/status_spec.rb index 12efcae61..9cb71d715 100644 --- a/spec/models/status_spec.rb +++ b/spec/models/status_spec.rb @@ -173,6 +173,22 @@ RSpec.describe Status, type: :model do end end + describe '.not_in_filtered_languages' do + context 'for accounts with language filters' do + let(:user) { Fabricate(:user, filtered_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 + end + + it 'includes status with unknown language' do + status = Fabricate(:status, language: nil) + expect(Status.not_in_filtered_languages(user.account)).to include status + end + end + end + describe '.as_home_timeline' do let(:account) { Fabricate(:account) } let(:followed) { Fabricate(:account) } -- cgit