parent
a082bcebff
commit
edfcc7886d
3 changed files with 0 additions and 69 deletions
|
|
@ -46,6 +46,3 @@ require "diaspora_federation/entities/message"
|
|||
require "diaspora_federation/entities/conversation"
|
||||
|
||||
require "diaspora_federation/entities/retraction"
|
||||
|
||||
# deprecated
|
||||
require "diaspora_federation/entities/request"
|
||||
|
|
|
|||
|
|
@ -1,33 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module DiasporaFederation
|
||||
module Entities
|
||||
# This entity represents a sharing request for a user. A user issues it
|
||||
# when they start sharing with another user.
|
||||
#
|
||||
# @see Validators::RequestValidator
|
||||
# @deprecated will be replaced with {Contact}
|
||||
class Request < Entity
|
||||
# @!attribute [r] author
|
||||
# The diaspora* ID of the person who share their profile
|
||||
# @see Person#author
|
||||
# @return [String] sender ID
|
||||
property :author, :string, xml_name: :sender_handle
|
||||
|
||||
# @!attribute [r] recipient
|
||||
# The diaspora* ID of the person who will be shared with
|
||||
# @see Validation::Rule::DiasporaId
|
||||
# @return [String] recipient ID
|
||||
property :recipient, :string, xml_name: :recipient_handle
|
||||
|
||||
def initialize(*)
|
||||
raise "Sending Request is not supported anymore! Use Contact instead!"
|
||||
end
|
||||
|
||||
# @return [Retraction] instance
|
||||
def self.from_hash(hash)
|
||||
Contact.new(hash)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -1,33 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module DiasporaFederation
|
||||
describe Entities::Request do
|
||||
let(:data) { {author: Fabricate.sequence(:diaspora_id), recipient: Fabricate.sequence(:diaspora_id)} }
|
||||
|
||||
let(:xml) { <<~XML }
|
||||
<request>
|
||||
<sender_handle>#{data[:author]}</sender_handle>
|
||||
<recipient_handle>#{data[:recipient]}</recipient_handle>
|
||||
</request>
|
||||
XML
|
||||
|
||||
describe "#initialize" do
|
||||
it "raises because it is not supported anymore" do
|
||||
expect {
|
||||
Entities::Request.new(data)
|
||||
}.to raise_error RuntimeError, "Sending Request is not supported anymore! Use Contact instead!"
|
||||
end
|
||||
end
|
||||
|
||||
context "parse contact" do
|
||||
it "parses the xml as a contact" do
|
||||
contact = Entities::Request.from_xml(Nokogiri::XML(xml).root)
|
||||
expect(contact).to be_a(Entities::Contact)
|
||||
expect(contact.author).to eq(data[:author])
|
||||
expect(contact.recipient).to eq(data[:recipient])
|
||||
expect(contact.following).to be_truthy
|
||||
expect(contact.sharing).to be_truthy
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
Loading…
Reference in a new issue