add tests to see if timestamps are updated on recevie...they are not
This commit is contained in:
parent
6e0e46435e
commit
a649d18cd7
4 changed files with 46 additions and 10 deletions
|
|
@ -65,7 +65,6 @@ class Post < ActiveRecord::Base
|
|||
def receive(user, person)
|
||||
#exists locally, but you dont know about it
|
||||
#does not exsist locally, and you dont know about it
|
||||
|
||||
#exists_locally?
|
||||
#you know about it, and it is mutable
|
||||
#you know about it, and it is not mutable
|
||||
|
|
@ -82,13 +81,13 @@ class Post < ActiveRecord::Base
|
|||
else
|
||||
user.add_post_to_aspects(local_post)
|
||||
Rails.logger.info("event=receive payload_type=#{self.class} update=true status=complete sender=#{self.diaspora_handle} existing_post=#{local_post.id}")
|
||||
local_post
|
||||
return local_post
|
||||
end
|
||||
elsif !local_post
|
||||
self.save
|
||||
user.add_post_to_aspects(self)
|
||||
Rails.logger.info("event=receive payload_type=#{self.class} update=false status=complete sender=#{self.diaspora_handle}")
|
||||
self
|
||||
return self
|
||||
else
|
||||
Rails.logger.info("event=receive payload_type=#{self.class} update=true status=abort sender=#{self.diaspora_handle} reason='update not from post owner' existing_post=#{self.id}")
|
||||
end
|
||||
|
|
|
|||
|
|
@ -20,7 +20,6 @@ describe 'a user receives a post' do
|
|||
|
||||
@user3 = eve
|
||||
@aspect3 = @user3.aspects.first
|
||||
|
||||
end
|
||||
|
||||
it 'streams only one message to the everyone aspect when a multi-aspected contacts posts' do
|
||||
|
|
@ -230,6 +229,36 @@ describe 'a user receives a post' do
|
|||
end
|
||||
end
|
||||
|
||||
|
||||
describe 'receiving mulitple versions of the same post from a remote pod' do
|
||||
before do
|
||||
@local_luke, @local_leia, @remote_raphael = set_up_friends
|
||||
@post = Factory.build(:status_message, :message => 'hey', :guid => 12313123, :person => @remote_raphael, :created_at => 5.days.ago, :updated_at => 5.days.ago)
|
||||
end
|
||||
|
||||
it 'does not update created_at or updated_at when two people save the same post' do
|
||||
@post = Factory.build(:status_message, :message => 'hey', :guid => 12313123, :person => @remote_raphael, :created_at => 5.days.ago, :updated_at => 5.days.ago)
|
||||
xml = @post.to_diaspora_xml
|
||||
receive_with_zord(@local_luke, @remote_raphael, xml)
|
||||
sleep(2)
|
||||
old_time = Time.now
|
||||
receive_with_zord(@local_leia, @remote_raphael, xml)
|
||||
(Post.find_by_guid @post.guid).updated_at.should be < old_time
|
||||
(Post.find_by_guid @post.guid).created_at.should be < old_time
|
||||
end
|
||||
|
||||
it 'does not update the post if a new one is sent with a new created_at' do
|
||||
@post = Factory.build(:status_message, :message => 'hey', :guid => 12313123, :person => @remote_raphael, :created_at => 5.days.ago)
|
||||
old_time = @post.created_at
|
||||
xml = @post.to_diaspora_xml
|
||||
receive_with_zord(@local_luke, @remote_raphael, xml)
|
||||
@post = Factory.build(:status_message, :message => 'hey', :guid => 12313123, :person => @remote_raphael, :created_at => 2.days.ago)
|
||||
receive_with_zord(@local_luke, @remote_raphael, xml)
|
||||
(Post.find_by_guid @post.guid).created_at.day.should == old_time.day
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
describe 'salmon' do
|
||||
let(:post){@user1.post :status_message, :message => "hello", :to => @aspect.id}
|
||||
let(:salmon){@user1.salmon( post )}
|
||||
|
|
|
|||
|
|
@ -76,13 +76,9 @@ describe Postzord::Dispatch do
|
|||
|
||||
context "comments" do
|
||||
before do
|
||||
@local_luke = Factory(:user_with_aspect, :username => "luke")
|
||||
@local_leia = Factory(:user_with_aspect, :username => "leia")
|
||||
@remote_raphael = Factory(:person, :diaspora_handle => "raphael@remote.net")
|
||||
connect_users_with_aspects(@local_luke, @local_leia)
|
||||
@local_leia.activate_contact(@remote_raphael, @local_leia.aspects.first)
|
||||
@local_luke.activate_contact(@remote_raphael, @local_luke.aspects.first)
|
||||
@local_luke, @local_leia, @remote_raphael = set_up_friends
|
||||
end
|
||||
|
||||
context "local luke's post is commented on by" do
|
||||
before do
|
||||
@post = @local_luke.post(:status_message, :message => "hello", :to => @local_luke.aspects.first)
|
||||
|
|
|
|||
|
|
@ -34,6 +34,18 @@ RSpec.configure do |config|
|
|||
end
|
||||
end
|
||||
|
||||
def set_up_friends
|
||||
local_luke = Factory(:user_with_aspect, :username => "luke")
|
||||
local_leia = Factory(:user_with_aspect, :username => "leia")
|
||||
remote_raphael = Factory(:person, :diaspora_handle => "raphael@remote.net")
|
||||
connect_users_with_aspects(local_luke, local_leia)
|
||||
local_leia.activate_contact(remote_raphael, local_leia.aspects.first)
|
||||
local_luke.activate_contact(remote_raphael, local_luke.aspects.first)
|
||||
|
||||
[local_luke, local_leia, remote_raphael]
|
||||
end
|
||||
|
||||
|
||||
def alice
|
||||
#users(:alice)
|
||||
User.where(:username => 'alice').first
|
||||
|
|
|
|||
Loading…
Reference in a new issue