summaryrefslogtreecommitdiffstats
path: root/spec/lib
diff options
context:
space:
mode:
authorThibG <thib@sitedethib.com>2020-08-02 11:21:10 +0200
committerGitHub <noreply@github.com>2020-08-02 11:21:10 +0200
commita1412491b76ca37ca668083d2958fccf750a5fd3 (patch)
tree1689d75b25f994579f2ed4b37ae08fddaf49c8d9 /spec/lib
parent9490011226e69426faefbfca02e5566cef369774 (diff)
Change content-type to be always computed from file data (#14452)
* Change content-type to be always computed from file data Restore previous behavior, detecting the content-type isn't very expensive, and some instances may serve files as application/octet-stream regardless of their true type, making fetching media from them fail, while it used to work pre-3.2.0. * Add test
Diffstat (limited to 'spec/lib')
-rw-r--r--spec/lib/activitypub/activity/create_spec.rb27
1 files changed, 27 insertions, 0 deletions
diff --git a/spec/lib/activitypub/activity/create_spec.rb b/spec/lib/activitypub/activity/create_spec.rb
index 2ac4acc12aa..51e0b8caff9 100644
--- a/spec/lib/activitypub/activity/create_spec.rb
+++ b/spec/lib/activitypub/activity/create_spec.rb
@@ -18,6 +18,7 @@ RSpec.describe ActivityPub::Activity::Create do
stub_request(:get, 'http://example.com/attachment.png').to_return(request_fixture('avatar.txt'))
stub_request(:get, 'http://example.com/emoji.png').to_return(body: attachment_fixture('emojo.png'))
+ stub_request(:get, 'http://example.com/emojib.png').to_return(body: attachment_fixture('emojo.png'), headers: { 'Content-Type' => 'application/octet-stream' })
end
describe '#perform' do
@@ -451,6 +452,32 @@ RSpec.describe ActivityPub::Activity::Create do
end
end
+ context 'with emojis served with invalid content-type' do
+ let(:object_json) do
+ {
+ id: [ActivityPub::TagManager.instance.uri_for(sender), '#bar'].join,
+ type: 'Note',
+ content: 'Lorem ipsum :tinkong:',
+ tag: [
+ {
+ type: 'Emoji',
+ icon: {
+ url: 'http://example.com/emojib.png',
+ },
+ name: 'tinkong',
+ },
+ ],
+ }
+ end
+
+ it 'creates status' do
+ status = sender.statuses.first
+
+ expect(status).to_not be_nil
+ expect(status.emojis.map(&:shortcode)).to include('tinkong')
+ end
+ end
+
context 'with emojis missing name' do
let(:object_json) do
{