about summary refs log tree commit diff
path: root/spec/lib/activitypub
diff options
context:
space:
mode:
authorThibG <thib@sitedethib.com>2019-03-04 22:51:23 +0100
committerEugen Rochko <eugen@zeonfederated.com>2019-03-04 22:51:23 +0100
commit833ffce2df68ae3b673e230fcb273da5d8c4681f (patch)
treef06854fd6b50c62897d9c25a9b50c21d93c894dd /spec/lib/activitypub
parent7a25bb858a2a7f3662d2ad2a8cba9ac7ea141aca (diff)
Store remote votes URI (#10158)
* Store remote votes URI

* Add spec for accepting remote votes

* Make poll vote id generation work the same way as follows
Diffstat (limited to 'spec/lib/activitypub')
-rw-r--r--spec/lib/activitypub/activity/create_spec.rb21
1 files changed, 21 insertions, 0 deletions
diff --git a/spec/lib/activitypub/activity/create_spec.rb b/spec/lib/activitypub/activity/create_spec.rb
index ac6237c86..4780c29c8 100644
--- a/spec/lib/activitypub/activity/create_spec.rb
+++ b/spec/lib/activitypub/activity/create_spec.rb
@@ -447,6 +447,27 @@ RSpec.describe ActivityPub::Activity::Create do
           expect(poll.cached_tallies).to eq [10, 3]
         end
       end
+
+      context 'when a vote to a local poll' do
+        let(:poll) { Fabricate(:poll, options: %w(Yellow Blue)) }
+        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 'adds a vote to the poll with correct uri' do
+          vote = poll.votes.first
+          expect(vote).to_not be_nil
+          expect(vote.uri).to eq object_json[:id]
+          expect(poll.reload.cached_tallies).to eq [1, 0]
+        end
+      end
     end
 
     context 'when sender is followed by local users' do