From 50487db1224851a49ee523bbc013d5f8686a7a55 Mon Sep 17 00:00:00 2001 From: Claire Date: Thu, 25 Aug 2022 04:27:47 +0200 Subject: Add ability to filter individual posts (#18945) * Add database table for status-specific filters * Add REST endpoints, entities and attributes * Show status filters in /filters interface * Perform server-side filtering for individual posts filters * Fix filtering on context mismatch * Refactor `toServerSideType` by moving it to its own module * Move loupe and delete icons to their own module * Add ability to filter individual posts from WebUI * Replace keyword list by warnings (expired, context mismatch) * Refactor server-side filtering code * Add tests --- .../controllers/api/v1/statuses_controller_spec.rb | 27 ++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'spec/controllers/api/v1/statuses_controller_spec.rb') diff --git a/spec/controllers/api/v1/statuses_controller_spec.rb b/spec/controllers/api/v1/statuses_controller_spec.rb index 4d104a198..24810a5d2 100644 --- a/spec/controllers/api/v1/statuses_controller_spec.rb +++ b/spec/controllers/api/v1/statuses_controller_spec.rb @@ -47,6 +47,33 @@ RSpec.describe Api::V1::StatusesController, type: :controller do end end + context 'when post is explicitly filtered' do + let(:status) { Fabricate(:status, text: 'hello world') } + + before do + filter = user.account.custom_filters.create!(phrase: 'filter1', context: %w(home), action: :hide) + filter.statuses.create!(status_id: status.id) + end + + it 'returns http success' do + get :show, params: { id: status.id } + expect(response).to have_http_status(200) + end + + it 'returns filter information' do + get :show, params: { id: status.id } + json = body_as_json + expect(json[:filtered][0]).to include({ + filter: a_hash_including({ + id: user.account.custom_filters.first.id.to_s, + title: 'filter1', + filter_action: 'hide', + }), + status_matches: [status.id.to_s], + }) + end + end + context 'when reblog includes filtered terms' do let(:status) { Fabricate(:status, reblog: Fabricate(:status, text: 'this toot is about that banned word')) } -- cgit