diff options
author | Jason Robinson <mail@jasonrobinson.me> | 2015-07-17 16:59:27 +0300 |
---|---|---|
committer | Jason Robinson <mail@jasonrobinson.me> | 2015-07-18 21:29:31 +0300 |
commit | bdf6c717729e0752f450cdd7592a49b2b2f39439 (patch) | |
tree | d26bc55aa3ddac65e94f39c9700da3ebf1a0e666 /spec/workers | |
parent | 0e439f6c1c66e46457bd26ff640c2278e53d9b9b (diff) |
Implement social relay functionality
* .well-known/social-relay - to serve subscription preferences to relays
* Workers.deferred_dispatch relay carbon copy functionality for outbound sending
See discussion here: https://www.loomio.org/d/9vpoe0UR/public-post-federation#comment-730911 and spec here: https://wiki.diasporafoundation.org/Relay_servers_for_public_posts
Diffstat (limited to 'spec/workers')
-rw-r--r-- | spec/workers/deferred_dispatch_spec.rb | 31 |
1 files changed, 30 insertions, 1 deletions
diff --git a/spec/workers/deferred_dispatch_spec.rb b/spec/workers/deferred_dispatch_spec.rb index f0a20d768..0d4064bbb 100644 --- a/spec/workers/deferred_dispatch_spec.rb +++ b/spec/workers/deferred_dispatch_spec.rb @@ -3,7 +3,36 @@ require 'spec_helper' describe Workers::DeferredDispatch do it "handles non existing records gracefully" do expect { - described_class.new.perform(alice.id, 'Comment', 0, {}) + described_class.new.perform(alice.id, "Comment", 0, {}) }.to_not raise_error end + + describe "#social relay functionality" do + let(:message) { FactoryGirl.create(:status_message, author: alice.person, public: true) } + before do + AppConfig.relay.outbound.send = true + end + + it "triggers fetch of relay handle" do + allow(Person).to receive(:find_by).and_return(nil) + + expect(Workers::FetchWebfinger).to receive(:perform_async) + + described_class.new.perform(alice.id, "StatusMessage", message.id, {}) + end + + it "triggers post to relay" do + relay_person = FactoryGirl.create(:person, diaspora_handle: AppConfig.relay.outbound.handle) + opts = {"additional_subscribers" => [relay_person], "services" => []} + allow(Person).to receive(:find_by).and_return(relay_person) + postzord = double + allow(Postzord::Dispatcher).to receive(:build).with(any_args).and_return(postzord) + allow(postzord).to receive(:post) + allow(Person).to receive(:where).and_return([relay_person]) + + expect(Postzord::Dispatcher).to receive(:build).with(alice, message, opts) + + described_class.new.perform(alice.id, "StatusMessage", message.id, {}) + end + end end |