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.target = target
|
||||
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
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -230,21 +230,29 @@ class User < ActiveRecord::Base
|
|||
end
|
||||
|
||||
######### Posts and Such ###############
|
||||
def retract(target)
|
||||
def retract(target, opts={})
|
||||
if target.respond_to?(:relayable?) && target.relayable?
|
||||
retraction = RelayableRetraction.build(self, target)
|
||||
else
|
||||
retraction = Retraction.for(target)
|
||||
end
|
||||
|
||||
opts = {}
|
||||
if target.is_a?(Post)
|
||||
opts[:additional_subscribers] = target.resharers
|
||||
if target.is_a?(Post) && target.reshares.size != 0
|
||||
reshare_retraction = RelayableRetraction.build(self, target)
|
||||
end
|
||||
|
||||
# if target.is_a?(Post)
|
||||
# opts[:additional_subscribers] = target.resharers
|
||||
# end
|
||||
|
||||
mailman = Postzord::Dispatch.new(self, retraction, opts)
|
||||
mailman.post
|
||||
|
||||
if reshare_retraction
|
||||
mailman = Postzord::Dispatch.new(self, reshare_retraction)
|
||||
mailman.post
|
||||
end
|
||||
|
||||
retraction.perform(self)
|
||||
|
||||
retraction
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@
|
|||
- if (post.author_id != current_user.person.id) && (post.public?) && !reshare?(post)
|
||||
·
|
||||
%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'
|
||||
|
|
|
|||
|
|
@ -91,9 +91,8 @@ Feature: public repost
|
|||
Then I should see "reshare this!"
|
||||
Then I should see a ".reshare"
|
||||
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"
|
||||
|
||||
Scenario: Can have text
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ describe Retraction do
|
|||
before do
|
||||
@aspect = alice.aspects.first
|
||||
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
|
||||
|
||||
describe 'serialization' do
|
||||
|
|
@ -20,12 +20,24 @@ describe Retraction do
|
|||
end
|
||||
|
||||
describe '#subscribers' do
|
||||
it 'returns the subscribers to the post for all objects other than person' do
|
||||
retraction = Retraction.for(@post)
|
||||
obj = retraction.instance_variable_get(:@object)
|
||||
wanted_subscribers = obj.subscribers(alice)
|
||||
obj.should_receive(:subscribers).with(alice).and_return(wanted_subscribers)
|
||||
retraction.subscribers(alice).map{|s| s.id}.should =~ wanted_subscribers.map{|s| s.id}
|
||||
context 'posts' do
|
||||
before do
|
||||
@retraction = Retraction.for(@post)
|
||||
@obj = @retraction.instance_variable_get(:@object)
|
||||
@wanted_subscribers = @obj.subscribers(alice)
|
||||
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
|
||||
|
||||
context 'setting subscribers' do
|
||||
|
|
|
|||
|
|
@ -756,14 +756,14 @@ describe User do
|
|||
describe '#retract' do
|
||||
before do
|
||||
@retraction = mock
|
||||
|
||||
@post = Factory(:status_message, :author => bob.person, :public => true)
|
||||
end
|
||||
|
||||
context "regular retractions" do
|
||||
before do
|
||||
Retraction.stub(:for).and_return(@retraction)
|
||||
@retraction.stub(:perform)
|
||||
|
||||
@post = Factory(:status_message, :author => bob.person, :public => true)
|
||||
end
|
||||
|
||||
it 'sends a retraction' do
|
||||
|
|
@ -787,13 +787,25 @@ describe User do
|
|||
end
|
||||
|
||||
it 'performs the retraction' do
|
||||
|
||||
pending
|
||||
end
|
||||
end
|
||||
|
||||
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
|
||||
|
|
|
|||
Loading…
Reference in a new issue