Do not allow adding votes to expired polls (#10214)
* Do not allow adding votes to expired polls * Only validate expires_at on create
This commit is contained in:
		@@ -482,6 +482,28 @@ RSpec.describe ActivityPub::Activity::Create do
 | 
			
		||||
          expect(poll.reload.cached_tallies).to eq [1, 0]
 | 
			
		||||
        end
 | 
			
		||||
      end
 | 
			
		||||
 | 
			
		||||
      context 'when a vote to an expired local poll' do
 | 
			
		||||
        let(:poll) do
 | 
			
		||||
          poll = Fabricate.build(:poll, options: %w(Yellow Blue), expires_at: 1.day.ago)
 | 
			
		||||
          poll.save(validate: false)
 | 
			
		||||
          poll
 | 
			
		||||
        end
 | 
			
		||||
        let!(:local_status) { Fabricate(:status, owned_poll: poll) }
 | 
			
		||||
 | 
			
		||||
        let(:object_json) do
 | 
			
		||||
          {
 | 
			
		||||
            id: [ActivityPub::TagManager.instance.uri_for(sender), '#bar'].join,
 | 
			
		||||
            type: 'Note',
 | 
			
		||||
            name: 'Yellow',
 | 
			
		||||
            inReplyTo: ActivityPub::TagManager.instance.uri_for(local_status)
 | 
			
		||||
          }
 | 
			
		||||
        end
 | 
			
		||||
 | 
			
		||||
        it 'does not add a vote to the poll' do
 | 
			
		||||
          expect(poll.votes.first).to be_nil
 | 
			
		||||
        end
 | 
			
		||||
      end
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    context 'when sender is followed by local users' do
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user