Merge branch 'master' of http://github.com/diaspora/diaspora
This commit is contained in:
commit
aaa4d75a5e
13 changed files with 296 additions and 102 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -13,3 +13,4 @@ gpg/diaspora-production/*.gpg
|
||||||
gpg/*/random_seed
|
gpg/*/random_seed
|
||||||
public/uploads/*
|
public/uploads/*
|
||||||
.rvmrc
|
.rvmrc
|
||||||
|
config/app_config.yml
|
||||||
|
|
|
||||||
|
|
@ -103,20 +103,41 @@ class User
|
||||||
aspect_ids = options.delete(:to)
|
aspect_ids = options.delete(:to)
|
||||||
end
|
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?
|
intitial_post(class_name, aspect_ids, options)
|
||||||
aspect_ids.each{ |aspect_id|
|
end
|
||||||
raise ArgumentError.new("Cannot post to an aspect you do not own.") unless aspect_id == "all" || self.aspects.find(aspect_id) }
|
|
||||||
|
|
||||||
|
|
||||||
|
def intitial_post(class_name, aspect_ids, options = {})
|
||||||
post = build_post(class_name, options)
|
post = build_post(class_name, options)
|
||||||
|
|
||||||
post.socket_to_uid(id, :aspect_ids => aspect_ids) if post.respond_to?(:socket_to_uid)
|
post.socket_to_uid(id, :aspect_ids => aspect_ids) if post.respond_to?(:socket_to_uid)
|
||||||
push_to_aspects(post, aspect_ids)
|
push_to_aspects(post, aspect_ids)
|
||||||
|
|
||||||
post
|
post
|
||||||
end
|
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 = {})
|
def build_post( class_name, options = {})
|
||||||
options[:person] = self.person
|
options[:person] = self.person
|
||||||
model_class = class_name.to_s.camelize.constantize
|
model_class = class_name.to_s.camelize.constantize
|
||||||
|
|
@ -221,7 +242,7 @@ class User
|
||||||
|
|
||||||
###Helpers############
|
###Helpers############
|
||||||
def self.instantiate!( opts = {} )
|
def self.instantiate!( opts = {} )
|
||||||
opts[:person][:diaspora_handle] = "#{opts[:username]}@#{terse_url}"
|
opts[:person][:diaspora_handle] = "#{opts[:username]}@#{APP_CONFIG[:terse_pod_url]}"
|
||||||
opts[:person][:url] = APP_CONFIG[:pod_url]
|
opts[:person][:url] = APP_CONFIG[:pod_url]
|
||||||
opts[:person][:serialized_key] = generate_key
|
opts[:person][:serialized_key] = generate_key
|
||||||
User.create(opts)
|
User.create(opts)
|
||||||
|
|
|
||||||
|
|
@ -17,11 +17,11 @@
|
||||||
|
|
||||||
%h3 Picture
|
%h3 Picture
|
||||||
%div#image_picker
|
%div#image_picker
|
||||||
= p.hidden_field :image_url, :value => (@profile.image_url.sub(APP_CONFIG[:pod_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?
|
- unless @photos.nil? || @photos.empty?
|
||||||
- for photo in @photos
|
- for photo in @photos
|
||||||
- if @profile.image_url && (photo.url(:thumb_medium) == @profile.image_url.sub(APP_CONFIG[:pod_url],'/'))
|
- if @profile.image_url && @profile.image_url.include?(photo.url(:thumb_medium))
|
||||||
%div.small_photo{:id => photo.url(:thumb_medium), :class=>'selected'}
|
%div.small_photo{:id => photo.url(:thumb_medium), :class=>'selected'}
|
||||||
= check_box_tag 'checked_photo', true, true
|
= check_box_tag 'checked_photo', true, true
|
||||||
= link_to image_tag(photo.url(:thumb_medium)), "#"
|
= link_to image_tag(photo.url(:thumb_medium)), "#"
|
||||||
|
|
|
||||||
|
|
@ -53,6 +53,11 @@ namespace :deploy do
|
||||||
run "ln -s -f #{shared_path}/bundle #{current_path}/vendor/bundle"
|
run "ln -s -f #{shared_path}/bundle #{current_path}/vendor/bundle"
|
||||||
end
|
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
|
task :start do
|
||||||
start_mongo
|
start_mongo
|
||||||
start_thin
|
start_thin
|
||||||
|
|
@ -150,4 +155,4 @@ namespace :db do
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
after "deploy:symlink", "deploy:symlink_images", "deploy:symlink_bundle"
|
after "deploy:symlink", "deploy:symlink_images", "deploy:symlink_bundle", 'deploy:symlink_config'
|
||||||
|
|
|
||||||
|
|
@ -2,12 +2,25 @@
|
||||||
# licensed under the Affero General Public License version 3. See
|
# licensed under the Affero General Public License version 3. See
|
||||||
# the COPYRIGHT file.
|
# the COPYRIGHT file.
|
||||||
|
|
||||||
raw_config = File.read("#{Rails.root}/config/app_config.yml")
|
def load_config_yaml filename
|
||||||
all_envs = YAML.load(raw_config)
|
YAML.load(File.read(filename))
|
||||||
if all_envs[Rails.env]
|
end
|
||||||
APP_CONFIG = all_envs['default'].merge(all_envs[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
|
else
|
||||||
APP_CONFIG = all_envs['default'].symbolize_keys
|
APP_CONFIG = all_envs['default'].symbolize_keys
|
||||||
end
|
end
|
||||||
|
|
||||||
puts "WARNING: Please modify your app_config.yml to have a proper pod_url!" if APP_CONFIG[:pod_url] == "http://example.org/" && Rails.env != :test
|
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
|
||||||
|
|
|
||||||
|
|
@ -7,4 +7,137 @@
|
||||||
# See http://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points.
|
# See http://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points.
|
||||||
|
|
||||||
pt-BR:
|
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"
|
||||||
|
|
|
||||||
|
|
@ -35,18 +35,18 @@ def create
|
||||||
:person => Person.new(
|
:person => Person.new(
|
||||||
:profile => Profile.new( :first_name => backer_info[backer_number]['given_name'], :last_name => backer_info[backer_number]['family_name'],
|
: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")
|
:image_url => "http://#{username}.joindiaspora.com/images/user/#{username}.jpg")
|
||||||
)
|
))
|
||||||
user.person.save!
|
user.person.save!
|
||||||
|
|
||||||
user.aspect(:name => "Presidents")
|
user.aspect(:name => "Presidents")
|
||||||
end
|
end
|
||||||
|
|
||||||
def set_app_config username
|
def set_app_config username
|
||||||
current_config = YAML.load(Rails.root.join('config', 'app_config.yml'))
|
current_config = YAML.load(File.read(Rails.root.join('config', 'app_config_example.yml')))
|
||||||
current_config[Rails.env] ||= {}
|
current_config[Rails.env.to_s] ||= {}
|
||||||
current_config[Rails.env][:pod_url] = "#{username}.joindiaspora.com"
|
current_config[Rails.env.to_s]['pod_url'] = "#{username}.joindiaspora.com"
|
||||||
current_config[:default][: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 = File.new(Rails.root.join('..','..','shared','app_config.yml'),'w')
|
||||||
file.write(current_config.to_yaml)
|
file.write(current_config.to_yaml)
|
||||||
file.close
|
file.close
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,19 @@
|
||||||
|
|
||||||
require 'config/environment'
|
require 'config/environment'
|
||||||
|
|
||||||
|
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"
|
username = "tom"
|
||||||
|
set_app_config username
|
||||||
|
|
||||||
# Create seed user
|
# Create seed user
|
||||||
user = User.instantiate!( :email => "tom@tom.joindiaspora.com",
|
user = User.instantiate!( :email => "tom@tom.joindiaspora.com",
|
||||||
:username => "tom",
|
:username => "tom",
|
||||||
|
|
|
||||||
|
|
@ -7,11 +7,11 @@
|
||||||
require 'config/environment'
|
require 'config/environment'
|
||||||
|
|
||||||
def set_app_config username
|
def set_app_config username
|
||||||
current_config = YAML.load(Rails.root.join('config', 'app_config.yml'))
|
current_config = YAML.load(File.read(Rails.root.join('config', 'app_config_example.yml')))
|
||||||
current_config[Rails.env] ||= {}
|
current_config[Rails.env.to_s] ||= {}
|
||||||
current_config[Rails.env][:pod_url] = "#{username}.joindiaspora.com"
|
current_config[Rails.env.to_s]['pod_url'] = "#{username}.joindiaspora.com"
|
||||||
current_config[:default][: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 = File.new(Rails.root.join('..','..','shared','app_config.yml'),'w')
|
||||||
file.write(current_config.to_yaml)
|
file.write(current_config.to_yaml)
|
||||||
file.close
|
file.close
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -35,11 +35,6 @@ module Diaspora
|
||||||
aspects.detect{|x| x.id == id }
|
aspects.detect{|x| x.id == id }
|
||||||
end
|
end
|
||||||
|
|
||||||
def album_by_id( id )
|
|
||||||
id = id.to_id
|
|
||||||
albums.detect{|x| x.id == id }
|
|
||||||
end
|
|
||||||
|
|
||||||
def aspects_with_post( id )
|
def aspects_with_post( id )
|
||||||
self.aspects.find_all_by_post_ids( id.to_id )
|
self.aspects.find_all_by_post_ids( id.to_id )
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -26,15 +26,22 @@ describe User do
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'posting' do
|
context 'posting' do
|
||||||
describe '#post' do
|
|
||||||
|
describe '#validate_aspect_permissions' do
|
||||||
it 'should not be able to post without a aspect' do
|
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/
|
proc {
|
||||||
|
user.validate_aspect_permissions([])
|
||||||
|
}.should raise_error /You must post to someone/
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should not be able to post to someone elses aspect' do
|
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./
|
proc {
|
||||||
|
user.validate_aspect_permissions(aspect2.id)
|
||||||
|
}.should raise_error /Cannot post to an aspect you do not own./
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe '#post' do
|
||||||
it 'should put the post in the aspect post array' do
|
it 'should put the post in the aspect post array' do
|
||||||
post = user.post(:status_message, :message => "hey", :to => aspect.id)
|
post = user.post(:status_message, :message => "hey", :to => aspect.id)
|
||||||
aspect.reload
|
aspect.reload
|
||||||
|
|
@ -47,6 +54,16 @@ describe User do
|
||||||
aspect.posts.should include album
|
aspect.posts.should include album
|
||||||
end
|
end
|
||||||
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
|
end
|
||||||
|
|
||||||
context 'dispatching' do
|
context 'dispatching' do
|
||||||
|
|
|
||||||
|
|
@ -7,82 +7,79 @@
|
||||||
require File.dirname(__FILE__) + '/../../spec_helper'
|
require File.dirname(__FILE__) + '/../../spec_helper'
|
||||||
|
|
||||||
describe User do
|
describe User do
|
||||||
|
let(:user) { Factory(:user) }
|
||||||
|
|
||||||
|
let(:user2) { Factory(:user) }
|
||||||
|
let(:user3) { Factory(:user) }
|
||||||
|
let(:user4) { Factory(:user) }
|
||||||
|
|
||||||
|
let!(:aspect) { user.aspect(:name => 'heroes') }
|
||||||
|
let!(:aspect2) { user.aspect(:name => 'losers') }
|
||||||
|
|
||||||
|
let!(:user2_aspect) { user2.aspect(:name => 'dudes') }
|
||||||
|
let!(:user3_aspect) { user3.aspect(:name => 'dudes') }
|
||||||
|
let!(:user4_aspect) { user4.aspect(:name => 'dudes') }
|
||||||
|
|
||||||
|
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 }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
@user = Factory.create(:user)
|
friend_users(user, aspect, user2, user2_aspect)
|
||||||
@aspect = @user.aspect(:name => 'heroes')
|
friend_users(user, aspect2, user3, user3_aspect)
|
||||||
@aspect2 = @user.aspect(:name => 'losers')
|
friend_users(user, aspect2, user4, user4_aspect)
|
||||||
|
|
||||||
@user2 = Factory.create :user
|
|
||||||
@user2_aspect = @user2.aspect(:name => 'dudes')
|
|
||||||
|
|
||||||
friend_users(@user, @aspect, @user2, @user2_aspect)
|
|
||||||
|
|
||||||
@user3 = Factory.create :user
|
|
||||||
@user3_aspect = @user3.aspect(:name => 'dudes')
|
|
||||||
friend_users(@user, @aspect2, @user3, @user3_aspect)
|
|
||||||
|
|
||||||
@user4 = Factory.create :user
|
|
||||||
@user4_aspect = @user4.aspect(:name => 'dudes')
|
|
||||||
friend_users(@user, @aspect2, @user4, @user4_aspect)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should generate a valid stream for a aspect of people' do
|
it 'should generate a valid stream for a aspect of people' do
|
||||||
status_message1 = @user2.post :status_message, :message => "hi", :to => @user2_aspect.id
|
(1..3).each{ |n|
|
||||||
status_message2 = @user3.post :status_message, :message => "heyyyy", :to => @user3_aspect.id
|
eval("user.receive status_message#{n}.to_diaspora_xml")
|
||||||
status_message3 = @user4.post :status_message, :message => "yooo", :to => @user4_aspect.id
|
}
|
||||||
|
|
||||||
@user.receive status_message1.to_diaspora_xml
|
user.visible_posts(:by_members_of => aspect).should include status_message1
|
||||||
@user.receive status_message2.to_diaspora_xml
|
user.visible_posts(:by_members_of => aspect).should_not include status_message2
|
||||||
@user.receive status_message3.to_diaspora_xml
|
user.visible_posts(:by_members_of => aspect).should_not include status_message3
|
||||||
@user.reload
|
|
||||||
|
|
||||||
@user.visible_posts(:by_members_of => @aspect).include?(status_message1).should be true
|
user.visible_posts(:by_members_of => aspect2).should_not include status_message1
|
||||||
@user.visible_posts(:by_members_of => @aspect).include?(status_message2).should be false
|
user.visible_posts(:by_members_of => aspect2).should include status_message2
|
||||||
@user.visible_posts(:by_members_of => @aspect).include?(status_message3).should be false
|
user.visible_posts(:by_members_of => aspect2).should 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
|
end
|
||||||
|
|
||||||
describe 'querying' do
|
context 'querying' do
|
||||||
|
describe '#find_visible_post_by_id' do
|
||||||
it 'should find a visible post by id' do
|
it 'should query' do
|
||||||
status_message1 = @user.post :status_message, :message => "hi", :to => @aspect.id
|
user2.find_visible_post_by_id(status_message1.id).should == status_message1
|
||||||
status_message2 = @user2.post :status_message, :message => "heyyyy", :to => @user2_aspect.id
|
user.find_visible_post_by_id(status_message1.id).should == nil
|
||||||
status_message3 = @user3.post :status_message, :message => "yooo", :to => @user3_aspect.id
|
end
|
||||||
|
end
|
||||||
@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
|
||||||
|
|
||||||
end
|
context 'albums' do
|
||||||
|
|
||||||
|
|
||||||
describe 'albums' do
|
|
||||||
before do
|
before do
|
||||||
@album = @user.post :album, :name => "Georges", :to => @aspect.id
|
@album = user.post :album, :name => "Georges", :to => aspect.id
|
||||||
@aspect.reload
|
aspect.reload
|
||||||
@aspect2.reload
|
aspect2.reload
|
||||||
@user.reload
|
user.reload
|
||||||
|
|
||||||
@album2 = @user.post :album, :name => "Borges", :to => @aspect.id
|
@album2 = user.post :album, :name => "Borges", :to => aspect.id
|
||||||
@aspect.reload
|
aspect.reload
|
||||||
@aspect2.reload
|
aspect2.reload
|
||||||
@user.reload
|
user.reload
|
||||||
|
|
||||||
@user.post :album, :name => "Luises", :to => @aspect2.id
|
user.post :album, :name => "Luises", :to => aspect2.id
|
||||||
@aspect.reload
|
aspect.reload
|
||||||
@aspect2.reload
|
aspect2.reload
|
||||||
@user.reload
|
user.reload
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should find all albums if passed :all' do
|
it 'should find all albums if passed :all' do
|
||||||
@user.albums_by_aspect(:all).size.should == 3
|
user.albums_by_aspect(:all).should have(3).albums
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should return the right number of albums' do
|
it 'should return the right number of albums' do
|
||||||
@user.albums_by_aspect(@aspect).size.should == 2
|
user.albums_by_aspect(aspect).should have(2).albums
|
||||||
@user.albums_by_aspect(@aspect2).size.should == 1
|
user.albums_by_aspect(aspect2).should have(1).album
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue