Merge branch '4239-move-federation-stuff-into-lib' of github.com:oliverbarnes/diaspora into oliverbarnes-4239-move-federation-stuff-into-lib

This commit is contained in:
Florian Staudacher 2013-08-27 22:04:12 +02:00
commit ba9e715c66
13 changed files with 38 additions and 26 deletions

View file

@ -1,6 +1,7 @@
# Head
## Refactor
Move non-model federation stuff into lib/ [#4363](https://github.com/diaspora/diaspora/pull/4363)
## Bug fixes
Highlight down arrow at the user menu on hover [#4441](https://github.com/diaspora/diaspora/pull/4441)

View file

@ -9,4 +9,5 @@ module Diaspora
require 'diaspora/markdownify'
require 'diaspora/mentionable'
require 'diaspora/exporter'
require 'diaspora/federated'
end

12
lib/diaspora/federated.rb Normal file
View file

@ -0,0 +1,12 @@
# Copyright (c) 2010-2011, Diaspora Inc. This file is
# licensed under the Affero General Public License version 3 or later. See
# the COPYRIGHT file.
module Diaspora
module Federated
require 'diaspora/federated/request'
require 'diaspora/federated/retraction'
require 'diaspora/federated/signed_retraction'
require 'diaspora/federated/relayable_retraction'
end
end

View file

@ -1,7 +1,6 @@
# Copyright (c) 2010-2011, Diaspora Inc. This file is
# licensed under the Affero General Public License version 3 or later. See
# the COPYRIGHT file.
class RelayableRetraction < SignedRetraction
xml_name :relayable_retraction
xml_attr :parent_author_signature

View file

@ -1,7 +1,6 @@
# Copyright (c) 2010-2011, Diaspora Inc. This file is
# licensed under the Affero General Public License version 3 or later. See
# the COPYRIGHT file.
class Retraction
include Diaspora::Federated::Base
@ -61,4 +60,4 @@ class Retraction
end
self
end
end
end

View file

@ -82,7 +82,7 @@ describe RelayableRetraction do
context 'from the upstream owner' do
before do
@comment = @local_luke.comment!(@remote_parent, "Yeah, it was great")
@retraction = RelayableRetraction.allocate
@retraction = described_class.allocate
@retraction.sender = @remote_raphael
@retraction.target = @comment
@retraction.stub!(:parent_author_signature_valid?).and_return(true)
@ -104,7 +104,7 @@ describe RelayableRetraction do
describe 'xml' do
before do
@comment = @local_leia.comment!(@local_parent, "yo")
@retraction = RelayableRetraction.build(@local_leia, @comment)
@retraction = described_class.build(@local_leia, @comment)
@retraction.parent_author_signature = 'PARENTSIGNATURE'
@retraction.target_author_signature = 'TARGETSIGNATURE'
@xml = @retraction.to_xml.to_s
@ -131,7 +131,7 @@ describe RelayableRetraction do
describe '.from_xml' do
before do
@marshalled = RelayableRetraction.from_xml(@xml)
@marshalled = described_class.from_xml(@xml)
end
it 'marshals the target' do

View file

@ -11,7 +11,7 @@ describe Request do
describe 'validations' do
before do
@request = Request.diaspora_initialize(:from => alice.person, :to => eve.person, :into => @aspect)
@request = described_class.diaspora_initialize(:from => alice.person, :to => eve.person, :into => @aspect)
end
it 'is valid' do
@ -42,7 +42,7 @@ describe Request do
end
it 'is not to yourself' do
@request = Request.diaspora_initialize(:from => alice.person, :to => alice.person, :into => @aspect)
@request = described_class.diaspora_initialize(:from => alice.person, :to => alice.person, :into => @aspect)
@request.should_not be_valid
end
end
@ -51,7 +51,7 @@ describe Request do
it 'returns request_accepted' do
person = FactoryGirl.build:person
request = Request.diaspora_initialize(:from => alice.person, :to => eve.person, :into => @aspect)
request = described_class.diaspora_initialize(:from => alice.person, :to => eve.person, :into => @aspect)
alice.contacts.create(:person_id => person.id)
request.notification_type(alice, person).should == Notifications::StartedSharing
@ -60,14 +60,14 @@ describe Request do
describe '#subscribers' do
it 'returns an array with to field on a request' do
request = Request.diaspora_initialize(:from => alice.person, :to => eve.person, :into => @aspect)
request = described_class.diaspora_initialize(:from => alice.person, :to => eve.person, :into => @aspect)
request.subscribers(alice).should =~ [eve.person]
end
end
describe '#receive' do
it 'creates a contact' do
request = Request.diaspora_initialize(:from => alice.person, :to => eve.person, :into => @aspect)
request = described_class.diaspora_initialize(:from => alice.person, :to => eve.person, :into => @aspect)
lambda{
request.receive(eve, alice.person)
}.should change{
@ -79,7 +79,7 @@ describe Request do
alice.share_with(eve.person, alice.aspects.first)
lambda {
Request.diaspora_initialize(:from => eve.person, :to => alice.person,
described_class.diaspora_initialize(:from => eve.person, :to => alice.person,
:into => eve.aspects.first).receive(alice, eve.person)
}.should change {
alice.contacts.find_by_person_id(eve.person.id).mutual?
@ -88,7 +88,7 @@ describe Request do
end
it 'sets sharing' do
Request.diaspora_initialize(:from => eve.person, :to => alice.person,
described_class.diaspora_initialize(:from => eve.person, :to => alice.person,
:into => eve.aspects.first).receive(alice, eve.person)
alice.contact_for(eve.person).should be_sharing
end
@ -98,10 +98,10 @@ describe Request do
alice.auto_follow_back_aspect = alice.aspects.first
alice.save
Request.diaspora_initialize(:from => eve.person, :to => alice.person,
:into => eve.aspects.first).receive(alice, eve.person)
described_class.diaspora_initialize(:from => eve.person, :to => alice.person,
:into => eve.aspects.first).receive(alice, eve.person)
eve.contact_for(alice.person).should be_sharing
eve.contact_for( alice.person ).should be_sharing
end
it 'shares not back if auto_following is not enabled' do
@ -109,7 +109,7 @@ describe Request do
alice.auto_follow_back_aspect = alice.aspects.first
alice.save
Request.diaspora_initialize(:from => eve.person, :to => alice.person,
described_class.diaspora_initialize(:from => eve.person, :to => alice.person,
:into => eve.aspects.first).receive(alice, eve.person)
eve.contact_for(alice.person).should be_nil
@ -126,14 +126,14 @@ describe Request do
alice.should_not_receive(:share_with)
Request.diaspora_initialize(:from => eve.person, :to => alice.person,
described_class.diaspora_initialize(:from => eve.person, :to => alice.person,
:into => eve.aspects.first).receive(alice, eve.person)
end
end
context 'xml' do
before do
@request = Request.diaspora_initialize(:from => alice.person, :to => eve.person, :into => @aspect)
@request = described_class.diaspora_initialize(:from => alice.person, :to => eve.person, :into => @aspect)
@xml = @request.to_xml.to_s
end
@ -148,7 +148,7 @@ describe Request do
context 'marshalling' do
it 'produces a request object' do
marshalled = Request.from_xml @xml
marshalled = described_class.from_xml @xml
marshalled.sender.should == alice.person
marshalled.recipient.should == eve.person

View file

@ -13,7 +13,7 @@ describe Retraction do
describe 'serialization' do
it 'should have a post id after serialization' do
retraction = Retraction.for(@post)
retraction = described_class.for(@post)
xml = retraction.to_xml.to_s
xml.include?(@post.guid.to_s).should == true
end
@ -22,7 +22,7 @@ describe Retraction do
describe '#subscribers' do
context 'posts' do
before do
@retraction = Retraction.for(@post)
@retraction = described_class.for(@post)
@obj = @retraction.instance_variable_get(:@object)
@wanted_subscribers = @obj.subscribers(alice)
end
@ -42,7 +42,7 @@ describe Retraction do
context 'setting subscribers' do
it 'barfs if the type is a person, and subscribers instance varabile is not set' do
retraction = Retraction.for(alice)
retraction = described_class.for(alice)
obj = retraction.instance_variable_get(:@object)
lambda {
@ -51,7 +51,7 @@ describe Retraction do
end
it 'returns manually set subscribers' do
retraction = Retraction.for(alice)
retraction = described_class.for(alice)
retraction.subscribers = "fooey"
retraction.subscribers(alice).should == 'fooey'
end

View file

@ -9,7 +9,7 @@ describe SignedRetraction do
end
describe '#perform' do
it "dispatches the retraction onward to recipients of the recipient's reshare" do
retraction = SignedRetraction.build(bob, @post)
retraction = described_class.build(bob, @post)
onward_retraction = retraction.dup
retraction.should_receive(:dup).and_return(onward_retraction)
@ -24,7 +24,7 @@ describe SignedRetraction do
bob.post(:reshare, :root_guid => remote_post.guid)
alice.post(:reshare, :root_guid => remote_post.guid)
remote_retraction = SignedRetraction.new.tap{|r|
remote_retraction = described_class.new.tap{|r|
r.target_type = remote_post.type
r.target_guid = remote_post.guid
r.sender = remote_post.author