Remove old Request entity

Closes #32
This commit is contained in:
Benjamin Neff 2019-10-29 03:17:35 +01:00
parent a082bcebff
commit edfcc7886d
No known key found for this signature in database
GPG key ID: 971464C3F1A90194
3 changed files with 0 additions and 69 deletions

View file

@ -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"

View file

@ -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

View file

@ -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