Skip to content
Extraits de code Groupes Projets
Valider 66925918 rédigé par Jason Robinson's avatar Jason Robinson Validation de Dennis Schubert
Parcourir les fichiers

Send comment to reshare author when commenting on reshare

As posts are always delivered also to reshare root, comments should also be delivered to reshare root, for concistency.
parent 0925a265
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -12,11 +12,20 @@ module Federated
relayable = build(options)
if relayable.save!
logger.info "user:#{@user.id} dispatching #{relayable.class}:#{relayable.guid}"
add_root_author(relayable)
Postzord::Dispatcher.defer_build_and_post(@user, relayable, @dispatcher_opts)
relayable
end
end
def add_root_author(relayable)
return unless relayable.parent.respond_to?(:root) && relayable.parent.root
# Comment post is a reshare, include original author in subscribers
root_post = relayable.parent.root
@dispatcher_opts[:additional_subscribers] ||= []
@dispatcher_opts[:additional_subscribers] << root_post.author
end
def build(options={})
options.merge!(relayable_options)
relayable = self.class.federated_class.new(options.merge(:author_id => @user.person.id))
......
require "spec_helper"
describe "adds root author on reshare" do
before do
@generator = Federated::Generator.new(double("user", id: 1), double)
@root_author = double("root_author")
root = double("root", author: @root_author)
parent = double("parent", root: root)
@relayable = double("relayable", parent: parent, class: "foo", guid: "123")
end
it "adds root to additional subscribers" do
@generator.add_root_author(@relayable)
additional_subscribers = @generator.instance_variable_get(:@dispatcher_opts)[:additional_subscribers]
expect(additional_subscribers).to include(@root_author)
end
it "calls add_root_author" do
allow(Postzord::Dispatcher).to receive(:defer_build_and_post).and_return(true)
allow(@generator).to receive(:build).and_return(@relayable)
allow(@relayable).to receive(:save!).and_return(true)
expect(@generator).to receive(:add_root_author)
@generator.create!
end
end
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter