Merge branch 'master' into HEAD

Conflicts:
	README.md
This commit is contained in:
Raphael 2010-09-22 15:42:46 -07:00
commit 486b9e8bbe
44 changed files with 581 additions and 374 deletions

1
.gitignore vendored
View file

@ -13,3 +13,4 @@ gpg/diaspora-production/*.gpg
gpg/*/random_seed
public/uploads/*
.rvmrc
config/app_config.yml

View file

@ -1,14 +1,23 @@
Diaspora is copyright Diaspora Inc., 2010, and files herein are licensed under the Affero General Public License version 3, the text of which can be found in GNU-AGPL-3.0, or any later version of the AGPL, unless otherwise noted. Components of Diaspora, including Rails, JQuery, and Devise, are licensed under the MIT/X11 license. Blueprint-CSS is licensed under a modified version of the MIT/X11 license. All unmodified files from these and other sources retain their original copyright and license notices: see the relevant individual files. Attribution information for Diaspora is contained in the AUTHORS file.
Diaspora is copyright Diaspora Inc., 2010, and files herein are licensed
under the Affero General Public License version 3, the text of which can
be found in GNU-AGPL-3.0, or any later version of the AGPL, unless otherwise
noted. Components of Diaspora, including Rails, JQuery, and Devise, are
licensed under the MIT/X11 license. Blueprint-CSS is licensed under a
modified version of the MIT/X11 license. All unmodified files from these
and other sources retain their original copyright and license notices: see
the relevant individual files. Attribution information for Diaspora is
contained in the AUTHORS file.
* In addition, as a special exception, the copyright holders give
* permission to link the code of portions of this program with the
* OpenSSL library under certain conditions as described in each
* individual source file, and distribute linked combinations
* including the two.
* You must obey the GNU General Public License in all respects
* for all of the code used other than OpenSSL. If you modify
* file(s) with this exception, you may extend this exception to your
* version of the file(s), but you are not obligated to do so. If you
* do not wish to do so, delete this exception statement from your
* version. If you delete this exception statement from all source
* files in the program, then also delete it here.
In addition, as a special exception, the copyright holders give
permission to link the code of portions of this program with the
OpenSSL library under certain conditions as described in each
individual source file, and distribute linked combinations
including the two.
You must obey the GNU Affero General Public License V3 or later in all respects
for all of the code used other than OpenSSL or the components mentioned
above. If you modify file(s) with this exception, you may extend this
exception to your version of the file(s), but you are not obligated to
do so. If you do not wish to do so, delete this exception statement from your
version. If you delete this exception statement from all source files in the
program, then also delete it here.

View file

@ -325,10 +325,10 @@ Ongoing discussion:
- [#diaspora-dev IRC channel](irc://irc.freenode.net/#diaspora-dev)
([join via the web client](http://webchat.freenode.net?channels=diaspora-dev))
More general info and updates about the project can be found on our
[blog](http://joindiaspora.com),
[and on Twitter](http://twitter.com/joindiaspora). Also, be sure to join the
official [mailing list](http://http://eepurl.com/Vebk).
More general info and updates about the project can be found on:
[Our blog](http://joindiaspora.com),
[and on Twitter](http://twitter.com/joindiaspora).
Also, be sure to join the official [mailing list](http://http://eepurl.com/Vebk).
If you wish to contact us privately about any exploits in Diaspora you may
find, you can email

View file

@ -10,10 +10,7 @@ class PhotosController < ApplicationController
respond_to :json, :only => :show
def create
album = Album.find_by_id params[:album_id]
puts params
begin
######################## dealing with local files #############

View file

@ -47,8 +47,8 @@ class RequestsController < ApplicationController
begin
@request = current_user.send_friend_request_to(rel_hash[:friend], aspect)
rescue Exception => e
raise e unless e.message.include? "already friends"
flash[:notice] = "You are already friends with #{params[:request][:destination_url]}!"
raise e unless e.message.include? "already"
flash[:notice] = "#{e.message} #{params[:request][:destination_url]}"
respond_with :location => aspect
return
end

View file

@ -4,7 +4,6 @@
module ApplicationHelper
def current_aspect?(aspect)
!@aspect.is_a?(Symbol) && @aspect.id == aspect.id
end
@ -68,5 +67,4 @@ module ApplicationHelper
def post_yield_tag(post)
(':' + post.id.to_s).to_sym
end
end

View file

@ -4,8 +4,7 @@
module DashboardsHelper
def title_for_page
'home'
'home'
end
end

View file

@ -4,7 +4,6 @@
module PhotosHelper
def linked_scaled_photo(photo, album)
link_to (image_tag photo.url(:scaled_full)), photo_path(album.next_photo(photo)), :rel => "prefetch"
end

View file

@ -9,7 +9,6 @@ module PublicsHelper
subscriber ||= Subscriber.new(:url => opts[:callback], :topic => opts[:topic])
if subscriber.save
if opts[:verify] == 'sync'
204
elsif opts[:verify] == 'async'

View file

@ -4,7 +4,6 @@
module RequestsHelper
def subscription_mode(profile)
if diaspora?(profile)
:friend
@ -33,12 +32,10 @@ module RequestsHelper
def relationship_flow(identifier)
action = :none
person = nil
puts identifier
person = Person.by_webfinger identifier
if person
action = (person == current_user.person ? :none : :friend)
end
{ action => person }
end
end

View file

@ -33,7 +33,4 @@ module SocketsHelper
action_hash.to_json
end
end

View file

@ -104,8 +104,8 @@ class Person
return nil unless public_key_entry
public_key = public_key_entry.first.href
new_person.exported_key = Base64.decode64 public_key
pubkey = public_key_entry.first.href
new_person.exported_key = Base64.decode64 pubkey
guid = profile.links.select{|x| x.rel == 'http://joindiaspora.com/guid'}.first.href
new_person.id = guid

View file

@ -5,12 +5,14 @@
require 'lib/diaspora/user/friending.rb'
require 'lib/diaspora/user/querying.rb'
require 'lib/diaspora/user/receiving.rb'
require 'lib/salmon/salmon'
class User
include MongoMapper::Document
include Diaspora::UserModules::Friending
include Diaspora::UserModules::Querying
include Diaspora::UserModules::Receiving
include Encryptor::Private
QUEUE = MessageHandler.new
@ -23,8 +25,6 @@ class User
key :visible_post_ids, Array
key :visible_person_ids, Array
key :url, String
one :person, :class_name => 'Person', :foreign_key => :owner_id
many :friends, :in => :friend_ids, :class_name => 'Person'
@ -95,7 +95,6 @@ class User
######## Posting ########
def post(class_name, options = {})
if class_name == :photo
raise ArgumentError.new("No album_id given") unless options[:album_id]
aspect_ids = aspects_with_post( options[:album_id] )
@ -104,20 +103,41 @@ class User
aspect_ids = options.delete(:to)
end
aspect_ids = [aspect_ids.to_s] if aspect_ids.is_a? BSON::ObjectId
aspect_ids = validate_aspect_permissions(aspect_ids)
raise ArgumentError.new("You must post to someone.") if aspect_ids.nil? || aspect_ids.empty?
aspect_ids.each{ |aspect_id|
raise ArgumentError.new("Cannot post to an aspect you do not own.") unless self.aspects.find(aspect_id) }
intitial_post(class_name, aspect_ids, options)
end
def intitial_post(class_name, aspect_ids, options = {})
post = build_post(class_name, options)
post.socket_to_uid(id, :aspect_ids => aspect_ids) if post.respond_to?(:socket_to_uid)
push_to_aspects(post, aspect_ids)
post
end
def repost( post, options = {} )
aspect_ids = validate_aspect_permissions(options[:to])
push_to_aspects(post, aspect_ids)
post
end
def validate_aspect_permissions(aspect_ids)
aspect_ids = [aspect_ids.to_s] if aspect_ids.is_a? BSON::ObjectId
if aspect_ids.nil? || aspect_ids.empty?
raise ArgumentError.new("You must post to someone.")
end
aspect_ids.each do |aspect_id|
unless aspect_id == "all" || self.aspects.find(aspect_id)
raise ArgumentError.new("Cannot post to an aspect you do not own.")
end
end
aspect_ids
end
def build_post( class_name, options = {})
options[:person] = self.person
model_class = class_name.to_s.camelize.constantize
@ -220,86 +240,10 @@ class User
end
end
###### Receiving #######
def receive_salmon ciphertext
cleartext = decrypt( ciphertext)
salmon = Salmon::SalmonSlap.parse cleartext
if salmon.verified_for_key?(salmon.author.public_key)
Rails.logger.info("data in salmon: #{salmon.data}")
self.receive(salmon.data)
end
end
def receive xml
object = Diaspora::Parser.from_xml(xml)
Rails.logger.debug("Receiving object for #{self.real_name}:\n#{object.inspect}")
Rails.logger.debug("From: #{object.person.inspect}") if object.person
if object.is_a? Retraction
if object.type == 'Person'
Rails.logger.info( "the person id is #{object.post_id} the friend found is #{visible_person_by_id(object.post_id).inspect}")
unfriended_by visible_person_by_id(object.post_id)
else
object.perform self.id
aspects = self.aspects_with_person(object.person)
aspects.each{ |aspect| aspect.post_ids.delete(object.post_id.to_id)
aspect.save
}
end
elsif object.is_a? Request
person = Diaspora::Parser.parse_or_find_person_from_xml( xml )
person.serialized_key ||= object.exported_key
object.person = person
object.person.save
old_request = Request.first(:id => object.id)
object.aspect_id = old_request.aspect_id if old_request
object.save
receive_friend_request(object)
elsif object.is_a? Profile
person = Diaspora::Parser.owner_id_from_xml xml
person.profile = object
person.save
elsif object.is_a?(Comment)
object.person = Diaspora::Parser.parse_or_find_person_from_xml( xml ).save if object.person.nil?
self.visible_people = self.visible_people | [object.person]
self.save
Rails.logger.debug("The person parsed from comment xml is #{object.person.inspect}") unless object.person.nil?
object.person.save
Rails.logger.debug("From: #{object.person.inspect}") if object.person
raise "In receive for #{self.real_name}, signature was not valid on: #{object.inspect}" unless object.post.person == self.person || object.verify_post_creator_signature
object.save
unless owns?(object)
dispatch_comment object
end
object.socket_to_uid(id) if (object.respond_to?(:socket_to_uid) && !self.owns?(object))
else
Rails.logger.debug("Saving object: #{object}")
object.user_refs += 1
object.save
self.raw_visible_posts << object
self.save
aspects = self.aspects_with_person(object.person)
aspects.each{ |aspect|
aspect.posts << object
aspect.save
object.socket_to_uid(id, :aspect_ids => [aspect.id]) if (object.respond_to?(:socket_to_uid) && !self.owns?(object))
}
end
end
###Helpers############
def self.instantiate!( opts = {} )
hostname = opts[:url].gsub(/(https?:|www\.)\/\//, '')
hostname.chop! if hostname[-1, 1] == '/'
opts[:person][:diaspora_handle] = "#{opts[:username]}@#{hostname}"
puts opts[:person][:diaspora_handle]
opts[:person][:diaspora_handle] = "#{opts[:username]}@#{APP_CONFIG[:terse_pod_url]}"
opts[:person][:url] = APP_CONFIG[:pod_url]
opts[:person][:serialized_key] = generate_key
User.create(opts)
end
@ -310,7 +254,7 @@ else
end
def terse_url
terse = self.url.gsub(/(https?:|www\.)\/\//, '')
terse = APP_CONFIG[:pod_url].gsub(/(https?:|www\.)\/\//, '')
terse = terse.chop! if terse[-1, 1] == '/'
terse
end

View file

@ -7,6 +7,6 @@
= person_image_tag(post.person)
%span.from
= link_to post.person.real_name, post.person
= auto_link sanitize post.text
= post.text
%div.time
= "#{time_ago_in_words(post.updated_at)} #{t('.ago')}"

View file

@ -10,7 +10,7 @@
= f.label :username
= f.text_field :username
%p.user_network
="@#{request.host}"
="@#{APP_CONFIG[:pod_url]}"
%p
= f.label :password

View file

@ -2,7 +2,6 @@
= form_for(resource, :as => resource_name, :url => registration_path(resource_name)) do |f|
= f.hidden_field :url, :value => request.host
%p
= f.label :username
= f.text_field :username
@ -17,8 +16,6 @@
= f.password_field :password_confirmation
= f.fields_for :person do |p|
= p.hidden_field :url, :value => request.host
= p.fields_for :profile do |pr|
%p
= pr.label :first_name

View file

@ -10,7 +10,7 @@
.content
%span.from
= link_to post.person.real_name, post.person
= auto_link sanitize post.message
= post.message
.info
%span.time= link_to(how_long_ago(post), object_path(post))

View file

@ -3,20 +3,14 @@
-# the COPYRIGHT file.
- title "Status Message"
%p
%strong Message:
= auto_link sanitize @status_message.message
%h1
= link_to @status_message.person.real_name, @status_message.person
= @status_message.message
%p
%strong Owner:
= @status_message.person.real_name
%h4= "comments (#{@status_message.comments.count})"
= render "comments/comments", :post => @status_message
%p
= link_to "Destroy", @status_message, :confirm => 'Are you sure?', :method => :delete
|
= link_to "View All", status_messages_path
- if current_user.owns? @status_message
= link_to "Destroy", @status_message, :confirm => 'Are you sure?', :method => :delete

View file

@ -17,11 +17,11 @@
%h3 Picture
%div#image_picker
= p.hidden_field :image_url, :value => (@profile.image_url.sub(@user.url,'/') if @profile.image_url), :id => 'image_url_field'
= p.hidden_field :image_url, :value => (@profile.image_url if @profile.image_url), :id => 'image_url_field'
- unless @photos.nil? || @photos.empty?
- for photo in @photos
- if @profile.image_url && (photo.url(:thumb_medium) == @profile.image_url.sub(@user.url,'/'))
- if @profile.image_url && @profile.image_url.include?(photo.url(:thumb_medium))
%div.small_photo{:id => photo.url(:thumb_medium), :class=>'selected'}
= check_box_tag 'checked_photo', true, true
= link_to image_tag(photo.url(:thumb_medium)), "#"

View file

@ -3,8 +3,8 @@
# the COPYRIGHT file.
development:
default:
pod_url: "http://example.org/"
debug: false
socket_debug : false
socket_host: 0.0.0.0
@ -13,21 +13,11 @@ development:
pubsub_server: 'https://pubsubhubbub.appspot.com/'
mongo_host: 'localhost'
mongo_post: 27017
development:
test:
debug: false
socket_debug : false
socket_host: 0.0.0.0
pod_url: "http://example.org/"
socket_port: 8081
pubsub_server: 'https://pubsubhubbub.appspot.com/'
mongo_host: 'localhost'
mongo_post: 27017
production:
debug: false
socket_debug : false
socket_host: 0.0.0.0
socket_port: 8080
pubsub_server: 'https://pubsubhubbub.appspot.com/'
mongo_host: 'localhost'
mongo_post: 27017

View file

@ -51,5 +51,6 @@ module Diaspora
# Configure sensitive parameters which will be filtered from the log file.
config.filter_parameters += [:password]
config.filter_parameters += [:xml]
end
end

View file

@ -53,6 +53,11 @@ namespace :deploy do
run "ln -s -f #{shared_path}/bundle #{current_path}/vendor/bundle"
end
task :symlink_config do
run "touch #{shared_path}/app_config.yml"
run "ln -s -f #{shared_path}/app_config.yml #{current_path}/config/app_config.yml"
end
task :start do
start_mongo
start_thin
@ -150,4 +155,4 @@ namespace :db do
end
after "deploy:symlink", "deploy:symlink_images", "deploy:symlink_bundle"
after "deploy:symlink", "deploy:symlink_images", "deploy:symlink_bundle", 'deploy:symlink_config'

View file

@ -2,6 +2,25 @@
# licensed under the Affero General Public License version 3. See
# the COPYRIGHT file.
def load_config_yaml filename
YAML.load(File.read(filename))
end
raw_config = File.read("#{Rails.root}/config/app_config.yml")
APP_CONFIG = YAML.load(raw_config)[Rails.env].symbolize_keys
if File.exist? "#{Rails.root}/config/app_config.yml"
all_envs = load_config_yaml "#{Rails.root}/config/app_config.yml"
all_envs = load_config_yaml "#{Rails.root}/config/app_config_example.yml" unless all_envs
else
puts "WARNING: No config/app_config.yml found! Look at config/app_config_example.yml for help."
all_envs = load_config_yaml "#{Rails.root}/config/app_config_example.yml"
end
if all_envs[Rails.env.to_s]
APP_CONFIG = all_envs['default'].merge(all_envs[Rails.env.to_s]).symbolize_keys
else
APP_CONFIG = all_envs['default'].symbolize_keys
end
APP_CONFIG[:terse_pod_url] = APP_CONFIG[:pod_url].gsub(/(https?:|www\.)\/\//, '')
APP_CONFIG[:terse_pod_url].chop! if APP_CONFIG[:terse_pod_url][-1, 1] == '/'
puts "WARNING: Please modify your app_config.yml to have a proper pod_url!" if APP_CONFIG[:terse_pod_url] == "example.org" && Rails.env != :test

View file

@ -7,4 +7,137 @@
# See http://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points.
pt-BR:
hello: "Olá Mundo"
hello: "Olá mundo"
layouts:
application:
edit_profile: "editar perfil"
logout: "sair"
shared:
aspect_nav:
all_aspects: "Todos Aspectos"
manage: "Gerenciar"
manage_your_aspects: "Gerencie seus Aspectos"
sub_header:
all_aspects: "Todos Aspectos"
manage_aspects: "Gerenciar Aspectos"
publisher:
share: "Compartilhar"
aspect_friends:
add_friends: "adicionar amigos"
albums:
album:
you: "você"
new_album:
create: "criar"
add_a_new_album: "Adicionar novo álbum"
show:
edit_album: "Editar Álbum"
albums: "álbuns"
updated: "atualizado"
by: "por"
edit:
editing: "Editando"
updated: "atualizado"
are_you_sure: "Tem certeza?"
delete_album: "Excluir Álbum"
cancel: "Cancelar"
index:
home: "home"
new_album: "Novo Álbum"
create:
success: "Você criou com sucesso um álbum chamado %{name}."
update:
success: "O álbum %{name} foi editado com sucesso."
failure: "Erro ao editar o álbum %{name}."
destroy:
success: "O álbum %{name} foi excluído com sucesso."
aspects:
index:
photos: "photos"
show:
photos: "photos"
manage:
add_a_new_aspect: "Adicionar um novo aspecto"
add_a_new_friend: "Adicionar um novo amigo"
show: "Exibir"
update_aspects: "Atualizar Aspectos"
requests: "Solicitações"
ignore_remove: "Ignorar/Excluir"
new_aspect:
add_a_new_aspect: "Adicionar um novo aspecto"
create: "Criar"
create:
success:"Clique no mais(+) do lado esquerdo para dizer ao Diaspora quem pode ver seu novo aspecto."
users:
edit:
cancel: "Cancelar"
update_profile: "Atualizar Perfil"
home: "Home"
diaspora_username: "USUÁRIO DIASPORA"
info: "Informações"
picture: "Imagem"
editing_profile: "Editando perfil"
albums: "Álbuns"
you_dont_have_any_photos: "Você não possui nenhuma photo! Vá para"
page_to_upload_some: "para fazer o upload de alguma."
comments:
comment:
ago: "atrás"
new_comment:
comment: "Comentário"
photos:
show:
prev: "anterior"
full_size: "tamanho máximo"
next: "próxima"
edit_photo: "Editar Foto"
delete_photo: "Excluir Foto"
are_you_sure: "Tem certeza?"
comments: "comentários"
edit:
editing: "Editando"
are_you_sure: "Tem certeza?"
delete_photo: "Excluir Foto"
photo:
show_comments: "exibir comentários"
posted_a_new_photo_to: "enviada um nova foto para"
new:
new_photo: "Nova Foto"
back_to_list: "Voltar para a Lista"
post_it: "enviar!"
registrations:
new:
sign_up: "Cadastro"
status_messages:
new_status_message:
tell_me_something_good: "diga-me qualquer coisa legal"
oh_yeah: "É isso aí!"
status_message:
show_comments: "exibir comentários"
delete: "Excluir"
are_you_sure: "Tem certeza?"
show:
status_message: "Mensagem de Status"
comments: "comentários"
are_you_sure: "Tem certeza?"
destroy: "Excluir"
view_all: "Exibir Todas"
message: "Mensagem"
owner: "Pertence a"
people:
index:
add_friend: "adicionar amigo(a)"
real_name: "nome real"
diaspora_handle: "diaspora handle"
thats_you: "esse é você!"
friend_request_pending: "pedido de amizade pendente"
you_have_a_friend_request_from_this_person: "você possui um pedido de amizade dessa pessoa"
new:
new_person: "Nova Pessoa"
back_to_list: "Voltar para a Lista"
show:
last_seen: "visto pela última vez a: %{how_long_ago}"
friends_since: "amigos desde: %{how_long_ago}"
save: "salvar"
are_you_sure: "Tem certeza?"
remove_friend: "excluir amigo"

View file

@ -1,27 +0,0 @@
-----BEGIN RSA PRIVATE KEY-----
MIIEowIBAAKCAQEAvCyAkyAMbn+flqwLIEnPL08iY8dWpkel1wtXXjUtaINjuvZ7
2XwK7ntnVHVRm49t+QFMWh8SpxDHnJDgb3X6uYem2DzB6L8HtuFVFN5lOUi+TeiI
LJsBmiGHc1tQwGB0jqmCG0J2QBDpDiw//ktOJNlZJfnPGY+4viSXwWpYhhh1v3ij
Inmp0+lw7z0+TyklNGVEsr6emwkgo5t20ClAQDmwy1BeYBcmtAehF55V3aSPQt1d
+hCmwl11PR6BLuGYgRirr4Xyc/GmyZVKkz8dLv40X+/Bk2D7owO+N5hf74EB1e3r
7Vu7LAfUOdtOFQJV5SWr3HTPo5vvU1oqR4VViQIBIwKCAQEApqsSy3QoRJzsb4Jw
QStuXRo0ZwEDmpc7HY2zyHg+KV5uRoKK89REMlALEEqnXeVwCG7dOeEB5G3yoJ2T
lewnNpy4WR/e8rfTofrHs2XkoHOhPbCzIDGFE3zIbXzD3ZdCqj5dS1gfl9R2picx
XZMn9MCCKPMzxi7W1ExL5dM4dsOuPRvie+nYGWvvv/LXvFTLFXDVwGXOhfDkLocv
r6STaUMj7RzLJneawOg1YS1Ivsj+Db4Q+abB4mRRhOe6igYu9Zd0ve8XAjJAHbx2
Kzl5XKj8fhOSwXyLBh+enqHv0yLR7GaZn0odjNdUeWdD0kF9DnsL3VMa12wmNXtu
48bX3wKBgQDzPRDyYmBIKp/eStzAEmkVz98JmQQoX3tF0VrVdLK0j0nLB19jbHl8
poHaPG8qIgGfFMwdhLOJmJ6CXa4eHffLJ0c32Ow+jQ+Is70Ssn6WSq0962WuuoWA
ARUwhyO9BaWvzTnMCYDI+dSydM26cvDmTTuvCJDbifmAkArgWGqM4wKBgQDGC9za
VTqnfBHGBXebLk/PRA8YOD9CvRrIrjylUxeSrbScK9i6v+1WK3dZCl8j7H3yYJ3B
8CT38FXxrHtGIn+5XU++fAeiLrnmNlYFCsn1nLt2SUqvODYYefxm/Vq1LQaWknHV
itnZF1CIltLLMI2w2iVCA0xRqots6gX+SMarowKBgQC7pCMEIAEhuntTthgB4lEQ
047M48Fg+TM13AQ+RBTUboliG6FbU64s9XodYdIZMC0i8slYmZHQi616gsgl3JqV
Z3F0OaBNgsLXK5HbOT0U2oWky4j0gUJqD3a/CSoyuzasMJpM8WNZNcFWd1zgSgpL
QuTmHI0BIUtxzjRGqptWvQKBgGAxpckiFSzHO9U12wI7ENJi4sKe+ie678CPJMVU
PqZUXwoGqxjg4P332uIa+wLR9AgDCsvpq45eyqiVmvYuA4XrfoEXq++wS6pU5/PS
ClK512VWzID+C6V9FDIGB3ySNmZkYy000DY+hjO2+KvVwSoDjnCFQlONWanuAuk5
So3hAoGBALfkYFRtSilhvtjOnnil0hdyUbCcRmKeUYl2Yb/cb3JmUfi9xRur7K46
Okwba+mnOJQT0kefFEUwsP9UPVLgppVh+llyAal1aJ5OnXn1o996TGTfNmy1aThr
aaGeAU2u8GFBiBrz9tRwzZo8ixUEZZrGFFN/n53bDHpBsbhRvHGX
-----END RSA PRIVATE KEY-----

View file

@ -1 +0,0 @@
ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAvCyAkyAMbn+flqwLIEnPL08iY8dWpkel1wtXXjUtaINjuvZ72XwK7ntnVHVRm49t+QFMWh8SpxDHnJDgb3X6uYem2DzB6L8HtuFVFN5lOUi+TeiILJsBmiGHc1tQwGB0jqmCG0J2QBDpDiw//ktOJNlZJfnPGY+4viSXwWpYhhh1v3ijInmp0+lw7z0+TyklNGVEsr6emwkgo5t20ClAQDmwy1BeYBcmtAehF55V3aSPQt1d+hCmwl11PR6BLuGYgRirr4Xyc/GmyZVKkz8dLv40X+/Bk2D7owO+N5hf74EB1e3r7Vu7LAfUOdtOFQJV5SWr3HTPo5vvU1oqR4VViQ== Diaspora deploy key

View file

@ -1,2 +0,0 @@
|1|1DLdTjtEIabpLiLzhVOp7colQSQ=|/Nw4MuJAYIztcexQDWF3NQoEljs= ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAq2A7hRGmdnm9tUDbO9IDSwBK6TbQa+PXYPCPy6rbTrTtw7PHkccKrpp0yVhp5HdEIcKr6pLlVDBfOLX9QUsyCOV0wzfjIJNlGEYsdlLJizHhbn2mUjvSAHQqZETYP81eFzLQNnPHt4EVVUh7VfDESU84KezmD5QlWpXLmvU31/yMf+Se8xhHTvKSCZIFImWwoG6mbUoWf9nzpIoaSjB+weqqUUmpaaasXVal72J+UX2B+2RPW3RcT0eOzQgqlJL3RKrTJvdsjE3JEAvGq3lGHSZXy28G3skua2SmVi/w4yCE6gbODqnTWlg7+wC604ydGXA8VJiS5ap43JXiUFFAaQ==
|1|j1rKwLcrA2MgHhcpdVf04ig02Hs=|Y4Jl+8HpsTyFlhSwoVxSVeRsf3k= ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAq2A7hRGmdnm9tUDbO9IDSwBK6TbQa+PXYPCPy6rbTrTtw7PHkccKrpp0yVhp5HdEIcKr6pLlVDBfOLX9QUsyCOV0wzfjIJNlGEYsdlLJizHhbn2mUjvSAHQqZETYP81eFzLQNnPHt4EVVUh7VfDESU84KezmD5QlWpXLmvU31/yMf+Se8xhHTvKSCZIFImWwoG6mbUoWf9nzpIoaSjB+weqqUUmpaaasXVal72J+UX2B+2RPW3RcT0eOzQgqlJL3RKrTJvdsjE3JEAvGq3lGHSZXy28G3skua2SmVi/w4yCE6gbODqnTWlg7+wC604ydGXA8VJiS5ap43JXiUFFAaQ==

View file

@ -15,25 +15,38 @@
require 'config/environment'
def create
config = YAML.load_file(File.dirname(__FILE__) + '/../../config/deploy_config.yml')
backer_info = config['servers']['backer']
backer_number = YAML.load_file(Rails.root.join('config','backer_number.yml'))[:seed_number].to_i
# Create seed user
#set pod url
username = backer_info[backer_number]['username'].gsub(/ /,'').downcase
set_app_config username
require 'config/initializers/_load_app_config.rb'
# Create seed user
user = User.instantiate!(:email => "#{username}@#{username}.joindiaspora.com",
:username => username,
:password => "#{username+backer_info[backer_number]['pin'].to_s}",
:password_confirmation => "#{username+backer_info[backer_number]['pin'].to_s}",
:url=> "http://#{username}.joindiaspora.com/",
:person => Person.new(
:diaspora_handle => "#{username}@#{username}.joindiaspora.com",
:profile => Profile.new( :first_name => backer_info[backer_number]['given_name'], :last_name => backer_info[backer_number]['family_name'],
:image_url => "http://#{username}.joindiaspora.com/images/user/#{username}.jpg"),
:url=> "http://#{username}.joindiaspora.com/")
)
:image_url => "http://#{username}.joindiaspora.com/images/user/#{username}.jpg")
))
user.person.save!
user.aspect(:name => "Presidents")
end
def set_app_config username
current_config = YAML.load(File.read(Rails.root.join('config', 'app_config_example.yml')))
current_config[Rails.env.to_s] ||= {}
current_config[Rails.env.to_s]['pod_url'] = "#{username}.joindiaspora.com"
current_config['default']['pod_url'] = "#{username}.joindiaspora.com"
file = File.new(Rails.root.join('..','..','shared','app_config.yml'),'w')
file.write(current_config.to_yaml)
file.close
end

View file

@ -6,31 +6,35 @@
require 'config/environment'
host = "localhost:3000"
url = "http://#{host}/"
def set_app_config username
current_config = YAML.load(File.read(Rails.root.join('config', 'app_config_example.yml')))
current_config[Rails.env.to_s] ||= {}
current_config[Rails.env.to_s]['pod_url'] = "#{username}.joindiaspora.com"
current_config['default']['pod_url'] = "#{username}.joindiaspora.com"
file = File.new(Rails.root.join('config','app_config.yml'),'w')
file.write(current_config.to_yaml)
file.close
end
username = "tom"
set_app_config username
# Create seed user
user = User.instantiate!( :email => "tom@tom.joindiaspora.com",
:username => "tom",
:password => "evankorth",
:password_confirmation => "evankorth",
:url=> "http://#{username}.joindiaspora.com/"
:person => Person.new(
:diaspora_handle => "tom@tom.joindiaspora.com",
:url => url,
:profile => Profile.new( :first_name => "Alexander", :last_name => "Hamiltom" ))
)
user.person.save!
user2 = User.instantiate!( :email => "korth@tom.joindiaspora.com",
:username => "korth",
:url=> "http://#{username}.joindiaspora.com/"
:password => "evankorth",
:password_confirmation => "evankorth",
:person => Person.new( :diaspora_handle => "korth@tom.joindiaspora.com",
:url => url,
:profile => Profile.new( :first_name => "Evan",
:last_name => "Korth")))
:person => Person.new(
:profile => Profile.new( :first_name => "Evan", :last_name => "Korth")))
user2.person.save!

View file

@ -6,17 +6,26 @@
require 'config/environment'
remote_url = "http://tom.joindiaspora.com/"
#remote_url = "http://localhost:3000/"
def set_app_config username
current_config = YAML.load(File.read(Rails.root.join('config', 'app_config_example.yml')))
current_config[Rails.env.to_s] ||= {}
current_config[Rails.env.to_s]['pod_url'] = "#{username}.joindiaspora.com"
current_config['default']['pod_url'] = "#{username}.joindiaspora.com"
file = File.new(Rails.root.join('..','..','shared','app_config.yml'),'w')
file.write(current_config.to_yaml)
file.close
end
set_app_config "tom"
require 'config/initializers/_load_app_config.rb'
# Create seed user
user = User.instantiate!( :email => "tom@tom.joindiaspora.com",
:username => "tom",
:password => "evankorth",
:password_confirmation => "evankorth",
:url => remote_url,
:person => {
:diaspora_handle => "tom@tom.joindiaspora.com",
:url => remote_url,
:profile => { :first_name => "Alexander", :last_name => "Hamiltom",
:image_url => "http://tom.joindiaspora.com/images/user/tom.jpg"}}
)
@ -26,11 +35,7 @@ user2 = User.instantiate!( :email => "korth@tom.joindiaspora.com",
:password => "evankorth",
:password_confirmation => "evankorth",
:username => "korth",
:url => remote_url,
:person => { :diaspora_handle => "korth@tom.joindiaspora.com",
:url => remote_url,
:profile => { :first_name => "Evan",
:last_name => "Korth",
:person => {:profile => { :first_name => "Evan", :last_name => "Korth",
:image_url => "http://tom.joindiaspora.com/images/user/korth.jpg"}})
user2.person.save!
@ -41,3 +46,5 @@ request = user.send_friend_request_to(user2, aspect)
reversed_request = user2.accept_friend_request( request.id, user2.aspect(:name => "presidents").id )
user.receive reversed_request.to_diaspora_xml
user.aspect(:name => "Presidents")

View file

@ -8,6 +8,9 @@ module Diaspora
module UserModules
module Friending
def send_friend_request_to(desired_friend, aspect)
# should have different exception types for these?
raise "You have already sent a friend request to that person!" if self.pending_requests.detect{
|x| x.destination_url == desired_friend.receive_url }
raise "You are already friends with that person!" if self.friends.detect{
|x| x.receive_url == desired_friend.receive_url}
request = Request.instantiate(

View file

@ -31,12 +31,8 @@ module Diaspora
end
def aspect_by_id( id )
self.aspects.find( id )
end
def album_by_id( id )
id = id.to_id
albums.detect{|x| x.id == id }
aspects.detect{|x| x.id == id }
end
def aspects_with_post( id )

View file

@ -0,0 +1,93 @@
module Diaspora
module UserModules
module Receiving
def receive_salmon ciphertext
cleartext = decrypt( ciphertext)
salmon = Salmon::SalmonSlap.parse cleartext
if salmon.verified_for_key?(salmon.author.public_key)
Rails.logger.info("data in salmon: #{salmon.data}")
self.receive(salmon.data)
end
end
def receive xml
object = Diaspora::Parser.from_xml(xml)
Rails.logger.debug("Receiving object for #{self.real_name}:\n#{object.inspect}")
Rails.logger.debug("From: #{object.person.inspect}") if object.person
if object.is_a? Retraction
receive_retraction object, xml
elsif object.is_a? Request
receive_request object, xml
elsif object.is_a? Profile
receive_profile object, xml
elsif object.is_a?(Comment)
receive_comment object, xml
else
receive_post object, xml
end
end
def receive_retraction retraction, xml
if retraction.type == 'Person'
Rails.logger.info( "the person id is #{retraction.post_id} the friend found is #{visible_person_by_id(retraction.post_id).inspect}")
unfriended_by visible_person_by_id(retraction.post_id)
else
retraction.perform self.id
aspects = self.aspects_with_person(retraction.person)
aspects.each{ |aspect| aspect.post_ids.delete(retraction.post_id.to_id)
aspect.save
}
end
end
def receive_request request, xml
person = Diaspora::Parser.parse_or_find_person_from_xml( xml )
person.serialized_key ||= request.exported_key
request.person = person
request.person.save
old_request = Request.first(:id => request.id)
request.aspect_id = old_request.aspect_id if old_request
request.save
receive_friend_request(request)
end
def receive_profile profile, xml
person = Diaspora::Parser.owner_id_from_xml xml
person.profile = profile
person.save
end
def receive_comment comment, xml
comment.person = Diaspora::Parser.parse_or_find_person_from_xml( xml ).save if comment.person.nil?
self.visible_people = self.visible_people | [comment.person]
self.save
Rails.logger.debug("The person parsed from comment xml is #{comment.person.inspect}") unless comment.person.nil?
comment.person.save
Rails.logger.debug("From: #{comment.person.inspect}") if comment.person
raise "In receive for #{self.real_name}, signature was not valid on: #{comment.inspect}" unless comment.post.person == self.person || comment.verify_post_creator_signature
comment.save
unless owns?(comment)
dispatch_comment comment
end
comment.socket_to_uid(id) if (comment.respond_to?(:socket_to_uid) && !self.owns?(comment))
end
def receive_post post, xml
Rails.logger.debug("Saving post: #{post}")
post.user_refs += 1
post.save
self.raw_visible_posts << post
self.save
aspects = self.aspects_with_person(post.person)
aspects.each{ |aspect|
aspect.posts << post
aspect.save
post.socket_to_uid(id, :aspect_ids => [aspect.id]) if (post.respond_to?(:socket_to_uid) && !self.owns?(post))
}
end
end
end
end

View file

@ -31,7 +31,7 @@ class MessageHandler
http.callback { process; process}
when :get
http = EventMachine::HttpRequest.new(query.destination).get :timeout => TIMEOUT
http.callback {send_to_seed(query, http.response); process}
http.callback {process}
else
raise "message is not a type I know!"
end
@ -47,10 +47,6 @@ class MessageHandler
} unless @queue.size == 0
end
def send_to_seed(message, http_response)
#DO SOMETHING!
end
def size
@queue.size
end

View file

@ -47,7 +47,7 @@ $(function() {
var dropzone = $(this)[0];
if ($(this)[0].id == ui.draggable[0].getAttribute('from_aspect_id')){
ui.draggable.css('background-color','#eee');
ui.draggable.css('background','none');
} else {
ui.draggable.css('background-color','orange');
$.ajax({
@ -61,7 +61,6 @@ $(function() {
}});
}
}
$(this).closest("ul").append(ui.draggable);
}
});

View file

@ -346,12 +346,18 @@ label {
margin-top: 26px; }
#publisher textarea {
width: 600px;
height: 40px;
height: 42px;
margin-top: 0;
margin-bottom: 0;
-webkit-box-shadow: 0 1px 0 white; }
box-shadow: 0 1px white;
-moz-box-shadow: 0 1px white;
-webkit-box-shadow: 0 1px white; }
#publisher .button {
margin-left: 100px; }
#publisher img {
-webkit-box-shadow: 0 1px 0 white;
border: 1px solid #bbbbbb;
border-top: 1px solid #666666; }
#image_picker .small_photo {
height: 100px;
@ -463,6 +469,7 @@ h1.big_text {
display: inline;
margin-right: 2px; }
#aspect_nav ul > li a {
text-shadow: 0 2px 0 #444444;
-webkit-border-radius: 3px 3px 0 0;
-moz-border-radius: 3px 3px 0 0;
line-height: 22px;
@ -557,7 +564,8 @@ h1.big_text {
.requests .grey,
.remove .grey {
color: #999999;
cursor: default; }
cursor: default;
text-shadow: 0 2px white; }
.aspect ul.dropzone,
.requests ul.dropzone,
.remove ul.dropzone {

View file

@ -3,14 +3,14 @@
.qq-upload-button {
display:block; /* or inline-block */
width: 105px; padding: 7px 0; text-align:center;
background:#880000; border-bottom:1px solid #ddd;color:#fff;
background:#333; border-bottom:1px solid #999;color:#fff;
}
.qq-upload-button-hover {background:#cc0000;}
.qq-upload-button-hover {background:#666;}
.qq-upload-button-focus {outline:1px dotted black;}
.qq-upload-drop-area {
position:absolute; top:0; left:0; width:100%; height:100%; min-height: 70px; z-index:2;
background:#FF9797; text-align:center;
background:#ccc; text-align:center;
}
.qq-upload-drop-area span {
display:block; position:absolute; top: 50%; width:100%; margin-top:-8px; font-size:16px;
@ -28,4 +28,4 @@
.qq-upload-size,.qq-upload-cancel {font-size:11px;}
.qq-upload-failed-text {display:none;}
.qq-upload-fail .qq-upload-failed-text {display:inline;}
.qq-upload-fail .qq-upload-failed-text {display:inline;}

View file

@ -453,16 +453,24 @@ label
textarea
:width 600px
:height 40px
:height 42px
:margin
:top 0
:bottom 0
:-webkit-box-shadow 0 1px 0 #fff
:box-shadow 0 1px #fff
:-moz-box-shadow 0 1px #fff
:-webkit-box-shadow 0 1px #fff
.button
:margin-left 100px
img
:-webkit-box-shadow 0 1px 0 #fff
:border 1px solid #bbb
:top 1px solid #666
#image_picker
.small_photo
@ -613,6 +621,7 @@ h1.big_text
:right 2px
a
:text-shadow 0 2px 0 #444
:-webkit-border-radius 3px 3px 0 0
:-moz-border-radius 3px 3px 0 0
:line
@ -705,8 +714,6 @@ h1.big_text
:display inline
.aspect_name
:position relative
@ -731,6 +738,7 @@ h1.big_text
.grey
:color #999
:cursor default
:text-shadow 0 2px #fff
ul.dropzone
:min-height 20px

View file

@ -39,7 +39,10 @@ Factory.define :user do |u|
u.sequence(:email) {|n| "bob#{n}@pivotallabs.com"}
u.password "bluepin7"
u.password_confirmation "bluepin7"
u.person { |a| Factory.create(:person_with_user, :owner_id => a._id)}
u.person { |a| Factory.create(:person_with_user,
:owner_id => a._id,
:diaspora_handle => "#{a.username}@#{APP_CONFIG[:pod_url].gsub(/(https?:|www\.)\/\//, '').chop!}")
}
end
Factory.define :status_message do |m|

View file

@ -123,7 +123,6 @@ describe MessageHandler do
request = FakeHttpRequest.new(:success)
request.should_receive(:get).exactly(1).times.and_return(request)
request.should_receive(:post).exactly(1).times.and_return(request)
@handler.should_receive(:send_to_seed).once
EventMachine::HttpRequest.stub!(:new).and_return(request)

View file

@ -15,6 +15,20 @@ describe Person do
@aspect2 = @user2.aspect(:name => "Abscence of Babes")
end
describe '#diaspora_handle' do
context 'local people' do
it 'uses the pod config url to set the diaspora_handle' do
@user.person.diaspora_handle.should == @user.username + "@example.org"
end
end
context 'remote people' do
it 'stores the diaspora_handle in the database' do
@person.diaspora_handle.include?(@user.terse_url).should be false
end
end
end
it 'should not allow two people with the same diaspora_handle' do
person_two = Factory.build(:person, :url => @person.diaspora_handle)
person_two.valid?.should == false
@ -148,13 +162,11 @@ describe Person do
end
it 'should search by diaspora_handle exactly' do
stub_success("tom@tom.joindiaspora.com")
Person.by_webfinger(@friend_one.diaspora_handle).should == @friend_one
end
it 'should create a stub for a remote user' do
stub_success("tom@tom.joindiaspora.com")
tom = Person.by_webfinger('tom@tom.joindiaspora.com')
tom.real_name.include?("Hamiltom").should be true

View file

@ -7,65 +7,85 @@
require File.dirname(__FILE__) + '/../../spec_helper'
describe User do
before do
@user = Factory.create :user
@aspect = @user.aspect(:name => 'heroes')
@aspect1 = @user.aspect(:name => 'heroes')
@user2 = Factory.create(:user)
@aspect2 = @user2.aspect(:name => 'losers')
let(:user) { Factory(:user) }
let(:user2) { Factory(:user) }
let(:user3) { Factory(:user) }
let(:user4) { Factory(:user) }
@user3 = Factory.create(:user)
@aspect3 = @user3.aspect(:name => 'heroes')
let(:aspect) {user.aspect(:name => 'heroes')}
let!(:aspect1) {user.aspect(:name => 'heroes')}
let!(:aspect2) {user2.aspect(:name => 'losers')}
let!(:aspect3) {user3.aspect(:name => 'heroes')}
let!(:aspect4) {user4.aspect(:name => 'heroes')}
@user4 = Factory.create(:user)
@aspect4 = @user4.aspect(:name => 'heroes')
friend_users(@user, @aspect, @user2, @aspect2)
friend_users(@user, @aspect, @user3, @aspect3)
friend_users(@user, @aspect1, @user4, @aspect4)
end
it 'should not be able to post without a aspect' do
proc {@user.post(:status_message, :message => "heyheyhey")}.should raise_error /You must post to someone/
before do
friend_users(user, aspect, user2, aspect2)
friend_users(user, aspect, user3, aspect3)
friend_users(user, aspect1, user4, aspect4)
end
it 'should not be able to post to someone elses aspect' do
proc {@user.post(:status_message, :message => "heyheyhey", :to => @aspect2.id)}.should raise_error /Cannot post to an aspect you do not own./
end
it 'should put the post in the aspect post array' do
post = @user.post(:status_message, :message => "hey", :to => @aspect.id)
@aspect.reload
@aspect.post_ids.include?(post.id).should be true
context 'posting' do
describe '#validate_aspect_permissions' do
it 'should not be able to post without a aspect' do
proc {
user.validate_aspect_permissions([])
}.should raise_error /You must post to someone/
end
it 'should not be able to post to someone elses aspect' do
proc {
user.validate_aspect_permissions(aspect2.id)
}.should raise_error /Cannot post to an aspect you do not own./
end
end
describe '#post' do
it 'should put the post in the aspect post array' do
post = user.post(:status_message, :message => "hey", :to => aspect.id)
aspect.reload
aspect.posts.should include post
end
it 'should put an album in the aspect post array' do
album = user.post :album, :name => "Georges", :to => aspect.id
aspect.reload
aspect.posts.should include album
end
end
describe '#repost' do
let!(:status_message) { user.post(:status_message, :message => "hello", :to => aspect.id) }
it 'should make the post visible in another aspect' do
user.repost( status_message, :to => aspect1.id )
aspect1.reload
aspect1.posts.count.should be 1
end
end
end
it 'should put an album in the aspect post array' do
album = @user.post :album, :name => "Georges", :to => @aspect.id
@aspect.reload
@aspect.post_ids.include?(album.id).should be true
@aspect.posts.include?(album).should be true
end
context 'dispatching' do
let!(:post) { user.build_post :status_message, :message => "hey" }
describe 'dispatching' do
before do
@post = @user.build_post :status_message, :message => "hey"
end
it 'should push a post to a aspect' do
@user.should_receive(:salmon).twice
@user.push_to_aspects(@post, @aspect.id)
describe '#push_to_aspects' do
it 'should push a post to a aspect' do
user.should_receive(:salmon).twice
user.push_to_aspects(post, aspect.id)
end
it 'should push a post to all aspects' do
user.should_receive(:salmon).exactly(3).times
user.push_to_aspects(post, :all)
end
end
it 'should push a post to all aspects' do
@user.should_receive(:salmon).exactly(3).times
@user.push_to_aspects(@post, :all)
describe '#push_to_people' do
it 'should push to people' do
user.should_receive(:salmon).twice
user.push_to_people(post, [user2.person, user3.person])
end
end
it 'should push to people' do
@user.should_receive(:salmon).twice
@user.push_to_people(@post, [@user2.person, @user3.person])
end
end
end

View file

@ -7,83 +7,80 @@
require File.dirname(__FILE__) + '/../../spec_helper'
describe User do
before do
@user = Factory.create(:user)
@aspect = @user.aspect(:name => 'heroes')
@aspect2 = @user.aspect(:name => 'losers')
let(:user) { Factory(:user) }
@user2 = Factory.create :user
@user2_aspect = @user2.aspect(:name => 'dudes')
let(:user2) { Factory(:user) }
let(:user3) { Factory(:user) }
let(:user4) { Factory(:user) }
friend_users(@user, @aspect, @user2, @user2_aspect)
let!(:aspect) { user.aspect(:name => 'heroes') }
let!(:aspect2) { user.aspect(:name => 'losers') }
@user3 = Factory.create :user
@user3_aspect = @user3.aspect(:name => 'dudes')
friend_users(@user, @aspect2, @user3, @user3_aspect)
let!(:user2_aspect) { user2.aspect(:name => 'dudes') }
let!(:user3_aspect) { user3.aspect(:name => 'dudes') }
let!(:user4_aspect) { user4.aspect(:name => 'dudes') }
@user4 = Factory.create :user
@user4_aspect = @user4.aspect(:name => 'dudes')
friend_users(@user, @aspect2, @user4, @user4_aspect)
end
let(:status_message1) { user2.post :status_message, :message => "hi", :to => user2_aspect.id }
let(:status_message2) { user3.post :status_message, :message => "heyyyy", :to => user3_aspect.id }
let(:status_message3) { user4.post :status_message, :message => "yooo", :to => user4_aspect.id }
it 'should generate a valid stream for a aspect of people' do
status_message1 = @user2.post :status_message, :message => "hi", :to => @user2_aspect.id
status_message2 = @user3.post :status_message, :message => "heyyyy", :to => @user3_aspect.id
status_message3 = @user4.post :status_message, :message => "yooo", :to => @user4_aspect.id
before do
friend_users(user, aspect, user2, user2_aspect)
friend_users(user, aspect2, user3, user3_aspect)
friend_users(user, aspect2, user4, user4_aspect)
end
@user.receive status_message1.to_diaspora_xml
@user.receive status_message2.to_diaspora_xml
@user.receive status_message3.to_diaspora_xml
@user.reload
it 'should generate a valid stream for a aspect of people' do
(1..3).each{ |n|
eval("user.receive status_message#{n}.to_diaspora_xml")
}
@user.visible_posts(:by_members_of => @aspect).include?(status_message1).should be true
@user.visible_posts(:by_members_of => @aspect).include?(status_message2).should be false
@user.visible_posts(:by_members_of => @aspect).include?(status_message3).should be false
user.visible_posts(:by_members_of => aspect).should include status_message1
user.visible_posts(:by_members_of => aspect).should_not include status_message2
user.visible_posts(:by_members_of => aspect).should_not include status_message3
@user.visible_posts(:by_members_of => @aspect2).include?(status_message1).should be false
@user.visible_posts(:by_members_of => @aspect2).include?(status_message2).should be true
@user.visible_posts(:by_members_of => @aspect2).include?(status_message3).should be true
end
user.visible_posts(:by_members_of => aspect2).should_not include status_message1
user.visible_posts(:by_members_of => aspect2).should include status_message2
user.visible_posts(:by_members_of => aspect2).should include status_message3
end
describe 'querying' do
it 'should find a visible post by id' do
status_message1 = @user.post :status_message, :message => "hi", :to => @aspect.id
status_message2 = @user2.post :status_message, :message => "heyyyy", :to => @user2_aspect.id
status_message3 = @user3.post :status_message, :message => "yooo", :to => @user3_aspect.id
@user.find_visible_post_by_id(status_message1.id).should == status_message1
@user2.find_visible_post_by_id(status_message1.id).should == nil
end
end
describe 'albums' do
before do
@album = @user.post :album, :name => "Georges", :to => @aspect.id
@aspect.reload
@aspect2.reload
@user.reload
@album2 = @user.post :album, :name => "Borges", :to => @aspect.id
@aspect.reload
@aspect2.reload
@user.reload
@user.post :album, :name => "Luises", :to => @aspect2.id
@aspect.reload
@aspect2.reload
@user.reload
end
it 'should find all albums if passed :all' do
@user.albums_by_aspect(:all).size.should == 3
end
it 'should return the right number of albums' do
@user.albums_by_aspect(@aspect).size.should == 2
@user.albums_by_aspect(@aspect2).size.should == 1
context 'querying' do
describe '#find_visible_post_by_id' do
it 'should query' do
user2.find_visible_post_by_id(status_message1.id).should == status_message1
user.find_visible_post_by_id(status_message1.id).should == nil
end
end
end
context 'albums' do
before do
@album = user.post :album, :name => "Georges", :to => aspect.id
aspect.reload
aspect2.reload
user.reload
@album2 = user.post :album, :name => "Borges", :to => aspect.id
aspect.reload
aspect2.reload
user.reload
user.post :album, :name => "Luises", :to => aspect2.id
aspect.reload
aspect2.reload
user.reload
end
it 'should find all albums if passed :all' do
user.albums_by_aspect(:all).should have(3).albums
end
it 'should return the right number of albums' do
user.albums_by_aspect(aspect).should have(2).albums
user.albums_by_aspect(aspect2).should have(1).album
end
end
end

View file

@ -7,20 +7,19 @@
require File.dirname(__FILE__) + '/../spec_helper'
describe User do
before do
@user = Factory.create(:user)
@aspect = @user.aspect(:name => 'heroes')
end
it 'should create with pivotal or allowed emails' do
user1 = Factory.create(:user, :email => "kimfuh@yahoo.com")
user2 = Factory.create(:user, :email => "awesome@sofaer.net")
user3 = Factory.create(:user, :email => "steveellis@pivotallabs.com")
user1.created_at.nil?.should be false
user2.created_at.nil?.should be false
user3.created_at.nil?.should be false
before do
@user = Factory.create(:user)
@aspect = @user.aspect(:name => 'heroes')
end
describe '#diaspora_handle' do
it 'uses the pod config url to set the diaspora_handle' do
@user.diaspora_handle.should == @user.username + "@example.org"
end
end
describe 'profiles' do
it 'should be able to update their profile and send it to their friends' do
Factory.create(:person)
@ -49,13 +48,14 @@ describe User do
friend_users(@user, Aspect.find_by_id(@aspect.id), user2, Aspect.find_by_id(aspect2.id))
@aspect.reload
@user.aspects.include?(@aspect).should == true
proc{@user.drop_aspect(@aspect)}.should raise_error /Aspect not empty/
@user.reload
@user.reload
@user.aspects.include?(@aspect).should == true
end
end
end