new users now autofollow diasporahq@joindiaspora.com; upon connecting to a user, you now get post visibilities for their public posts (that your pod knows about)
This commit is contained in:
parent
a320891df0
commit
73616a3e7a
6 changed files with 42 additions and 2 deletions
|
|
@ -345,7 +345,10 @@ class User < ActiveRecord::Base
|
|||
|
||||
def seed_aspects
|
||||
self.aspects.create(:name => I18n.t('aspects.seed.family'))
|
||||
self.aspects.create(:name => I18n.t('aspects.seed.work'))
|
||||
work = self.aspects.create(:name => I18n.t('aspects.seed.work'))
|
||||
default_account = Webfinger.new('diasporahq@joindiaspora.com').fetch
|
||||
self.share_with(default_account, work)
|
||||
work
|
||||
end
|
||||
|
||||
def self.generate_key
|
||||
|
|
|
|||
|
|
@ -22,10 +22,21 @@ module Diaspora
|
|||
if notification = Notification.where(:target_id => person.id).first
|
||||
notification.update_attributes(:unread=>false)
|
||||
end
|
||||
|
||||
|
||||
register_post_visibilities(contact)
|
||||
contact
|
||||
end
|
||||
|
||||
def register_post_visibilities(contact)
|
||||
#should have select here, but proven hard to test
|
||||
posts = Post.where(:author_id => contact.person_id, :public => true).limit(100)
|
||||
posts.map! do |post|
|
||||
PostVisibility.new(:contact_id => contact.id, :post_id => post.id)
|
||||
end
|
||||
PostVisibility.import(posts) unless posts.empty?
|
||||
nil
|
||||
end
|
||||
|
||||
def remove_contact(contact, opts={:force => false})
|
||||
posts = contact.posts.all
|
||||
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ describe InvitationsController do
|
|||
@aspect = @user.aspects.first
|
||||
|
||||
request.env["devise.mapping"] = Devise.mappings[:user]
|
||||
Webfinger.stub_chain(:new, :fetch).and_return(Factory(:person))
|
||||
end
|
||||
|
||||
describe "#create" do
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ describe RegistrationsController do
|
|||
:password_confirmation => "password"
|
||||
}
|
||||
}
|
||||
Webfinger.stub_chain(:new, :fetch).and_return(Factory(:person))
|
||||
end
|
||||
|
||||
describe '#check_registrations_open!' do
|
||||
|
|
|
|||
|
|
@ -76,6 +76,16 @@ describe Diaspora::UserModules::Connecting do
|
|||
end
|
||||
end
|
||||
|
||||
describe '#register_post_visibilities' do
|
||||
it 'creates post visibilites for up to 100 posts' do
|
||||
Post.stub_chain(:where, :limit).and_return([Factory(:status_message, :public => true)])
|
||||
c = Contact.create!(:user_id => alice.id, :person_id => eve.person.id)
|
||||
expect{
|
||||
alice.register_post_visibilities(c)
|
||||
}.to change(PostVisibility, :count).by(1)
|
||||
end
|
||||
end
|
||||
|
||||
describe '#share_with' do
|
||||
it 'finds or creates a contact' do
|
||||
lambda {
|
||||
|
|
@ -104,6 +114,11 @@ describe Diaspora::UserModules::Connecting do
|
|||
}.should change(contact.aspects, :count).by(1)
|
||||
end
|
||||
|
||||
it 'calls #register_post_visibilities with a contact' do
|
||||
eve.should_receive(:register_post_visibilities)
|
||||
eve.share_with(alice.person, eve.aspects.first)
|
||||
end
|
||||
|
||||
context 'dispatching' do
|
||||
it 'dispatches a request on initial request' do
|
||||
contact = alice.contacts.new(:person => eve.person)
|
||||
|
|
|
|||
|
|
@ -171,6 +171,15 @@ describe User do
|
|||
end
|
||||
end
|
||||
|
||||
describe '#seed_aspects' do
|
||||
it 'follows the default account' do
|
||||
Webfinger.stub_chain(:new, :fetch).and_return(Factory(:person))
|
||||
expect{
|
||||
eve.seed_aspects
|
||||
}.to change(eve.contacts, :count).by(1)
|
||||
end
|
||||
end
|
||||
|
||||
describe ".build" do
|
||||
context 'with valid params' do
|
||||
before do
|
||||
|
|
|
|||
Loading…
Reference in a new issue