diff --git a/app/models/user.rb b/app/models/user.rb index b187a9ea3b3fc69dcc3fb4133c270b5f11d42260..dc9723440a8b22b1c8344f36f7a0813fa8eadef1 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -228,8 +228,7 @@ class User < ActiveRecord::Base ######## Posting ######## def build_post(class_name, opts={}) - opts[:author] = self.person - opts[:diaspora_handle] = opts[:author].diaspora_handle + opts[:author] = person model_class = class_name.to_s.camelize.constantize model_class.diaspora_initialize(opts) diff --git a/lib/diaspora/fields/author.rb b/lib/diaspora/fields/author.rb index eaabbf27fb2a7b26dd983bb239d023947bf16e93..29bf5204d2d4bfba47b50c32ae2d69b6a0fea3a7 100644 --- a/lib/diaspora/fields/author.rb +++ b/lib/diaspora/fields/author.rb @@ -10,10 +10,6 @@ module Diaspora validates :author, presence: true end end - - def diaspora_handle=(nh) - self.author = Person.find_or_fetch_by_identifier(nh) - end end end end diff --git a/spec/factories.rb b/spec/factories.rb index 55df861e671a1848c16e3e12d8514bdf1122cf7f..9964492ed59eefb2b9abebfe1f37985f9c41bd35 100644 --- a/spec/factories.rb +++ b/spec/factories.rb @@ -94,9 +94,6 @@ FactoryGirl.define do factory(:status_message, aliases: %i(status_message_without_participation)) do sequence(:text) {|n| "jimmy's #{n} whales" } author - after(:build) do |sm| - sm.diaspora_handle = sm.author.diaspora_handle - end factory(:status_message_with_poll) do after(:build) do |sm| diff --git a/spec/integration/federation/attack_vectors_spec.rb b/spec/integration/federation/attack_vectors_spec.rb index 033a90990ea31ad7941aa8d708053f77e39a4969..b2d8795a8f3ba1f2e4f42bfc0012336b901d5a79 100644 --- a/spec/integration/federation/attack_vectors_spec.rb +++ b/spec/integration/federation/attack_vectors_spec.rb @@ -20,7 +20,7 @@ describe "attack vectors", type: :request do # bob trys to send a message to alice original_message = eve.post(:status_message, text: "store this!", to: eves_aspect.id) - original_message.diaspora_handle = bob.diaspora_handle + original_message.author = bob.person alice.share_with(eve.person, alices_aspect) @@ -116,7 +116,7 @@ describe "attack vectors", type: :request do original_message = eve.post(:photo, user_file: uploaded_photo, text: "store this!", to: eves_aspect.id) new_message = original_message.dup - new_message.diaspora_handle = alice.diaspora_handle + new_message.author = alice.person new_message.text = "bad bad bad" new_message.height = 23 new_message.width = 42 diff --git a/spec/models/status_message_spec.rb b/spec/models/status_message_spec.rb index a12bb92c73ca4cd1f038f0f115acd2c857a67f6a..dffeff84191cd3e0441543e8b18d6a9c1f8d4173 100644 --- a/spec/models/status_message_spec.rb +++ b/spec/models/status_message_spec.rb @@ -96,15 +96,6 @@ describe StatusMessage, type: :model do end end - describe "#diaspora_handle=" do - it "sets #author" do - person = FactoryGirl.create(:person) - post = FactoryGirl.build(:status_message, author: user.person) - post.diaspora_handle = person.diaspora_handle - expect(post.author).to eq(person) - end - end - context "emptyness" do it "needs either a message or at least one photo" do post = user.build_post(:status_message, text: nil)