Add missing validations in ActivityPub::Activity::Create (#5096)
This commit is contained in:
		
				
					committed by
					
						
						Eugen Rochko
					
				
			
			
				
	
			
			
			
						parent
						
							5c82c2b75f
						
					
				
				
					commit
					98936bfcdf
				
			@@ -171,6 +171,26 @@ RSpec.describe ActivityPub::Activity::Create do
 | 
			
		||||
      end
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    context 'with mentions missing href' do
 | 
			
		||||
      let(:object_json) do
 | 
			
		||||
        {
 | 
			
		||||
          id: 'bar',
 | 
			
		||||
          type: 'Note',
 | 
			
		||||
          content: 'Lorem ipsum',
 | 
			
		||||
          tag: [
 | 
			
		||||
            {
 | 
			
		||||
              type: 'Mention',
 | 
			
		||||
            },
 | 
			
		||||
          ],
 | 
			
		||||
        }
 | 
			
		||||
      end
 | 
			
		||||
 | 
			
		||||
      it 'creates status' do
 | 
			
		||||
        status = sender.statuses.first
 | 
			
		||||
        expect(status).to_not be_nil
 | 
			
		||||
      end
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    context 'with media attachments' do
 | 
			
		||||
      let(:object_json) do
 | 
			
		||||
        {
 | 
			
		||||
@@ -195,6 +215,27 @@ RSpec.describe ActivityPub::Activity::Create do
 | 
			
		||||
      end
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    context 'with media attachments missing url' do
 | 
			
		||||
      let(:object_json) do
 | 
			
		||||
        {
 | 
			
		||||
          id: 'bar',
 | 
			
		||||
          type: 'Note',
 | 
			
		||||
          content: 'Lorem ipsum',
 | 
			
		||||
          attachment: [
 | 
			
		||||
            {
 | 
			
		||||
              type: 'Document',
 | 
			
		||||
              mime_type: 'image/png',
 | 
			
		||||
            },
 | 
			
		||||
          ],
 | 
			
		||||
        }
 | 
			
		||||
      end
 | 
			
		||||
 | 
			
		||||
      it 'creates status' do
 | 
			
		||||
        status = sender.statuses.first
 | 
			
		||||
        expect(status).to_not be_nil
 | 
			
		||||
      end
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    context 'with hashtags' do
 | 
			
		||||
      let(:object_json) do
 | 
			
		||||
        {
 | 
			
		||||
@@ -219,6 +260,27 @@ RSpec.describe ActivityPub::Activity::Create do
 | 
			
		||||
      end
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    context 'with hashtags missing name' do
 | 
			
		||||
      let(:object_json) do
 | 
			
		||||
        {
 | 
			
		||||
          id: 'bar',
 | 
			
		||||
          type: 'Note',
 | 
			
		||||
          content: 'Lorem ipsum',
 | 
			
		||||
          tag: [
 | 
			
		||||
            {
 | 
			
		||||
              type: 'Hashtag',
 | 
			
		||||
              href: 'http://example.com/blah',
 | 
			
		||||
            },
 | 
			
		||||
          ],
 | 
			
		||||
        }
 | 
			
		||||
      end
 | 
			
		||||
 | 
			
		||||
      it 'creates status' do
 | 
			
		||||
        status = sender.statuses.first
 | 
			
		||||
        expect(status).to_not be_nil
 | 
			
		||||
      end
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    context 'with emojis' do
 | 
			
		||||
      let(:object_json) do
 | 
			
		||||
        {
 | 
			
		||||
@@ -242,5 +304,47 @@ RSpec.describe ActivityPub::Activity::Create do
 | 
			
		||||
        expect(status.emojis.map(&:shortcode)).to include('tinking')
 | 
			
		||||
      end
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    context 'with emojis missing name' do
 | 
			
		||||
      let(:object_json) do
 | 
			
		||||
        {
 | 
			
		||||
          id: 'bar',
 | 
			
		||||
          type: 'Note',
 | 
			
		||||
          content: 'Lorem ipsum :tinking:',
 | 
			
		||||
          tag: [
 | 
			
		||||
            {
 | 
			
		||||
              type: 'Emoji',
 | 
			
		||||
              href: 'http://example.com/emoji.png',
 | 
			
		||||
            },
 | 
			
		||||
          ],
 | 
			
		||||
        }
 | 
			
		||||
      end
 | 
			
		||||
 | 
			
		||||
      it 'creates status' do
 | 
			
		||||
        status = sender.statuses.first
 | 
			
		||||
        expect(status).to_not be_nil
 | 
			
		||||
      end
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    context 'with emojis missing href' do
 | 
			
		||||
      let(:object_json) do
 | 
			
		||||
        {
 | 
			
		||||
          id: 'bar',
 | 
			
		||||
          type: 'Note',
 | 
			
		||||
          content: 'Lorem ipsum :tinking:',
 | 
			
		||||
          tag: [
 | 
			
		||||
            {
 | 
			
		||||
              type: 'Emoji',
 | 
			
		||||
              name: 'tinking',
 | 
			
		||||
            },
 | 
			
		||||
          ],
 | 
			
		||||
        }
 | 
			
		||||
      end
 | 
			
		||||
 | 
			
		||||
      it 'creates status' do
 | 
			
		||||
        status = sender.statuses.first
 | 
			
		||||
        expect(status).to_not be_nil
 | 
			
		||||
      end
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
end
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user