repost wip
This commit is contained in:
parent
987d44c41c
commit
2d6f51f68c
6 changed files with 50 additions and 19 deletions
|
|
@ -51,7 +51,7 @@ class RelayableRetraction
|
||||||
retraction.sender = sender
|
retraction.sender = sender
|
||||||
retraction.target = target
|
retraction.target = target
|
||||||
retraction.target_author_signature = retraction.sign_with_key(sender.encryption_key) if sender.person == target.author
|
retraction.target_author_signature = retraction.sign_with_key(sender.encryption_key) if sender.person == target.author
|
||||||
retraction.parent_author_signature = retraction.sign_with_key(sender.encryption_key) if sender.person == target.parent.author
|
retraction.parent_author_signature = retraction.sign_with_key(sender.encryption_key) if defined?(target.parent) && sender.person == target.parent.author
|
||||||
retraction
|
retraction
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -230,21 +230,29 @@ class User < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
######### Posts and Such ###############
|
######### Posts and Such ###############
|
||||||
def retract(target)
|
def retract(target, opts={})
|
||||||
if target.respond_to?(:relayable?) && target.relayable?
|
if target.respond_to?(:relayable?) && target.relayable?
|
||||||
retraction = RelayableRetraction.build(self, target)
|
retraction = RelayableRetraction.build(self, target)
|
||||||
else
|
else
|
||||||
retraction = Retraction.for(target)
|
retraction = Retraction.for(target)
|
||||||
end
|
end
|
||||||
|
|
||||||
opts = {}
|
if target.is_a?(Post) && target.reshares.size != 0
|
||||||
if target.is_a?(Post)
|
reshare_retraction = RelayableRetraction.build(self, target)
|
||||||
opts[:additional_subscribers] = target.resharers
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# if target.is_a?(Post)
|
||||||
|
# opts[:additional_subscribers] = target.resharers
|
||||||
|
# end
|
||||||
|
|
||||||
mailman = Postzord::Dispatch.new(self, retraction, opts)
|
mailman = Postzord::Dispatch.new(self, retraction, opts)
|
||||||
mailman.post
|
mailman.post
|
||||||
|
|
||||||
|
if reshare_retraction
|
||||||
|
mailman = Postzord::Dispatch.new(self, reshare_retraction)
|
||||||
|
mailman.post
|
||||||
|
end
|
||||||
|
|
||||||
retraction.perform(self)
|
retraction.perform(self)
|
||||||
|
|
||||||
retraction
|
retraction
|
||||||
|
|
|
||||||
|
|
@ -61,7 +61,7 @@
|
||||||
- if (post.author_id != current_user.person.id) && (post.public?) && !reshare?(post)
|
- if (post.author_id != current_user.person.id) && (post.public?) && !reshare?(post)
|
||||||
·
|
·
|
||||||
%span.reshare_action
|
%span.reshare_action
|
||||||
= link_to "Reshare", reshares_path(:root_id => post.id), :method => :post, :remote => true, :confirm => "Reshare: #{post.author.name} - #{post.text}?"
|
= link_to "#{(post.reshares.size unless post.reshares.size == 0)} Reshare", reshares_path(:root_id => post.id), :method => :post, :remote => true, :confirm => "Reshare: #{post.author.name} - #{post.text}?"
|
||||||
·
|
·
|
||||||
|
|
||||||
= link_to t('comments.new_comment.comment'), '#', :class => 'focus_comment_textarea'
|
= link_to t('comments.new_comment.comment'), '#', :class => 'focus_comment_textarea'
|
||||||
|
|
|
||||||
|
|
@ -91,9 +91,8 @@ Feature: public repost
|
||||||
Then I should see "reshare this!"
|
Then I should see "reshare this!"
|
||||||
Then I should see a ".reshare"
|
Then I should see a ".reshare"
|
||||||
And I should see "Bob"
|
And I should see "Bob"
|
||||||
|
And I go to the home page
|
||||||
|
|
||||||
And I go to the destroy user session page
|
|
||||||
And I sign in as "bob@bob.bob"
|
|
||||||
And I should see "1 Reshare"
|
And I should see "1 Reshare"
|
||||||
|
|
||||||
Scenario: Can have text
|
Scenario: Can have text
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ describe Retraction do
|
||||||
before do
|
before do
|
||||||
@aspect = alice.aspects.first
|
@aspect = alice.aspects.first
|
||||||
alice.contacts.create(:person => eve.person, :aspects => [@aspect])
|
alice.contacts.create(:person => eve.person, :aspects => [@aspect])
|
||||||
@post = alice.post :status_message, :text => "Destroy!", :to => @aspect.id
|
@post = alice.post(:status_message, :public => true, :text => "Destroy!", :to => @aspect.id)
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'serialization' do
|
describe 'serialization' do
|
||||||
|
|
@ -20,12 +20,24 @@ describe Retraction do
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '#subscribers' do
|
describe '#subscribers' do
|
||||||
it 'returns the subscribers to the post for all objects other than person' do
|
context 'posts' do
|
||||||
retraction = Retraction.for(@post)
|
before do
|
||||||
obj = retraction.instance_variable_get(:@object)
|
@retraction = Retraction.for(@post)
|
||||||
wanted_subscribers = obj.subscribers(alice)
|
@obj = @retraction.instance_variable_get(:@object)
|
||||||
obj.should_receive(:subscribers).with(alice).and_return(wanted_subscribers)
|
@wanted_subscribers = @obj.subscribers(alice)
|
||||||
retraction.subscribers(alice).map{|s| s.id}.should =~ wanted_subscribers.map{|s| s.id}
|
end
|
||||||
|
|
||||||
|
it 'returns the subscribers to the post for all objects other than person' do
|
||||||
|
@retraction.subscribers(alice).map(&:id).should =~ @wanted_subscribers.map(&:id)
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'does not return the authors of reshares' do
|
||||||
|
@post.reshares << Factory.create(:reshare, :root => @post, :author => bob.person)
|
||||||
|
@post.save!
|
||||||
|
|
||||||
|
@wanted_subscribers -= [bob.person]
|
||||||
|
@retraction.subscribers(alice).map(&:id).should =~ @wanted_subscribers.map(&:id)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'setting subscribers' do
|
context 'setting subscribers' do
|
||||||
|
|
|
||||||
|
|
@ -756,14 +756,14 @@ describe User do
|
||||||
describe '#retract' do
|
describe '#retract' do
|
||||||
before do
|
before do
|
||||||
@retraction = mock
|
@retraction = mock
|
||||||
|
|
||||||
|
@post = Factory(:status_message, :author => bob.person, :public => true)
|
||||||
end
|
end
|
||||||
|
|
||||||
context "regular retractions" do
|
context "regular retractions" do
|
||||||
before do
|
before do
|
||||||
Retraction.stub(:for).and_return(@retraction)
|
Retraction.stub(:for).and_return(@retraction)
|
||||||
@retraction.stub(:perform)
|
@retraction.stub(:perform)
|
||||||
|
|
||||||
@post = Factory(:status_message, :author => bob.person, :public => true)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'sends a retraction' do
|
it 'sends a retraction' do
|
||||||
|
|
@ -787,13 +787,25 @@ describe User do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'performs the retraction' do
|
it 'performs the retraction' do
|
||||||
|
pending
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context "relayable retractions" do
|
context "relayable retractions" do
|
||||||
it 'sends a relayable retraction if the object is relayable' do
|
before do
|
||||||
|
@post.reshares << Factory.create(:reshare, :author => remote_raphael)
|
||||||
|
@post.save!
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'sends a relayable retraction if the object is relayable' do
|
||||||
|
r_ret = RelayableRetraction.build(bob, @post)
|
||||||
|
RelayableRetraction.should_receive(:build).and_return(r_ret)
|
||||||
|
|
||||||
|
dis = mock
|
||||||
|
dis.should_receive(:post)
|
||||||
|
Postzord::Dispatch.should_receive(:new).with(bob, r_ret).and_return(dis)
|
||||||
|
|
||||||
|
bob.retract(@post)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue