From f08f880f584271a922a0d8d3759e634d67947d12 Mon Sep 17 00:00:00 2001 From: ThibG Date: Wed, 25 Mar 2020 22:40:58 +0100 Subject: Fix media not being marked sensitive when client sets a CW but no text (#13277) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Mastodon enforces the “sensitive” flag on media attachments whenever a toot is posted with a Content Warning. However, it does so *after* potentially converting the Content Warning to toot text (when there is no toot text), which leads to inconsistent and surprising behavior for API clients. This commit fixes this inconsistency. --- spec/services/post_status_service_spec.rb | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'spec/services') diff --git a/spec/services/post_status_service_spec.rb b/spec/services/post_status_service_spec.rb index 025a3da40..147a59fc3 100644 --- a/spec/services/post_status_service_spec.rb +++ b/spec/services/post_status_service_spec.rb @@ -79,6 +79,13 @@ RSpec.describe PostStatusService, type: :service do expect(status.spoiler_text).to eq spoiler_text end + it 'creates a sensitive status when there is a CW but no text' do + status = subject.call(Fabricate(:account), text: '', spoiler_text: 'foo') + + expect(status).to be_persisted + expect(status).to be_sensitive + end + it 'creates a status with empty default spoiler text' do status = create_status_with_options(spoiler_text: nil) -- cgit