Merge branch 'master' into getting-started
This commit is contained in:
commit
1d5b7a87f1
45 changed files with 955 additions and 395 deletions
2
Gemfile
2
Gemfile
|
|
@ -58,7 +58,7 @@ group :test do
|
|||
gem 'rspec', '>= 2.0.0'
|
||||
gem 'rspec-rails', '>= 2.0.0'
|
||||
gem 'mocha'
|
||||
gem 'database_cleaner'
|
||||
gem 'database_cleaner', '0.5.2'
|
||||
gem 'webmock'
|
||||
end
|
||||
|
||||
|
|
|
|||
75
Gemfile.lock
75
Gemfile.lock
|
|
@ -1,8 +1,8 @@
|
|||
GIT
|
||||
remote: git://github.com/Empact/roxml.git
|
||||
revision: 33034d3e632b3a14565a791af0a63c7e23ec0de4
|
||||
revision: d411519add92e0cd5a985253f376d25c26884324
|
||||
specs:
|
||||
roxml (3.1.5)
|
||||
roxml (3.1.6)
|
||||
activesupport (>= 2.3.0)
|
||||
nokogiri (>= 1.3.3)
|
||||
|
||||
|
|
@ -141,10 +141,10 @@ GEM
|
|||
columnize (0.3.1)
|
||||
configuration (1.1.0)
|
||||
crack (0.1.8)
|
||||
cucumber (0.9.2)
|
||||
cucumber (0.9.3)
|
||||
builder (~> 2.1.2)
|
||||
diff-lcs (~> 1.1.2)
|
||||
gherkin (~> 2.2.5)
|
||||
gherkin (~> 2.2.9)
|
||||
json (~> 1.4.6)
|
||||
term-ansicolor (~> 1.0.5)
|
||||
cucumber-rails (0.3.2)
|
||||
|
|
@ -169,9 +169,10 @@ GEM
|
|||
factory_girl_rails (1.0)
|
||||
factory_girl (~> 1.3)
|
||||
rails (>= 3.0.0.beta4)
|
||||
faraday (0.4.6)
|
||||
addressable (>= 2.1.1)
|
||||
rack (>= 1.0.1)
|
||||
faraday (0.5.1)
|
||||
addressable (~> 2.2.2)
|
||||
multipart-post (~> 1.0.1)
|
||||
rack (~> 1.2.1)
|
||||
ffi (0.6.3)
|
||||
rake (>= 0.8.7)
|
||||
gherkin (2.2.9)
|
||||
|
|
@ -183,17 +184,18 @@ GEM
|
|||
http_connection (1.4.0)
|
||||
httparty (0.6.1)
|
||||
crack (= 0.1.8)
|
||||
i18n (0.4.1)
|
||||
i18n (0.4.2)
|
||||
json (1.4.6)
|
||||
json_pure (1.4.6)
|
||||
launchy (0.3.7)
|
||||
configuration (>= 0.0.5)
|
||||
rake (>= 0.8.1)
|
||||
linecache (0.43)
|
||||
mail (2.2.7)
|
||||
mail (2.2.9)
|
||||
activesupport (>= 2.3.6)
|
||||
mime-types
|
||||
treetop (>= 1.4.5)
|
||||
i18n (~> 0.4.1)
|
||||
mime-types (~> 1.16)
|
||||
treetop (~> 1.4.8)
|
||||
mime-types (1.16)
|
||||
mini_fb (1.1.3)
|
||||
hashie
|
||||
|
|
@ -205,12 +207,13 @@ GEM
|
|||
mixlib-cli (1.2.0)
|
||||
mixlib-config (1.1.2)
|
||||
mixlib-log (1.2.0)
|
||||
mocha (0.9.8)
|
||||
mocha (0.9.9)
|
||||
rake
|
||||
moneta (0.6.0)
|
||||
mongo (1.1)
|
||||
bson (>= 1.0.5)
|
||||
multi_json (0.0.4)
|
||||
multipart-post (1.0.1)
|
||||
net-ldap (0.1.1)
|
||||
net-scp (1.0.4)
|
||||
net-ssh (>= 1.99.1)
|
||||
|
|
@ -220,33 +223,33 @@ GEM
|
|||
net-ssh-gateway (1.0.1)
|
||||
net-ssh (>= 1.99.1)
|
||||
nokogiri (1.4.3.1)
|
||||
oa-basic (0.1.5)
|
||||
oa-basic (0.1.6)
|
||||
multi_json (~> 0.0.2)
|
||||
nokogiri (~> 1.4.2)
|
||||
oa-core (= 0.1.5)
|
||||
oa-core (= 0.1.6)
|
||||
rest-client (~> 1.6.0)
|
||||
oa-core (0.1.5)
|
||||
oa-core (0.1.6)
|
||||
rack (~> 1.1)
|
||||
oa-enterprise (0.1.5)
|
||||
oa-enterprise (0.1.6)
|
||||
net-ldap (~> 0.1.1)
|
||||
nokogiri (~> 1.4.2)
|
||||
oa-core (= 0.1.5)
|
||||
oa-core (= 0.1.6)
|
||||
pyu-ruby-sasl (~> 0.0.3.1)
|
||||
rubyntlm (~> 0.1.1)
|
||||
oa-oauth (0.1.5)
|
||||
oa-oauth (0.1.6)
|
||||
multi_json (~> 0.0.2)
|
||||
nokogiri (~> 1.4.2)
|
||||
oa-core (= 0.1.5)
|
||||
oa-core (= 0.1.6)
|
||||
oauth (~> 0.4.0)
|
||||
oauth2 (~> 0.0.10)
|
||||
oa-openid (0.1.5)
|
||||
oa-core (= 0.1.5)
|
||||
rack-openid (~> 1.1.1)
|
||||
oauth2 (~> 0.1.0)
|
||||
oa-openid (0.1.6)
|
||||
oa-core (= 0.1.6)
|
||||
rack-openid (~> 1.2.0)
|
||||
ruby-openid-apps-discovery
|
||||
oauth (0.4.3)
|
||||
oauth2 (0.0.13)
|
||||
faraday (~> 0.4.1)
|
||||
multi_json (>= 0.0.4)
|
||||
oauth2 (0.1.0)
|
||||
faraday (~> 0.5.0)
|
||||
multi_json (~> 0.0.4)
|
||||
ohai (0.5.8)
|
||||
extlib
|
||||
json (>= 1.4.4, <= 1.4.6)
|
||||
|
|
@ -254,12 +257,12 @@ GEM
|
|||
mixlib-config
|
||||
mixlib-log
|
||||
systemu
|
||||
omniauth (0.1.5)
|
||||
oa-basic (= 0.1.5)
|
||||
oa-core (= 0.1.5)
|
||||
oa-enterprise (= 0.1.5)
|
||||
oa-oauth (= 0.1.5)
|
||||
oa-openid (= 0.1.5)
|
||||
omniauth (0.1.6)
|
||||
oa-basic (= 0.1.6)
|
||||
oa-core (= 0.1.6)
|
||||
oa-enterprise (= 0.1.6)
|
||||
oa-oauth (= 0.1.6)
|
||||
oa-openid (= 0.1.6)
|
||||
plucky (0.3.6)
|
||||
mongo (~> 1.1)
|
||||
polyglot (0.3.1)
|
||||
|
|
@ -270,9 +273,9 @@ GEM
|
|||
rack (1.2.1)
|
||||
rack-mount (0.6.13)
|
||||
rack (>= 1.0.0)
|
||||
rack-openid (1.1.2)
|
||||
rack (>= 0.4)
|
||||
ruby-openid (>= 2.0.3)
|
||||
rack-openid (1.2.0)
|
||||
rack (>= 1.1.0)
|
||||
ruby-openid (>= 2.1.8)
|
||||
rack-test (0.5.6)
|
||||
rack (>= 1.0)
|
||||
rails (3.0.1)
|
||||
|
|
@ -356,7 +359,7 @@ DEPENDENCIES
|
|||
carrierwave!
|
||||
chef
|
||||
cucumber-rails (= 0.3.2)
|
||||
database_cleaner
|
||||
database_cleaner (= 0.5.2)
|
||||
devise (= 1.1.3)
|
||||
devise-mongo_mapper!
|
||||
devise_invitable (~> 0.3.4)
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ class ApplicationController < ActionController::Base
|
|||
|
||||
@aspects = current_user.aspects
|
||||
@aspects_dropdown_array = current_user.aspects.collect{|x| [x.to_s, x.id]}
|
||||
@friends = current_user.friends
|
||||
@friends = current_user.person_objects
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -51,8 +51,8 @@ class AspectsController < ApplicationController
|
|||
unless @aspect
|
||||
render :file => "#{Rails.root}/public/404.html", :layout => false, :status => 404
|
||||
else
|
||||
@friends = @aspect.people
|
||||
@posts = current_user.visible_posts( :by_members_of => @aspect ).paginate :page => params[:page], :per_page => 15, :order => 'created_at DESC'
|
||||
@friends = @aspect.person_objects
|
||||
@posts = current_user.visible_posts( :by_members_of => @aspect ).paginate :per_page => 15, :order => 'created_at DESC'
|
||||
respond_with @aspect
|
||||
end
|
||||
end
|
||||
|
|
@ -101,11 +101,4 @@ class AspectsController < ApplicationController
|
|||
end
|
||||
redirect_to aspects_manage_path
|
||||
end
|
||||
|
||||
private
|
||||
def clean_hash(params)
|
||||
return {
|
||||
:name => params[:name]
|
||||
}
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -21,7 +21,8 @@ class PeopleController < ApplicationController
|
|||
render :file => "#{Rails.root}/public/404.html", :layout => false, :status => 404
|
||||
else
|
||||
@profile = @person.profile
|
||||
@aspects_with_person = current_user.aspects_with_person(@person)
|
||||
@contact = current_user.contact_for(@person)
|
||||
@aspects_with_person = @contact.aspects if @contact
|
||||
@posts = current_user.visible_posts(:person_id => @person.id).paginate :page => params[:page], :order => 'created_at DESC'
|
||||
respond_with @person
|
||||
end
|
||||
|
|
|
|||
|
|
@ -94,16 +94,13 @@ class UsersController < ApplicationController
|
|||
def import
|
||||
xml = params[:upload][:file].read
|
||||
|
||||
params[:user][:diaspora_handle] = 'asodij@asodij.asd'
|
||||
|
||||
|
||||
begin
|
||||
importer = Diaspora::Importer.new(Diaspora::Parsers::XML)
|
||||
importer.execute(xml, params[:user])
|
||||
flash[:notice] = "hang on a sec, try logging in!"
|
||||
|
||||
rescue Exception => e
|
||||
flash[:error] = "Derp, something went wrong: #{e.message}"
|
||||
flash[:error] = "Something went wrong: #{e.message}"
|
||||
end
|
||||
|
||||
redirect_to new_user_registration_path
|
||||
|
|
|
|||
|
|
@ -6,11 +6,10 @@ class Aspect
|
|||
include MongoMapper::Document
|
||||
|
||||
key :name, String
|
||||
key :person_ids, Array
|
||||
key :request_ids, Array
|
||||
key :post_ids, Array
|
||||
|
||||
many :people, :in => :person_ids, :class_name => 'Person'
|
||||
many :people, :foreign_key => 'aspect_ids', :class_name => 'Contact'
|
||||
many :requests, :in => :request_ids, :class_name => 'Request'
|
||||
many :posts, :in => :post_ids, :class_name => 'Post'
|
||||
|
||||
|
|
@ -31,6 +30,11 @@ class Aspect
|
|||
posts.detect{|x| x.person.id == id }
|
||||
end
|
||||
|
||||
def person_objects
|
||||
person_ids = people.map{|x| x.person_id}
|
||||
Person.all(:id.in => person_ids)
|
||||
end
|
||||
|
||||
def as_json(opts = {})
|
||||
{
|
||||
:aspect => {
|
||||
|
|
|
|||
19
app/models/contact.rb
Normal file
19
app/models/contact.rb
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
# Copyright (c) 2010, Diaspora Inc. This file is
|
||||
# licensed under the Affero General Public License version 3 or later. See
|
||||
# the COPYRIGHT file.
|
||||
|
||||
class Contact
|
||||
include MongoMapper::Document
|
||||
attr_accessor :aspect_names #this is only used in the importer
|
||||
|
||||
belongs_to :user
|
||||
validates_presence_of :user
|
||||
|
||||
belongs_to :person
|
||||
validates_presence_of :person
|
||||
|
||||
key :aspect_ids, Array, :typecast => 'ObjectId'
|
||||
many :aspects, :in => :aspect_ids, :class_name => 'Aspect'
|
||||
validates_presence_of :aspects
|
||||
|
||||
end
|
||||
|
|
@ -40,6 +40,8 @@ class Person
|
|||
validates_format_of :url, :with =>
|
||||
/^(https?):\/\/[a-z0-9]+([\-\.]{1}[a-z0-9]+)*(\.[a-z]{2,5})?(:[0-9]{1,5})?(\/.*)?$/ix
|
||||
|
||||
ensure_index :diaspora_handle
|
||||
|
||||
def self.search(query)
|
||||
return Person.all if query.to_s.empty?
|
||||
query_tokens = query.to_s.strip.split(" ")
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ class User
|
|||
end
|
||||
|
||||
many :inviters, :in => :inviter_ids, :class_name => 'User'
|
||||
many :friends, :in => :friend_ids, :class_name => 'Person'
|
||||
many :friends, :in => :friend_ids, :class_name => 'Contact'
|
||||
many :visible_people, :in => :visible_person_ids, :class_name => 'Person' # One of these needs to go
|
||||
many :pending_requests, :in => :pending_request_ids, :class_name => 'Request'
|
||||
many :raw_visible_posts, :in => :visible_post_ids, :class_name => 'Post'
|
||||
|
|
@ -119,21 +119,26 @@ class User
|
|||
end
|
||||
|
||||
def add_person_to_aspect(person_id, aspect_id, opts = {})
|
||||
contact = contact_for(Person.find(person_id))
|
||||
raise "Can not add person to an aspect you do not own" unless aspect = self.aspects.find_by_id(aspect_id)
|
||||
raise "Can not add person you are not friends with" unless person = self.find_friend_by_id(person_id)
|
||||
raise 'Can not add person who is already in the aspect' if aspect.person_ids.include?(person_id)
|
||||
aspect.people << person
|
||||
raise "Can not add person you are not friends with" unless contact
|
||||
raise 'Can not add person who is already in the aspect' if aspect.people.include?(contact)
|
||||
contact.aspects << aspect
|
||||
opts[:posts] ||= self.raw_visible_posts.all(:person_id => person_id)
|
||||
|
||||
aspect.posts += opts[:posts]
|
||||
contact.save
|
||||
aspect.save
|
||||
end
|
||||
|
||||
def delete_person_from_aspect(person_id, aspect_id, opts = {})
|
||||
raise "Can not delete a person from an aspect you do not own" unless aspect = self.aspects.find_by_id(aspect_id)
|
||||
aspect.person_ids.delete(person_id.to_id)
|
||||
aspect = Aspect.find(aspect_id)
|
||||
raise "Can not delete a person from an aspect you do not own" unless aspect.user == self
|
||||
contact = contact_for Person.find(person_id)
|
||||
contact.aspect_ids.delete aspect.id
|
||||
opts[:posts] ||= aspect.posts.all(:person_id => person_id)
|
||||
aspect.posts -= opts[:posts]
|
||||
contact.save
|
||||
aspect.save
|
||||
end
|
||||
|
||||
|
|
@ -219,17 +224,17 @@ class User
|
|||
aspects = self.aspects.find_all_by_id(aspect_ids)
|
||||
end
|
||||
#send to the aspects
|
||||
target_people = []
|
||||
target_contacts = []
|
||||
|
||||
aspects.each { |aspect|
|
||||
aspect.posts << post
|
||||
aspect.save
|
||||
target_people = target_people | aspect.people
|
||||
target_contacts = target_contacts | aspect.people
|
||||
}
|
||||
|
||||
push_to_hub(post) if post.respond_to?(:public) && post.public
|
||||
|
||||
push_to_people(post, target_people)
|
||||
push_to_people(post, self.person_objects(target_contacts))
|
||||
end
|
||||
|
||||
def push_to_people(post, people)
|
||||
|
|
@ -282,7 +287,8 @@ class User
|
|||
if owns? comment.post
|
||||
comment.post_creator_signature = comment.sign_with_key(encryption_key)
|
||||
comment.save
|
||||
push_to_people comment, people_in_aspects(aspects_with_post(comment.post.id))
|
||||
aspects = aspects_with_post(comment.post_id)
|
||||
push_to_people(comment, people_in_aspects(aspects))
|
||||
elsif owns? comment
|
||||
comment.save
|
||||
push_to_people comment, [comment.post.person]
|
||||
|
|
@ -450,11 +456,11 @@ class User
|
|||
end
|
||||
|
||||
def unfriend_everyone
|
||||
friends.each { |friend|
|
||||
if friend.owner?
|
||||
friend.owner.unfriended_by self.person
|
||||
friends.each { |contact|
|
||||
if contact.person.owner?
|
||||
contact.person.owner.unfriended_by self.person
|
||||
else
|
||||
self.unfriend friend
|
||||
self.unfriend contact
|
||||
end
|
||||
}
|
||||
end
|
||||
|
|
|
|||
|
|
@ -48,7 +48,8 @@
|
|||
%li!= remove_link(aspect)
|
||||
|
||||
%ul.dropzone{:data=>{:aspect_id=>aspect.id}}
|
||||
-for person in aspect.people
|
||||
-for contact in aspect.people
|
||||
-person = contact.person
|
||||
%li.person{:data=>{:guid=>person.id, :aspect_id=>aspect.id}}
|
||||
.delete
|
||||
.x
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@
|
|||
%li
|
||||
%i= t(".last_seen",:how_long_ago => how_long_ago(@posts.first))
|
||||
|
||||
- if @person != current_user.person && current_user.friends.include?(@person)
|
||||
- if @person != current_user.person && @contact
|
||||
%li
|
||||
%i= t(".friends_since",:how_long_ago => how_long_ago(@person))
|
||||
%li
|
||||
|
|
|
|||
11
ci-19.sh
Executable file
11
ci-19.sh
Executable file
|
|
@ -0,0 +1,11 @@
|
|||
#!/bin/bash
|
||||
|
||||
echo "*************************************************************************************************" &&
|
||||
echo "* ruby 1.9.2-p0 build *" &&
|
||||
echo "*************************************************************************************************" &&
|
||||
echo "" &&
|
||||
rm -f Gemfile.lock &&
|
||||
source /usr/local/rvm/scripts/rvm &&
|
||||
rvm use ruby-1.9.2-p0@diaspora &&
|
||||
bundle install &&
|
||||
bundle exec rake cruise
|
||||
11
ci.sh
11
ci.sh
|
|
@ -9,14 +9,3 @@ source /usr/local/rvm/scripts/rvm &&
|
|||
rvm use ruby-1.8.7-p249@diaspora &&
|
||||
bundle install &&
|
||||
bundle exec rake cruise
|
||||
# bundle exec rake cruise &&
|
||||
# echo "" &&
|
||||
# echo "*************************************************************************************************" &&
|
||||
# echo "* ruby 1.9.2-p0 build *" &&
|
||||
# echo "*************************************************************************************************" &&
|
||||
# echo "" &&
|
||||
# rm -f Gemfile.lock &&
|
||||
# source /usr/local/rvm/scripts/rvm &&
|
||||
# rvm use ruby-1.9.2-p0@diaspora &&
|
||||
# bundle install &&
|
||||
# bundle exec rake cruise
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ default:
|
|||
pubsub_server: 'https://pubsubhubbub.appspot.com/'
|
||||
mongo_host: 'localhost'
|
||||
mongo_port: 27017
|
||||
mailer_on: false
|
||||
smtp_address: 'smtp.example.com'
|
||||
smtp_port: '587'
|
||||
smtp_domain: 'mail.example.com'
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ Diaspora::Application.configure do
|
|||
config.action_controller.perform_caching = false
|
||||
|
||||
# Don't care if the mailer can't send
|
||||
config.action_mailer.raise_delivery_errors = true
|
||||
config.action_mailer.raise_delivery_errors = false
|
||||
config.active_support.deprecation = :log
|
||||
config.middleware.use MongoMapper::ClearDevMemory
|
||||
#config.threadsafe!
|
||||
|
|
|
|||
|
|
@ -47,16 +47,4 @@ Diaspora::Application.configure do
|
|||
# the I18n.default_locale when a translation can not be found)
|
||||
config.i18n.fallbacks = true
|
||||
config.threadsafe!
|
||||
|
||||
config.action_mailer.delivery_method = :smtp
|
||||
config.action_mailer.default_url_options = {:host => 'pivots.joindiaspora.com'}
|
||||
config.action_mailer.smtp_settings = {
|
||||
:address => 'smtp.gmail.com',
|
||||
:port => 587,
|
||||
:domain => 'mail.joindiaspora.com',
|
||||
:authentication => 'plain',
|
||||
:user_name => 'diaspora-pivots@joindiaspora.com',
|
||||
:password => "xy289|]G+R*-kA",
|
||||
:enable_starttls_auto => true
|
||||
}
|
||||
end
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
Diaspora::Application.configure do
|
||||
config.action_mailer.default_url_options = {:host => APP_CONFIG[:terse_pod_url]}
|
||||
unless Rails.env == 'test'
|
||||
unless Rails.env == 'test' || APP_CONFIG[:mailer_on] != true
|
||||
config.action_mailer.delivery_method = :smtp
|
||||
config.action_mailer.smtp_settings = {
|
||||
:address => APP_CONFIG[:smtp_address],
|
||||
|
|
|
|||
|
|
@ -31,9 +31,13 @@ sv:
|
|||
updated: 'Ditt konto har uppdateras.'
|
||||
destroyed: 'Ditt konto är avslutat. Välkommen åter!'
|
||||
unlocks:
|
||||
send_instructions: 'Du kommer att få ett ebrev med instruktioner för att låsa upp ditt konto inom några minuter.'
|
||||
send_instructions: 'Du kommer att få ett mail med instruktioner för att låsa upp ditt konto inom några minuter.'
|
||||
unlocked: 'Ditt konto har är nu upplåst och du är inloggad'
|
||||
invitations:
|
||||
send_instructions: 'Din inbjudan är nu skickad.'
|
||||
invitation_token_invalid: 'Denna inbjudan är ej giltig!'
|
||||
updated: 'Ditt lösenord är nu inställt och du är inloggad.'
|
||||
mailer:
|
||||
confirmation_instructions: 'Instruktioner för att verifiera ditt konto.'
|
||||
reset_password_instructions: 'Instruktioner för att terställa ditt lösenord.'
|
||||
reset_password_instructions: 'Instruktioner för att återställa ditt lösenord.'
|
||||
unlock_instructions: 'Instruktioner för att låsa upp ditt konto.'
|
||||
|
|
|
|||
|
|
@ -15,6 +15,10 @@ en:
|
|||
taken: "is already taken"
|
||||
email:
|
||||
taken: "is already taken"
|
||||
person:
|
||||
attributes:
|
||||
diaspora_handle:
|
||||
taken: "is already taken"
|
||||
hello: "Hello world"
|
||||
application:
|
||||
helper:
|
||||
|
|
|
|||
|
|
@ -6,6 +6,15 @@
|
|||
# See http://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points.
|
||||
|
||||
fr-informal:
|
||||
activemodel:
|
||||
errors:
|
||||
models:
|
||||
user:
|
||||
attributes:
|
||||
username:
|
||||
taken: "est déjà pris"
|
||||
email:
|
||||
taken: "est déjà pris"
|
||||
hello: "Bonjour tout le monde"
|
||||
application:
|
||||
helper:
|
||||
|
|
@ -38,6 +47,7 @@ fr-informal:
|
|||
share: "Partager"
|
||||
aspect_friends:
|
||||
add_friends: "ajouter des amis"
|
||||
photos: "photos"
|
||||
albums:
|
||||
album:
|
||||
you: "toi"
|
||||
|
|
@ -69,10 +79,14 @@ fr-informal:
|
|||
friends_albums: "Albums d’amis"
|
||||
your_albums: "Tes albums"
|
||||
aspects:
|
||||
index:
|
||||
photos: "photos"
|
||||
show:
|
||||
photos: "photos"
|
||||
no_friends_message:
|
||||
nobody: "Tu as forcément des amis, n’hésite pas à les ramener sur Diaspora !"
|
||||
nobody_in_aspect: "Ton aspect '%{aspect_name}' est vide."
|
||||
add_friend: "Ajouter un ami"
|
||||
add_friend_to: "Ajouter quelqu’un à %{aspect_name}"
|
||||
invite: "Inviter quelqu’un à rejoindre Diaspora !"
|
||||
no_posts_message:
|
||||
start_talking: "Personne n’a encore rien dit. Commence dès à présent la conversation !"
|
||||
manage:
|
||||
add_a_new_aspect: "Ajouter un nouvel aspect"
|
||||
add_a_new_friend: "Ajouter un nouvel ami"
|
||||
|
|
@ -90,12 +104,12 @@ fr-informal:
|
|||
success: "%{name} a été supprimé avec succès."
|
||||
update:
|
||||
success: "Ton aspect, %{name}, a été édité avec succès."
|
||||
move_friends:
|
||||
failure: "L’édition de l’aspect concernant ton ami %{real_name} a échoué."
|
||||
success: "Les aspects ont été édités avec succès."
|
||||
move_friend:
|
||||
failure: "ne fonctionne pas %{inspect}"
|
||||
success: "Tu montres à présent à ton ami un aspect différent au tiens."
|
||||
success: "Personne déplacée vers le nouvel aspect"
|
||||
add_to_aspect:
|
||||
failure: "L’ajout de l’ami vers l’aspect a échoué."
|
||||
success: "Tu as ajouté l’ami à l’aspect avec succès."
|
||||
helper:
|
||||
remove: "supprimer"
|
||||
aspect_not_empty: "L’aspect n’est pas vide"
|
||||
|
|
@ -136,6 +150,8 @@ fr-informal:
|
|||
photo:
|
||||
show_comments: "afficher les commentaires"
|
||||
posted_a_new_photo_to: "a publié une nouvelle photo dans"
|
||||
delete: "Supprimer"
|
||||
are_you_sure: "Es-tu sûr(e) ?"
|
||||
new:
|
||||
new_photo: "Nouvelle photo"
|
||||
back_to_list: "Retourner à la liste"
|
||||
|
|
@ -159,6 +175,7 @@ fr-informal:
|
|||
sent: 'Ton invitation a été envoyée.'
|
||||
no_more: 'Tu n’as plus d’invitation.'
|
||||
already_sent: 'Tu as déjà invité cette personne.'
|
||||
already_friends: 'Tu es déjà ami avec cette personne'
|
||||
invitation_token_invalid: 'Le jeton d’invitation fourni n’est pas valide !'
|
||||
updated: 'Ton mot de passe a été réglé avec succès. Tu es à présent connecté.'
|
||||
|
||||
|
|
@ -200,6 +217,7 @@ fr-informal:
|
|||
save: "sauver"
|
||||
are_you_sure: "Es-tu sûr(e) ?"
|
||||
remove_friend: "supprimer de mes amis"
|
||||
no_posts: "aucun message à afficher !"
|
||||
requests:
|
||||
new_request:
|
||||
add_a_new_friend_to: "Ajouter un nouvel ami à"
|
||||
|
|
@ -212,6 +230,9 @@ fr-informal:
|
|||
ignore: "Requête d’ami ignorée."
|
||||
create:
|
||||
error: "Aucun résultat Diaspora n’a été trouvé avec cette adresse e-mail !"
|
||||
already_friends: "Vous êtes déjà amis avec %{destination_url}!"
|
||||
invalid_identity: "Cette identité n’est pas proprement formatée"
|
||||
error_server: "Un problème est survenu avec l’autre serveur. Il n’existe peut-être pas ?"
|
||||
yourself: "Tu ne peux pas être ami avec toi-même !"
|
||||
already_friends: "Tu es déjà ami avec %{destination_url}!"
|
||||
success: "Une requête d’ami a été envoyée à %{destination_url}."
|
||||
horribly_wrong: "Quelque chose d’horrible s’est produit."
|
||||
|
|
|
|||
|
|
@ -6,6 +6,19 @@
|
|||
# See http://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points.
|
||||
|
||||
fr:
|
||||
activemodel:
|
||||
errors:
|
||||
models:
|
||||
user:
|
||||
attributes:
|
||||
username:
|
||||
taken: "est déjà pris"
|
||||
email:
|
||||
taken: "est déjà pris"
|
||||
person:
|
||||
attributes:
|
||||
diaspora_handle:
|
||||
taken: "est déjà pris"
|
||||
hello: "Bonjour tout le monde"
|
||||
application:
|
||||
helper:
|
||||
|
|
@ -38,6 +51,7 @@ fr:
|
|||
share: "Partager"
|
||||
aspect_friends:
|
||||
add_friends: "ajouter des amis"
|
||||
photos: "photos"
|
||||
albums:
|
||||
album:
|
||||
you: "vous"
|
||||
|
|
@ -69,10 +83,14 @@ fr:
|
|||
friends_albums: "Albums d’amis"
|
||||
your_albums: "Vos albums"
|
||||
aspects:
|
||||
index:
|
||||
photos: "photos"
|
||||
show:
|
||||
photos: "photos"
|
||||
no_friends_message:
|
||||
nobody: "Vous avez forcément des amis, n’hésitez pas à les ramener sur Diaspora !"
|
||||
nobody_in_aspect: "Votre aspect '%{aspect_name}' est vide."
|
||||
add_friend: "Ajouter un ami"
|
||||
add_friend_to: "Ajouter quelqu’un à %{aspect_name}"
|
||||
invite: "Inviter quelqu’un à rejoindre Diaspora !"
|
||||
no_posts_message:
|
||||
start_talking: "Personne n’a encore rien dit. Commencez dès à présent la conversation !"
|
||||
manage:
|
||||
add_a_new_aspect: "Ajouter un nouvel aspect"
|
||||
add_a_new_friend: "Ajouter un nouvel ami"
|
||||
|
|
@ -90,12 +108,12 @@ fr:
|
|||
success: "%{name} a été supprimé avec succès."
|
||||
update:
|
||||
success: "Votre aspect, %{name}, a été édité avec succès."
|
||||
move_friends:
|
||||
failure: "L’édition de l’aspect concernant votre ami %{real_name} a échoué."
|
||||
success: "Les aspects ont été édités avec succès."
|
||||
move_friend:
|
||||
failure: "ne fonctionne pas %{inspect}"
|
||||
success: "Vous montrez à présent à votre ami un aspect différent au vôtre."
|
||||
success: "Personne déplacée vers le nouvel aspect"
|
||||
add_to_aspect:
|
||||
failure: "L’ajout de l’ami vers l’aspect a échoué."
|
||||
success: "Vous avez ajouté l’ami vers l’aspect avec succès."
|
||||
helper:
|
||||
remove: "supprimer"
|
||||
aspect_not_empty: "L’aspect n’est pas vide"
|
||||
|
|
@ -136,6 +154,8 @@ fr:
|
|||
photo:
|
||||
show_comments: "afficher les commentaires"
|
||||
posted_a_new_photo_to: "a publié une nouvelle photo dans"
|
||||
delete: "Supprimer"
|
||||
are_you_sure: "Êtes-vous sûr(e) ?"
|
||||
new:
|
||||
new_photo: "Nouvelle photo"
|
||||
back_to_list: "Retourner à la liste"
|
||||
|
|
@ -159,6 +179,7 @@ fr:
|
|||
sent: 'Votre invitation a été envoyée.'
|
||||
no_more: 'Vous n’avez plus d’invitation.'
|
||||
already_sent: 'Vous avez déjà invité cette personne.'
|
||||
already_friends: 'Vous êtes déjà ami avec cette personne'
|
||||
invitation_token_invalid: 'Le jeton d’invitation fourni n’est pas valide !'
|
||||
updated: 'Votre mot de passe a été réglé avec succès. Vous êtes à présent connecté.'
|
||||
|
||||
|
|
@ -200,6 +221,7 @@ fr:
|
|||
save: "sauver"
|
||||
are_you_sure: "Êtes-vous sûr(e) ?"
|
||||
remove_friend: "supprimer de mes amis"
|
||||
no_posts: "aucun message à afficher !"
|
||||
requests:
|
||||
new_request:
|
||||
add_a_new_friend_to: "Ajouter un nouvel ami à"
|
||||
|
|
@ -212,6 +234,9 @@ fr:
|
|||
ignore: "Requête d’ami ignorée."
|
||||
create:
|
||||
error: "Aucun résultat Diaspora n’a été trouvé avec cette adresse e-mail !"
|
||||
already_friends: "Vous êtes déjà amis avec %{destination_url}!"
|
||||
invalid_identity: "Cette identité n’est pas proprement formatée"
|
||||
error_server: "Un problème est survenu avec l’autre serveur. Il n’existe peut-être pas ?"
|
||||
yourself: "Vous ne pouvez pas être ami avec vous-même !"
|
||||
already_friends: "Vous êtes déjà ami avec %{destination_url}!"
|
||||
success: "Une requête d’ami a été envoyée à %{destination_url}."
|
||||
horribly_wrong: "Quelque chose d’horrible s’est produit."
|
||||
|
|
|
|||
|
|
@ -2,8 +2,236 @@
|
|||
# licensed under the Affero General Public License version 3 or later. See
|
||||
# the COPYRIGHT file.
|
||||
|
||||
# Swedish localization file.
|
||||
# See http://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points.
|
||||
# Localization file for Swedish
|
||||
|
||||
sv:
|
||||
hello: "Hej"
|
||||
activemodel:
|
||||
errors:
|
||||
models:
|
||||
user:
|
||||
attributes:
|
||||
username:
|
||||
taken: "är redan taget"
|
||||
email:
|
||||
taken: "är redan taget"
|
||||
hello: "Hej världen!"
|
||||
application:
|
||||
helper:
|
||||
unknown_person: "okänd person"
|
||||
new_requests: "nya förfrågningar"
|
||||
dashboards:
|
||||
helper:
|
||||
home: "hem"
|
||||
error_messages:
|
||||
helper:
|
||||
invalid_fields: "Ogiltiga fält"
|
||||
correct_the_following_errors_and_try_again: "Rätta följande fel och försök igen."
|
||||
people:
|
||||
helper:
|
||||
results_for: " resultat för %{params}"
|
||||
people_on_pod_are_aware_of: " personer på denna pod är medveten om att"
|
||||
layouts:
|
||||
application:
|
||||
edit_profile: "ändra profil"
|
||||
logout: "logga ut"
|
||||
shared:
|
||||
aspect_nav:
|
||||
all_aspects: "Alla Aspekter"
|
||||
manage: "Hantera"
|
||||
manage_your_aspects: "Hantera dina Aspekter"
|
||||
sub_header:
|
||||
all_aspects: "Alla Aspekter"
|
||||
manage_aspects: "Hantera Aspekter"
|
||||
publisher:
|
||||
share: "Dela"
|
||||
aspect_friends:
|
||||
add_friends: "lägg till vänner"
|
||||
photos: "foton"
|
||||
albums:
|
||||
album:
|
||||
you: "du"
|
||||
new_album:
|
||||
create: "skapa"
|
||||
add_a_new_album: "Lägg till ett nytt Album"
|
||||
show:
|
||||
edit_album: "Ändra Album"
|
||||
albums: "album"
|
||||
updated: "updated"
|
||||
by: "av"
|
||||
edit:
|
||||
editing: "Ändrar"
|
||||
updated: "uppdaterad"
|
||||
are_you_sure: "Är du säker?"
|
||||
delete_album: "Ta bort album"
|
||||
cancel: "Avbryt"
|
||||
index:
|
||||
home: "hem"
|
||||
new_album: "NyttAlbum"
|
||||
create:
|
||||
success: "Du har nu skapat albumet %{name}."
|
||||
update:
|
||||
success: "Albumet %{name} ändrades."
|
||||
failure: "Ändringarna av albumet %{name} misslyckades."
|
||||
destroy:
|
||||
success: "Albumet %{name} är nu borttaget."
|
||||
helper:
|
||||
friends_albums: "Vänners Album"
|
||||
your_albums: "Dina Album"
|
||||
aspects:
|
||||
no_friends_message:
|
||||
nobody: "Vi vet att du har vänner, bjud in dem till Diaspora!"
|
||||
nobody_in_aspect: "Aspekten '%{aspect_name}' är tom."
|
||||
add_friend: "Lägg till en vän"
|
||||
add_friend_to: "Lägg till en vän i %{aspect_name}"
|
||||
invite: "Bjud in en vän till Diaspora!"
|
||||
no_posts_message:
|
||||
start_talking: "Ingen har sagt något än. Bli först!"
|
||||
manage:
|
||||
add_a_new_aspect: "Lägg till en ny aspekt"
|
||||
add_a_new_friend: "Lägg till en ny vän"
|
||||
show: "Visa"
|
||||
update_aspects: "Uppdatera Aspekter"
|
||||
requests: "Förfrågningar"
|
||||
ignore_remove: "Ignorera/Ta bort"
|
||||
new_aspect:
|
||||
add_a_new_aspect: "Lägg till ny aspekt"
|
||||
create: "Skapa"
|
||||
create:
|
||||
success: "Klicka på plustecknet till höger för att välja vilka som kan se din nya aspekt."
|
||||
failure: "Aspekten kunde inte skapas."
|
||||
destroy:
|
||||
success: "%{name} är nu borttagen."
|
||||
update:
|
||||
success: "Din aspekt, %{name}, är nu ändrad."
|
||||
move_friend:
|
||||
failure: "fungerade inte %{inspect}"
|
||||
success: "Personen flyttades till den nya aspekten"
|
||||
add_to_aspect:
|
||||
failure: "Misslyckades med att lägga personen i den nya aspekten."
|
||||
success: "Personen tillagt i aspekten."
|
||||
helper:
|
||||
remove: "ta bort"
|
||||
aspect_not_empty: "Aspekten är inte tom"
|
||||
users:
|
||||
edit:
|
||||
editing_profile: "Ändrar profil"
|
||||
profile:
|
||||
cancel: "Avbryt"
|
||||
update_profile: "Uppdatera Profil"
|
||||
home: "Hem"
|
||||
diaspora_username: "DIASPORA-ID:"
|
||||
info: "Info"
|
||||
picture: "Profilbild"
|
||||
editing_profile: "Ändrar profil"
|
||||
albums: "Album"
|
||||
you_dont_have_any_photos: "Do har inga foton! Gå till"
|
||||
page_to_upload_some: "sidan för att ladda upp några."
|
||||
or: "eller"
|
||||
destroy: "Ditt konto är nu stängt."
|
||||
comments:
|
||||
comment:
|
||||
ago: "sedan"
|
||||
new_comment:
|
||||
comment: "Kommentar"
|
||||
photos:
|
||||
show:
|
||||
prev: "föregående"
|
||||
full_size: "full storlek"
|
||||
next: "nästa"
|
||||
edit_photo: "Ändra Foto"
|
||||
delete_photo: "Ta bort Foto"
|
||||
are_you_sure: "Är du säker?"
|
||||
comments: "kommentarer"
|
||||
edit:
|
||||
editing: "Ändrar"
|
||||
are_you_sure: "Är du säker?"
|
||||
delete_photo: "Ta bort Foto"
|
||||
photo:
|
||||
show_comments: "visa kommentarer"
|
||||
posted_a_new_photo_to: "laddade upp ett nytt foto till"
|
||||
delete: "Ta bort"
|
||||
are_you_sure: "Är du säker?"
|
||||
new:
|
||||
new_photo: "Nytt Foto"
|
||||
back_to_list: "Tillbaka till listan"
|
||||
post_it: "skicka!"
|
||||
create:
|
||||
runtime_error: "Fotot kunde inte laddas upp."
|
||||
integrity_error: "Fotot kunde inte laddas upp. Är du säker på att den där filen var en bild?"
|
||||
type_error: "Fotot kunde inte laddas upp. Är du säker på att det var en bild du försökte ladda upp?"
|
||||
update:
|
||||
notice: "Fotot är nu uppdaterat."
|
||||
error: "Misslyckades med att ändra fotot."
|
||||
destroy:
|
||||
notice: "Fotot borttaget."
|
||||
registrations:
|
||||
new:
|
||||
sign_up: "Registrera dig"
|
||||
create:
|
||||
success: "Du har nu gått med i Diaspora!"
|
||||
invitations:
|
||||
create:
|
||||
sent: 'Din inbjudan är nu skickad.'
|
||||
no_more: 'Du har inga fler inbjudningar.'
|
||||
already_sent: 'Du har redan bjudit in denna person.'
|
||||
already_friends: 'Du är redan vän med den här personen'
|
||||
invitation_token_invalid: 'Din inbjudningskod är inte giltig!'
|
||||
updated: 'Ditt lösenord är nu ändrats, och du har loggats in.'
|
||||
|
||||
status_messages:
|
||||
new_status_message:
|
||||
tell_me_something_good: "berätta något intressant"
|
||||
oh_yeah: "oh yeah!"
|
||||
status_message:
|
||||
show_comments: "visa kommentarer"
|
||||
delete: "Ta bort"
|
||||
are_you_sure: "Är du säker?"
|
||||
show:
|
||||
status_message: "Statusmeddelande"
|
||||
comments: "kommentarer"
|
||||
are_you_sure: "Är du säker?"
|
||||
destroy: "Ta bort"
|
||||
view_all: "Visa alla"
|
||||
message: "Meddelande"
|
||||
owner: "Ägare"
|
||||
helper:
|
||||
no_message_to_display: "Inget meddelande att visa."
|
||||
people:
|
||||
person:
|
||||
add_friend: "lägg till vän"
|
||||
pending_request: "väntande förfrågan"
|
||||
index:
|
||||
add_friend: "lägg till vän"
|
||||
real_name: "verkligt namn"
|
||||
diaspora_handle: "diaspora-id"
|
||||
thats_you: "det är du!"
|
||||
friend_request_pending: "förfrågan är skickad"
|
||||
you_have_a_friend_request_from_this_person: "du har en väntande förfrågan från den här personen"
|
||||
new:
|
||||
new_person: "Ny Person"
|
||||
back_to_list: "Tillbaka till listan"
|
||||
show:
|
||||
last_seen: "senast sedd: %{how_long_ago}"
|
||||
friends_since: "vänner sedan: %{how_long_ago}"
|
||||
save: "spara"
|
||||
are_you_sure: "Är du säker?"
|
||||
remove_friend: "ta bort vän"
|
||||
no_posts: "ingenting att visa!"
|
||||
requests:
|
||||
new_request:
|
||||
add_a_new_friend_to: "Lägg till en vän till"
|
||||
enter_a_diaspora_username: "Ange ett Diaspora-id:"
|
||||
your_diaspora_username_is: "Ditt Diaspora-id är: %{diaspora_handle}"
|
||||
friends_username: "Vännens Diaspora-id"
|
||||
destroy:
|
||||
success: "Ni är nu vänner."
|
||||
error: "Var god välj en aspekt!"
|
||||
ignore: "Ignorerade förfrågan."
|
||||
create:
|
||||
error: "Ingen diaspora seed med detta id hittades!"
|
||||
invalid_identity: "Detta id har ett ogiltigt format"
|
||||
error_server: "Problem att kontaka den andra servern. Är det möjligt att den inte finns?"
|
||||
yourself: "Du kan inte fråga dig själv!"
|
||||
already_friends: "Du är redan vän med %{destination_url}!"
|
||||
success: "En förfrågan har skickats till %{destination_url}."
|
||||
horribly_wrong: "Nu gick något rejält fel här."
|
||||
|
|
|
|||
|
|
@ -3,6 +3,8 @@
|
|||
# the COPYRIGHT file.
|
||||
|
||||
require File.join(File.dirname(__FILE__), "..", "..", "config", "environment")
|
||||
require File.join(File.dirname(__FILE__), "..", "..", "spec", "helper_methods")
|
||||
|
||||
|
||||
def set_app_config username
|
||||
current_config = YAML.load(File.read(Rails.root.join('config', 'app_config.yml.example')))
|
||||
|
|
@ -18,7 +20,7 @@ username = "tom"
|
|||
set_app_config username unless File.exists?(Rails.root.join('config', 'app_config.yml'))
|
||||
|
||||
require Rails.root.join('config', "initializers", "_load_app_config.rb")
|
||||
|
||||
include HelperMethods
|
||||
# Create seed user
|
||||
user = User.build( :email => "tom@tom.joindiaspora.com",
|
||||
:username => "tom",
|
||||
|
|
@ -45,6 +47,7 @@ user2.person.save!
|
|||
user2.seed_aspects
|
||||
# friending users
|
||||
aspect = user.aspect(:name => "other dudes")
|
||||
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, user2.person
|
||||
aspect2 = user2.aspect(:name => "presidents")
|
||||
|
||||
friend_users(user, aspect, user2, aspect2)
|
||||
user.aspect(:name => "Presidents")
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
# the COPYRIGHT file.
|
||||
|
||||
require File.join(File.dirname(__FILE__), "..", "..", "config", "environment")
|
||||
require File.join(File.dirname(__FILE__), "..", "..", "spec", "helper_methods")
|
||||
|
||||
def set_app_config username
|
||||
current_config = YAML.load(File.read(Rails.root.join('config', 'app_config.yml.example')))
|
||||
|
|
@ -17,6 +18,7 @@ end
|
|||
set_app_config "tom" unless File.exists?(Rails.root.join('config', 'app_config.yml'))
|
||||
|
||||
require 'config/initializers/_load_app_config.rb'
|
||||
include HelperMethods
|
||||
|
||||
# Create seed user
|
||||
user = User.build( :email => "tom@tom.joindiaspora.com",
|
||||
|
|
@ -41,8 +43,7 @@ user2.seed_aspects
|
|||
user2.person.save!
|
||||
# friending users
|
||||
aspect = user.aspect(:name => "other dudes")
|
||||
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, user2.person
|
||||
user.aspect(:name => "Presidents")
|
||||
aspect2 = user2.aspect(:name => "presidents")
|
||||
|
||||
friend_users(user, aspect, user2, aspect2)
|
||||
user.aspect(:name => "Presidents")
|
||||
|
|
|
|||
|
|
@ -22,16 +22,19 @@ module Diaspora
|
|||
|
||||
xml.parent << user.person.to_xml
|
||||
}
|
||||
|
||||
|
||||
|
||||
xml.aspects {
|
||||
user.aspects.each do |aspect|
|
||||
xml.aspect {
|
||||
xml.name aspect.name
|
||||
|
||||
xml.person_ids {
|
||||
aspect.person_ids.each do |id|
|
||||
xml.person_id id
|
||||
end
|
||||
}
|
||||
# xml.person_ids {
|
||||
#aspect.person_ids.each do |id|
|
||||
#xml.person_id id
|
||||
#end
|
||||
#}
|
||||
|
||||
xml.post_ids {
|
||||
aspect.posts.find_all_by_person_id(user_person_id).each do |post|
|
||||
|
|
@ -42,16 +45,25 @@ module Diaspora
|
|||
end
|
||||
}
|
||||
|
||||
xml.people {
|
||||
xml.contacts {
|
||||
user.friends.each do |friend|
|
||||
xml.parent << friend.to_xml
|
||||
xml.contact {
|
||||
xml.user_id friend.user_id
|
||||
xml.person_id friend.person_id
|
||||
|
||||
xml.aspects {
|
||||
friend.aspects.each do |aspect|
|
||||
xml.aspect {
|
||||
xml.name aspect.name
|
||||
}
|
||||
end
|
||||
}
|
||||
}
|
||||
end
|
||||
}
|
||||
|
||||
xml.posts {
|
||||
user.raw_visible_posts.find_all_by_person_id(user_person_id).each do |post|
|
||||
#post_doc = post.to_xml
|
||||
|
||||
#post.comments.each do |comment|
|
||||
# post_doc << comment.to_xml
|
||||
#end
|
||||
|
|
@ -59,6 +71,14 @@ module Diaspora
|
|||
xml.parent << post.to_xml
|
||||
end
|
||||
}
|
||||
|
||||
xml.people {
|
||||
user.friends.each do |friend|
|
||||
person = friend.person
|
||||
xml.parent << person.to_xml
|
||||
|
||||
end
|
||||
}
|
||||
}
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -9,8 +9,9 @@ module Diaspora
|
|||
self.class.send(:include, strategy)
|
||||
end
|
||||
|
||||
def commit(user, person, aspects, people, posts, opts = {})
|
||||
filter = verify_and_clean(user, person, people, aspects, posts)
|
||||
def commit(user, person, aspects, people, posts, contacts, opts = {})
|
||||
filter = verify_and_clean(user, person, people, aspects, posts, contacts)
|
||||
|
||||
#assume data is good
|
||||
|
||||
# to go
|
||||
|
|
@ -27,11 +28,9 @@ module Diaspora
|
|||
|
||||
user.visible_post_ids = filter[:whitelist].keys
|
||||
|
||||
user.friend_ids = people.collect{ |x| x.id }
|
||||
user.visible_person_ids = user.friend_ids
|
||||
#user.friend_ids =
|
||||
user.visible_person_ids = people.collect{ |x| x.id }
|
||||
|
||||
user.save!
|
||||
user.person.save!
|
||||
|
||||
posts.each do |post|
|
||||
post.save! if filter[:unknown].include? post.id
|
||||
|
|
@ -43,28 +42,60 @@ module Diaspora
|
|||
user.aspects << aspect
|
||||
end
|
||||
|
||||
|
||||
|
||||
people.each do |p|
|
||||
p.save! if filter[:people].include? p.id.to_s
|
||||
end
|
||||
|
||||
contacts.each do |contact|
|
||||
contact.user = user
|
||||
|
||||
user.friends << contact
|
||||
contact.save!
|
||||
end
|
||||
|
||||
|
||||
puts user.persisted?
|
||||
|
||||
puts user.inspect
|
||||
user.save(:validate => false)
|
||||
|
||||
|
||||
end
|
||||
|
||||
def assign_aspect_ids(contacts, aspects)
|
||||
a_hash = {}
|
||||
aspects.each{|x| a_hash[x.name]=x.id}
|
||||
|
||||
contacts.each do |contact|
|
||||
contact.aspect_names.each do |x|
|
||||
contact.aspect_ids << a_hash[x]
|
||||
end
|
||||
contact.aspect_names = nil
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
### verification (to be module) ################
|
||||
|
||||
def verify_and_clean(user, person, people, aspects, posts)
|
||||
def verify_and_clean(user, person, people, aspects, posts, contacts)
|
||||
verify_user(user)
|
||||
verify_person_for_user(user, person)
|
||||
filters = filter_posts(posts, person)
|
||||
|
||||
|
||||
clean_aspects(aspects, filters[:whitelist])
|
||||
filters[:all_person_ids] = people.collect{ |x| x.id.to_id }
|
||||
|
||||
|
||||
raise "incorrect number of contacts" unless verify_contacts(contacts, filters[:all_person_ids])
|
||||
assign_aspect_ids(contacts, aspects)
|
||||
filters[:people] = filter_people(people)
|
||||
filters
|
||||
end
|
||||
|
||||
def verify_contacts(contacts, person_ids)
|
||||
return false if contacts.count != person_ids.count
|
||||
contacts.all?{|x| person_ids.include?(x.person_id)}
|
||||
end
|
||||
|
||||
def verify_user(user)
|
||||
User.find_by_id(user.id).nil? ? true : raise("User already exists!")
|
||||
end
|
||||
|
|
@ -126,11 +157,12 @@ module Diaspora
|
|||
|
||||
user, person = parse_user_and_person(doc)
|
||||
aspects = parse_aspects(doc)
|
||||
contacts = parse_contacts(doc)
|
||||
people = parse_people(doc)
|
||||
posts = parse_posts(doc)
|
||||
|
||||
user
|
||||
commit(user, person, aspects, people, posts, opts)
|
||||
commit(user, person, aspects, people, posts, contacts, opts)
|
||||
end
|
||||
|
||||
def parse_user_and_person(doc)
|
||||
|
|
@ -152,7 +184,6 @@ module Diaspora
|
|||
aspect = Aspect.new
|
||||
aspect.name = a.xpath('/aspect/name').text
|
||||
aspect.post_ids = a.xpath('/aspect/post_ids/post_id').collect{ |x| x.text.to_id }
|
||||
aspect.person_ids = a.xpath('/aspect/person_ids/person_id').collect{ |x| x.text.to_id }
|
||||
aspects << aspect
|
||||
end
|
||||
aspects
|
||||
|
|
@ -165,6 +196,18 @@ module Diaspora
|
|||
end
|
||||
end
|
||||
|
||||
def parse_contacts(doc)
|
||||
contacts = []
|
||||
contact_doc = doc.xpath('/export/contacts/contact')
|
||||
|
||||
contact_doc.each do |x|
|
||||
contact = Contact.new
|
||||
contact.person_id = x.xpath("person_id").text.to_id
|
||||
contact.aspect_names = x.xpath('aspects/aspect/name').collect{ |x| x.text}
|
||||
contacts << contact
|
||||
end
|
||||
contacts
|
||||
end
|
||||
|
||||
def parse_posts(doc)
|
||||
post_doc = doc.xpath('/export/posts/status_message')
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ module Diaspora
|
|||
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}
|
||||
|x| x.person.receive_url == desired_friend.receive_url}
|
||||
request = Request.instantiate(
|
||||
:to => desired_friend.receive_url,
|
||||
:from => self.person,
|
||||
|
|
@ -90,13 +90,15 @@ module Diaspora
|
|||
end
|
||||
|
||||
def remove_friend(bad_friend)
|
||||
raise "Friend not deleted" unless self.friend_ids.delete( bad_friend.id )
|
||||
aspects.each{|aspect|
|
||||
if aspect.person_ids.delete( bad_friend.id )
|
||||
contact = contact_for(bad_friend)
|
||||
raise "Friend not deleted" unless self.friend_ids.delete(contact.id)
|
||||
contact.aspects.each{|aspect|
|
||||
contact.aspects.delete(aspect)
|
||||
aspect.posts.delete_if { |post|
|
||||
post.person_id == bad_friend.id}
|
||||
end}
|
||||
self.save
|
||||
post.person_id == bad_friend.id
|
||||
}
|
||||
aspect.save
|
||||
}
|
||||
|
||||
self.raw_visible_posts.find_all_by_person_id( bad_friend.id ).each{|post|
|
||||
self.visible_post_ids.delete( post.id )
|
||||
|
|
@ -104,7 +106,7 @@ module Diaspora
|
|||
(post.user_refs > 0 || post.person.owner.nil? == false) ? post.save : post.destroy
|
||||
}
|
||||
self.save
|
||||
|
||||
contact.destroy
|
||||
bad_friend.save
|
||||
end
|
||||
|
||||
|
|
@ -114,12 +116,17 @@ module Diaspora
|
|||
end
|
||||
|
||||
def activate_friend(person, aspect)
|
||||
aspect.people << person
|
||||
friends << person
|
||||
new_contact = Contact.create(:user => self, :person => person, :aspects => [aspect])
|
||||
new_contact.aspects << aspect
|
||||
friends << new_contact
|
||||
save
|
||||
aspect.save
|
||||
end
|
||||
|
||||
def contact_for(person)
|
||||
friends.first(:person_id => person.id)
|
||||
end
|
||||
|
||||
def request_from_me?(request)
|
||||
(pending_request_ids.include?(request.id.to_id)) && (request.callback_url == person.receive_url)
|
||||
end
|
||||
|
|
|
|||
|
|
@ -23,14 +23,28 @@ module Diaspora
|
|||
|
||||
def visible_person_by_id( id )
|
||||
id = id.to_id
|
||||
return self.person if id == self.person.id
|
||||
result = friends.detect{|x| x.id == id }
|
||||
result = visible_people.detect{|x| x.id == id } unless result
|
||||
result
|
||||
if id == self.person.id
|
||||
self.person
|
||||
elsif friend = friends.first(:person_id => id)
|
||||
friend.person
|
||||
else
|
||||
visible_people.detect{|x| x.id == id }
|
||||
end
|
||||
end
|
||||
|
||||
def friends_not_in_aspect( aspect )
|
||||
Person.all(:id.in => self.friend_ids, :id.nin => aspect.person_ids)
|
||||
person_ids = Contact.all(:user_id => self.id, :aspect_ids.ne => aspect._id).collect{|x| x.person_id }
|
||||
Person.all(:id.in => person_ids)
|
||||
end
|
||||
|
||||
def person_objects(contacts = self.friends)
|
||||
person_ids = contacts.collect{|x| x.person_id}
|
||||
Person.all(:id.in => person_ids)
|
||||
end
|
||||
|
||||
def people_in_aspects(aspects)
|
||||
person_ids = contacts_in_aspects(aspects).collect{|x| x.person_id}
|
||||
Person.all(:id.in => person_ids)
|
||||
end
|
||||
|
||||
def aspect_by_id( id )
|
||||
|
|
@ -38,22 +52,18 @@ module Diaspora
|
|||
aspects.detect{|x| x.id == id }
|
||||
end
|
||||
|
||||
def find_friend_by_id(id)
|
||||
id = id.to_id
|
||||
friends.detect{|x| x.id == id }
|
||||
end
|
||||
|
||||
def aspects_with_post( id )
|
||||
self.aspects.find_all_by_post_ids( id.to_id )
|
||||
end
|
||||
|
||||
|
||||
def aspects_with_person person
|
||||
aspects.all(:person_ids => person.id)
|
||||
contact_for(person).aspects
|
||||
end
|
||||
|
||||
def people_in_aspects aspects
|
||||
aspects.inject([]) do |found_people,aspect|
|
||||
found_people | aspect.people
|
||||
def contacts_in_aspects aspects
|
||||
aspects.inject([]) do |contacts,aspect|
|
||||
contacts | aspect.people
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -16,11 +16,15 @@ module Diaspora
|
|||
|
||||
sender_in_xml = sender(object, xml)
|
||||
|
||||
if (salmon_author == sender_in_xml)
|
||||
if (salmon_author != sender_in_xml)
|
||||
raise "Malicious Post, #{salmon_author.real_name} with id #{salmon_author.id} is sending a #{object.class} as #{sender_in_xml.real_name} with id #{sender_in_xml.id} "
|
||||
end
|
||||
|
||||
if object.is_a? Request
|
||||
receive_request object, sender_in_xml
|
||||
elsif self.friend_ids.include? salmon_author.id
|
||||
return receive_request object, sender_in_xml
|
||||
end
|
||||
raise "Not friends with that person" unless self.contact_for(salmon_author)
|
||||
|
||||
if object.is_a? Retraction
|
||||
receive_retraction object, xml
|
||||
elsif object.is_a? Profile
|
||||
|
|
@ -30,13 +34,6 @@ module Diaspora
|
|||
else
|
||||
receive_post object, xml
|
||||
end
|
||||
else
|
||||
raise "Not friends with that person"
|
||||
end
|
||||
|
||||
else
|
||||
raise "Malicious Post, #{salmon_author.real_name} with id #{salmon_author.id} is sending a #{object.class} as #{sender_in_xml.real_name} with id #{sender_in_xml.id} "
|
||||
end
|
||||
end
|
||||
|
||||
def sender(object, xml)
|
||||
|
|
@ -72,6 +69,7 @@ module Diaspora
|
|||
request.person = person
|
||||
request.person.save
|
||||
old_request = Request.first(:id => request.id)
|
||||
Rails.logger.info("I got a reqest_id #{request.id} with old request #{old_request.inspect}")
|
||||
request.aspect_id = old_request.aspect_id if old_request
|
||||
request.save
|
||||
receive_friend_request(request)
|
||||
|
|
|
|||
|
|
@ -105,8 +105,12 @@ header
|
|||
:margin -2em
|
||||
:bottom 2em
|
||||
:color #000
|
||||
|
||||
:background
|
||||
:color #333
|
||||
:background -webkit-gradient( linear, left bottom, left top, color-stop(0.01, rgb(31,31,31)), color-stop(0.12, rgb(51,51,51)))
|
||||
:background -moz-linear-gradient( center bottom, rgb(31,31,31) 1%, rgb(51,51,51) 12%)
|
||||
|
||||
:padding 0
|
||||
:top 5px
|
||||
:color #CCC
|
||||
|
|
@ -874,7 +878,7 @@ h1.big_text
|
|||
:font
|
||||
:weight bold
|
||||
:background
|
||||
:color rgba(252,252,252,1)
|
||||
:color rgb(252,252,252)
|
||||
|
||||
:color #444
|
||||
&:hover
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ describe AspectsController do
|
|||
@user2 = Factory.create(:user)
|
||||
@aspect2 = @user2.aspect(:name => "party people")
|
||||
friend_users(@user,@aspect, @user2, @aspect2)
|
||||
@contact = @user.contact_for(@user2.person)
|
||||
sign_in :user, @user
|
||||
end
|
||||
|
||||
|
|
@ -21,7 +22,7 @@ describe AspectsController do
|
|||
it "assigns @friends to all the user's friends" do
|
||||
Factory.create :person
|
||||
get :index
|
||||
assigns[:friends].should == @user.friends
|
||||
assigns[:friends].should == @user.person_objects
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -53,7 +54,8 @@ describe AspectsController do
|
|||
describe "#move_friend" do
|
||||
let(:opts) { {:friend_id => "person_id", :from => "from_aspect_id", :to => {:to => "to_aspect_id"}}}
|
||||
it 'calls the move_friend_method' do
|
||||
pending "need to figure out how to stub current_user to return our test @user"
|
||||
pending "need to figure out what is the deal with remote requests"
|
||||
@controller.stub!(:current_user).and_return(@user)
|
||||
@user.should_receive(:move_friend).with( :friend_id => "person_id", :from => "from_aspect_id", :to => "to_aspect_id")
|
||||
post :move_friend, opts
|
||||
end
|
||||
|
|
@ -75,20 +77,20 @@ describe AspectsController do
|
|||
describe "#add_to_aspect" do
|
||||
it 'adds the users to the aspect' do
|
||||
@aspect1.reload
|
||||
@aspect1.people.include?(@user2.person).should be false
|
||||
@aspect1.people.include?(@contact).should be false
|
||||
post 'add_to_aspect', {:friend_id => @user2.person.id, :aspect_id => @aspect1.id }
|
||||
@aspect1.reload
|
||||
@aspect1.people.include?(@user2.person).should be true
|
||||
@aspect1.people.include?(@contact).should be true
|
||||
end
|
||||
end
|
||||
|
||||
describe "#remove_from_aspect" do
|
||||
it 'adds the users to the aspect' do
|
||||
@aspect.reload
|
||||
@aspect.people.include?(@user2.person).should be true
|
||||
@aspect.people.include?(@contact).should be true
|
||||
post 'remove_from_aspect', {:friend_id => @user2.person.id, :aspect_id => @aspect1.id }
|
||||
@aspect1.reload
|
||||
@aspect1.people.include?(@user2.person).should be false
|
||||
@aspect1.people.include?(@contact).should be false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
85
spec/helper_methods.rb
Normal file
85
spec/helper_methods.rb
Normal file
|
|
@ -0,0 +1,85 @@
|
|||
module HelperMethods
|
||||
def stub_sockets
|
||||
Diaspora::WebSocket.stub!(:queue_to_user).and_return(true)
|
||||
Diaspora::WebSocket.stub!(:subscribe).and_return(true)
|
||||
Diaspora::WebSocket.stub!(:unsubscribe).and_return(true)
|
||||
end
|
||||
|
||||
def unstub_sockets
|
||||
Diaspora::WebSocket.unstub!(:queue_to_user)
|
||||
Diaspora::WebSocket.unstub!(:subscribe)
|
||||
Diaspora::WebSocket.unstub!(:unsubscribe)
|
||||
end
|
||||
|
||||
def stub_comment_signature_verification
|
||||
Comment.any_instance.stubs(:verify_signature).returns(true)
|
||||
end
|
||||
|
||||
def unstub_mocha_stubs
|
||||
Mocha::Mockery.instance.stubba.unstub_all
|
||||
end
|
||||
|
||||
def get_models
|
||||
models = []
|
||||
Dir.glob( File.dirname(__FILE__) + '/../app/models/*' ).each do |f|
|
||||
models << File.basename( f ).gsub( /^(.+).rb/, '\1')
|
||||
end
|
||||
models
|
||||
end
|
||||
|
||||
def message_queue
|
||||
User::QUEUE
|
||||
end
|
||||
|
||||
def friend_users(user1, aspect1, user2, aspect2)
|
||||
request = user1.send_friend_request_to(user2.person, aspect1)
|
||||
user2.receive_friend_request(request)
|
||||
reversed_request = user2.accept_friend_request( request.id, aspect2.id)
|
||||
user1.reload
|
||||
user1.receive reversed_request.to_diaspora_xml, user2.person
|
||||
user1.reload
|
||||
aspect1.reload
|
||||
user2.reload
|
||||
aspect2.reload
|
||||
end
|
||||
|
||||
def stub_success(address = 'abc@example.com', opts = {})
|
||||
host = address.split('@')[1]
|
||||
stub_request(:get, "https://#{host}/.well-known/host-meta").to_return(:status => 200, :body => host_xrd)
|
||||
stub_request(:get, "http://#{host}/.well-known/host-meta").to_return(:status => 200, :body => host_xrd)
|
||||
if opts[:diaspora] || host.include?("diaspora")
|
||||
stub_request(:get, /webfinger\/\?q=#{address}/).to_return(:status => 200, :body => finger_xrd)
|
||||
stub_request(:get, "http://#{host}/hcard/users/4c8eccce34b7da59ff000002").to_return(:status => 200, :body => hcard_response)
|
||||
else
|
||||
stub_request(:get, /webfinger\/\?q=#{address}/).to_return(:status => 200, :body => nonseed_finger_xrd)
|
||||
stub_request(:get, 'http://evan.status.net/hcard').to_return(:status => 200, :body => evan_hcard)
|
||||
end
|
||||
end
|
||||
|
||||
def stub_failure(address = 'abc@example.com')
|
||||
host = address.split('@')[1]
|
||||
stub_request(:get, "https://#{host}/.well-known/host-meta").to_return(:status => 200, :body => host_xrd)
|
||||
stub_request(:get, "http://#{host}/.well-known/host-meta").to_return(:status => 200, :body => host_xrd)
|
||||
stub_request(:get, /webfinger\/\?q=#{address}/).to_return(:status => 500)
|
||||
end
|
||||
|
||||
def host_xrd
|
||||
File.open(File.dirname(__FILE__) + '/fixtures/host_xrd').read
|
||||
end
|
||||
|
||||
def finger_xrd
|
||||
File.open(File.dirname(__FILE__) + '/fixtures/finger_xrd').read
|
||||
end
|
||||
|
||||
def hcard_response
|
||||
File.open(File.dirname(__FILE__) + '/fixtures/hcard_response').read
|
||||
end
|
||||
|
||||
def nonseed_finger_xrd
|
||||
File.open(File.dirname(__FILE__) + '/fixtures/nonseed_finger_xrd').read
|
||||
end
|
||||
|
||||
def evan_hcard
|
||||
File.open(File.dirname(__FILE__) + '/fixtures/evan_hcard').read
|
||||
end
|
||||
end
|
||||
|
|
@ -11,6 +11,7 @@ describe Diaspora::Exporter do
|
|||
let!(:user2) { Factory(:user) }
|
||||
let!(:user3) { Factory(:user) }
|
||||
|
||||
let!(:aspect) { user1.aspect(:name => "Old Work") }
|
||||
let(:aspect1) { user1.aspect(:name => "Work") }
|
||||
let(:aspect2) { user2.aspect(:name => "Family") }
|
||||
let(:aspect3) { user3.aspect(:name => "Pivots") }
|
||||
|
|
@ -19,47 +20,84 @@ describe Diaspora::Exporter do
|
|||
let!(:status_message2) { user1.post(:status_message, :message => "Two", :public => true, :to => aspect1.id) }
|
||||
let!(:status_message3) { user2.post(:status_message, :message => "Three", :public => false, :to => aspect2.id) }
|
||||
|
||||
let(:exported) { Diaspora::Exporter.new(Diaspora::Exporters::XML).execute(user1) }
|
||||
|
||||
it 'should include a users posts' do
|
||||
exported.should include status_message1.message
|
||||
exported.should include status_message2.message
|
||||
exported.should_not include status_message3.message
|
||||
end
|
||||
let(:exported) { Nokogiri::XML(Diaspora::Exporter.new(Diaspora::Exporters::XML).execute(user1)) }
|
||||
|
||||
context '<user/>' do
|
||||
let(:user_xml) {exported.xpath('//user').to_s}
|
||||
it 'should include a users private key' do
|
||||
exported.should include user1.serialized_private_key
|
||||
user_xml.to_s.should include user1.serialized_private_key
|
||||
end
|
||||
end
|
||||
|
||||
it 'should include post_ids' do
|
||||
doc = Nokogiri::XML::parse(exported)
|
||||
doc.xpath('//aspects').to_s.should include status_message1.id.to_s
|
||||
context '<aspects/>' do
|
||||
let(:aspects_xml) {exported.xpath('//aspects').to_s}
|
||||
it 'should include the aspect name' do
|
||||
|
||||
doc.xpath('//aspects').to_s.should include status_message2.id.to_s
|
||||
doc.xpath('//posts').to_s.should include status_message1.id.to_s
|
||||
end
|
||||
|
||||
it 'should include the post_ids' do
|
||||
aspects_xml.should include status_message1.id.to_s
|
||||
aspects_xml.should include status_message2.id.to_s
|
||||
end
|
||||
end
|
||||
|
||||
context '<contacts/>' do
|
||||
|
||||
before do
|
||||
friend_users(user1, aspect1, user3, aspect3)
|
||||
user1.add_person_to_aspect(user3.person.id, aspect.id)
|
||||
user1.reload
|
||||
end
|
||||
|
||||
let(:contacts_xml) {exported.xpath('//contacts').to_s}
|
||||
it 'should include a person id' do
|
||||
contacts_xml.should include user3.person.id.to_s
|
||||
end
|
||||
|
||||
it 'should include an aspects names of all aspects they are in' do
|
||||
#contact specific xml needs to be tested
|
||||
user1.friends.find_by_person_id(user3.person.id).aspects.count.should > 0
|
||||
user1.friends.find_by_person_id(user3.person.id).aspects.each { |aspect|
|
||||
contacts_xml.should include aspect.name
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
context '<people/>' do
|
||||
let(:people_xml) {exported.xpath('//people').to_s}
|
||||
before do
|
||||
friend_users(user1, aspect1, user3, aspect3)
|
||||
user1.reload
|
||||
end
|
||||
it 'should include persons id' do
|
||||
people_xml.should include user3.person.id.to_s
|
||||
end
|
||||
|
||||
it 'should include their profile' do
|
||||
people_xml.should include user3.person.profile.first_name
|
||||
people_xml.should include user3.person.profile.last_name
|
||||
end
|
||||
|
||||
it 'should include their public key' do
|
||||
people_xml.should include user3.person.exported_key
|
||||
end
|
||||
|
||||
it 'should include their diaspora handle' do
|
||||
people_xml.should include user3.person.diaspora_handle
|
||||
end
|
||||
end
|
||||
|
||||
context '<posts>' do
|
||||
let(:posts_xml) {exported.xpath('//posts').to_s}
|
||||
it 'should include many posts xml' do
|
||||
posts_xml.should include status_message1.message
|
||||
posts_xml.should include status_message2.message
|
||||
posts_xml.should_not include status_message3.message
|
||||
end
|
||||
|
||||
it 'should include post created at time' do
|
||||
doc = Nokogiri::XML::parse(exported)
|
||||
doc = Nokogiri::XML::parse(posts_xml)
|
||||
Time.parse(doc.xpath('//posts/status_message/created_at').first.text).should == status_message1.created_at
|
||||
end
|
||||
|
||||
it 'should include a list of users posts' do
|
||||
doc = Nokogiri::XML::parse(exported)
|
||||
posts = doc.xpath('//posts').to_s
|
||||
posts.should include(status_message1.message)
|
||||
end
|
||||
|
||||
it 'should serialize a users friends' do
|
||||
friend_users(user1, aspect1, user3, aspect3)
|
||||
doc = Nokogiri::XML::parse(exported)
|
||||
doc.xpath('/export/people').to_s.should include user3.person.id.to_s
|
||||
end
|
||||
|
||||
it 'should serialize only a users posts within his aspects' do
|
||||
message = Factory(:status_message, :message => "Shouldn't be here", :person => user3.person)
|
||||
aspect1.posts << message
|
||||
doc = Nokogiri::XML::parse(exported)
|
||||
doc.xpath('/export/aspects').to_s.should_not include message.message
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -73,14 +73,14 @@ describe Diaspora::Importer do
|
|||
|
||||
@user1.friends.count.should be 4
|
||||
|
||||
@user1.friends.should include @user2.person
|
||||
@user1.friends.should include @user3.person
|
||||
@user1.friends.should include @user4.person
|
||||
@user1.friends.should include @user5.person
|
||||
@user1.contact_for(@user2.person).should_not be_nil
|
||||
@user1.contact_for(@user3.person).should_not be_nil
|
||||
@user1.contact_for(@user4.person).should_not be_nil
|
||||
@user1.contact_for(@user5.person).should_not be_nil
|
||||
|
||||
# User is generated with two pre-populated aspects
|
||||
@user1.aspects.count.should be 6
|
||||
@user1.aspects.find_by_name("Dudes").people.should include @user2.person
|
||||
@user1.aspects.find_by_name("Dudes").people.find_by_person_id(@user2.person.id).should_not be_nil
|
||||
@user1.aspects.find_by_name("Dudes").posts.should include @status_message5
|
||||
|
||||
@user1.raw_visible_posts.count.should be 6
|
||||
|
|
@ -137,9 +137,21 @@ describe Diaspora::Importer do
|
|||
it 'should should have post ids' do
|
||||
aspects.any?{|x| x.post_ids.count > 0}.should be true
|
||||
end
|
||||
end
|
||||
|
||||
it 'should have person ids' do
|
||||
aspects.any?{|x| x.person_ids.count > 0}.should be true
|
||||
describe '#parse_contacts' do
|
||||
let(:contacts) { @importer.parse_contacts(@doc) }
|
||||
|
||||
it 'should return an array' do
|
||||
contacts.count.should == 4
|
||||
end
|
||||
|
||||
it 'should should have post ids' do
|
||||
contacts.all?{|x| x.aspect_names.count > 0}.should be true
|
||||
end
|
||||
|
||||
it 'should should have a person id' do
|
||||
contacts.all?{|x| x.person_id.nil? || x.person_id == ""}.should be false
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -172,9 +184,10 @@ describe Diaspora::Importer do
|
|||
# Generate exported XML for user1
|
||||
exporter = Diaspora::Exporter.new(Diaspora::Exporters::XML)
|
||||
@xml = exporter.execute(@user1)
|
||||
|
||||
@username =@user1.username
|
||||
# Remove user1 from the server
|
||||
@user1.aspects.each( &:delete )
|
||||
@user1.friends.each( &:delete )
|
||||
@user1.raw_visible_posts.find_all_by_person_id(@user1.person.id).each( &:delete )
|
||||
@user1.delete
|
||||
|
||||
|
|
@ -182,12 +195,15 @@ describe Diaspora::Importer do
|
|||
end
|
||||
|
||||
it 'should import' do
|
||||
pending "there is some weirdness with diaspora handle we need to look into... and this test is terrible"
|
||||
pending "there is some weirdness with diaspora handle we need to look into... and this test needs love
|
||||
the test passes when the validations are set to false when saving the user in the importer"
|
||||
|
||||
User.delete_all
|
||||
Person.delete_all
|
||||
Post.delete_all
|
||||
StatusMessage.delete_all
|
||||
Aspect.delete_all
|
||||
Contact.delete_all
|
||||
|
||||
User.count.should == 0
|
||||
Person.count.should == 0
|
||||
|
|
@ -196,15 +212,18 @@ describe Diaspora::Importer do
|
|||
:email => "bob@bob.com",
|
||||
:password => "bobbybob",
|
||||
:password => "bobbybob",
|
||||
:diaspora_handle => "bob@diaspora.com")
|
||||
:diaspora_handle => "#{@username}@#{APP_CONFIG[:terse_pod_url]}")
|
||||
|
||||
User.count.should == 1
|
||||
n = User.first
|
||||
Post.count.should == 4
|
||||
n.aspects.count.should == 6
|
||||
Person.count.should be == 5
|
||||
Contact.count.should be == 4
|
||||
|
||||
User.first.person.diaspora_handle.should == User.first.diaspora_handle
|
||||
# need to check this
|
||||
#User.first.person.diaspora_handle.should == User.first.diaspora_handle
|
||||
User.first.diaspora_handle.should == "#{@username}@#{APP_CONFIG[:terse_pod_url]}"
|
||||
|
||||
|
||||
Person.find_by_id( @user1.person.id ).nil?.should == false
|
||||
|
|
@ -223,12 +242,7 @@ describe Diaspora::Importer do
|
|||
|
||||
n.friends.count.should be 4
|
||||
end
|
||||
|
||||
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -99,8 +99,9 @@ describe Diaspora::Parser do
|
|||
|
||||
user.reload
|
||||
aspect.reload
|
||||
aspect.people.include?(new_person).should be true
|
||||
user.friends.include?(new_person).should be true
|
||||
new_contact = user.contact_for(new_person)
|
||||
aspect.people.include?(new_contact).should be true
|
||||
user.friends.include?(new_contact).should be true
|
||||
end
|
||||
|
||||
it 'should process retraction for a person' do
|
||||
|
|
|
|||
|
|
@ -51,6 +51,23 @@ describe Diaspora::Importer do
|
|||
end
|
||||
end
|
||||
|
||||
describe 'verify contacts' do
|
||||
let(:contact1) {Contact.new(:user => user1, :person => user2.person, :aspects => [aspect1])}
|
||||
let(:contact2) {Contact.new(:user => user1, :person => user3.person, :aspects => [aspect2])}
|
||||
let(:contact3) {Contact.new(:user => user1, :person => user3.person, :aspects => [aspect3])}
|
||||
let(:less_contacts) {[contact1]}
|
||||
let(:same_contacts) {[contact1, contact2]}
|
||||
let(:more_contacts) {[contact1, contact2, contact3]}
|
||||
|
||||
let(:person_ids) {[user2.person.id, user3.person.id]}
|
||||
|
||||
|
||||
it 'should be false if the number of the number of contacts is not equal to the number of imported people' do
|
||||
importer.verify_contacts(less_contacts, person_ids).should be false
|
||||
importer.verify_contacts(same_contacts, person_ids).should be true
|
||||
importer.verify_contacts(more_contacts, person_ids).should be false
|
||||
end
|
||||
end
|
||||
|
||||
describe '#filter_posts' do
|
||||
it 'should make sure all found posts are owned by the user' do
|
||||
|
|
|
|||
|
|
@ -11,6 +11,15 @@ describe 'making sure the spec runner works' do
|
|||
loaded_user.person.owner_id.should == user.id
|
||||
end
|
||||
|
||||
describe 'factories' do
|
||||
describe 'build' do
|
||||
it 'does not save a built user' do
|
||||
pending "This problem is bizarre and needs fixing"
|
||||
Factory.build(:user).persisted?.should be_false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe '#friend_users' do
|
||||
before do
|
||||
@user1 = Factory.create(:user)
|
||||
|
|
@ -18,18 +27,20 @@ describe 'making sure the spec runner works' do
|
|||
@user2 = Factory.create(:user)
|
||||
@aspect2 = @user2.aspect(:name => "bruisers")
|
||||
friend_users(@user1, @aspect1, @user2, @aspect2)
|
||||
@user1.reload
|
||||
@aspect1.reload
|
||||
@user2.reload
|
||||
@aspect2.reload
|
||||
end
|
||||
|
||||
it 'makes the first user friends with the second' do
|
||||
@aspect1.people.include?(@user2.person).should be_true
|
||||
contact = @user1.contact_for @user2.person
|
||||
@user1.friends.include?(contact).should be_true
|
||||
@aspect1.people.include?(contact).should be_true
|
||||
contact.aspects.include?( @aspect1 ).should be true
|
||||
end
|
||||
|
||||
it 'makes the second user friends with the first' do
|
||||
@aspect2.people.include?(@user1.person).should be_true
|
||||
contact = @user2.contact_for @user1.person
|
||||
@user2.friends.include?(contact).should be_true
|
||||
@aspect2.people.include?(contact).should be_true
|
||||
contact.aspects.include?( @aspect2 ).should be true
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -29,15 +29,17 @@ describe Aspect do
|
|||
end
|
||||
|
||||
it 'should be able to have other users' do
|
||||
aspect.people << user2.person
|
||||
aspect.people.include?(user.person).should be false
|
||||
aspect.people.include?(user2.person).should be true
|
||||
Contact.create(:user => user, :person => user2.person, :aspects => [aspect])
|
||||
aspect.people.first(:person_id => user.person.id).should be_nil
|
||||
aspect.people.first(:person_id => user2.person.id).should_not be_nil
|
||||
aspect.people.size.should == 1
|
||||
end
|
||||
|
||||
it 'should be able to have users and people' do
|
||||
aspect.people << user2.person
|
||||
aspect.people << friend_2
|
||||
contact1 = Contact.create(:user => user, :person => user2.person, :aspects => [aspect])
|
||||
contact2 = Contact.create(:user => user, :person => friend_2, :aspects => [aspect])
|
||||
aspect.people.include?(contact1).should be_true
|
||||
aspect.people.include?(contact2).should be_true
|
||||
aspect.save.should be_true
|
||||
end
|
||||
end
|
||||
|
|
@ -69,7 +71,7 @@ describe Aspect do
|
|||
end
|
||||
|
||||
it 'should have people' do
|
||||
aspect.people.all.include?(friend).should be true
|
||||
aspect.people.first(:person_id => friend.id).should be_true
|
||||
aspect.people.size.should == 1
|
||||
end
|
||||
|
||||
|
|
@ -87,8 +89,9 @@ describe Aspect do
|
|||
user.add_person_to_aspect(friend.id, aspect1.id)
|
||||
aspects = user.aspects_with_person(friend)
|
||||
aspects.count.should == 2
|
||||
aspects.each{ |asp| asp.people.include?(friend) }
|
||||
aspects.should_not include aspect_without_friend
|
||||
contact = user.contact_for(friend)
|
||||
aspects.each{ |asp| asp.people.include?(contact).should be_true }
|
||||
aspects.include?(aspect_without_friend).should be_false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -140,6 +143,7 @@ describe Aspect do
|
|||
end
|
||||
|
||||
context "aspect management" do
|
||||
let(:contact){user.contact_for(user2.person)}
|
||||
before do
|
||||
friend_users(user, aspect, user2, aspect2)
|
||||
aspect.reload
|
||||
|
|
@ -149,10 +153,10 @@ describe Aspect do
|
|||
|
||||
describe "#add_person_to_aspect" do
|
||||
it 'adds the user to the aspect' do
|
||||
aspect1.people.should_not include user2.person
|
||||
aspect1.people.include?(contact).should be_false
|
||||
user.add_person_to_aspect(user2.person.id, aspect1.id)
|
||||
aspect1.reload
|
||||
aspect1.people.should include user2.person
|
||||
aspect1.people.include?(contact).should be_true
|
||||
end
|
||||
|
||||
it 'raises if its an aspect that the user does not own'do
|
||||
|
|
@ -172,10 +176,10 @@ describe Aspect do
|
|||
it 'deletes a user from the aspect' do
|
||||
user.add_person_to_aspect(user2.person.id, aspect1.id)
|
||||
user.reload
|
||||
user.aspects.find_by_id(aspect1.id).people.include?(user2.person).should be true
|
||||
aspect1.reload.people.include?(contact).should be true
|
||||
user.delete_person_from_aspect(user2.person.id, aspect1.id)
|
||||
user.reload
|
||||
user.aspects.find_by_id(aspect1.id).people.include?(user2.person).should be false
|
||||
aspect1.reload.people.include?(contact).should be false
|
||||
end
|
||||
|
||||
it 'should check to make sure you have the aspect ' do
|
||||
|
|
@ -189,9 +193,7 @@ describe Aspect do
|
|||
let(:message2){user3.post(:status_message, :message => "other post", :to => aspect3.id)}
|
||||
|
||||
before do
|
||||
friend_users(user, aspect, user3, aspect3)
|
||||
user.receive message.to_diaspora_xml, user2.person
|
||||
user.receive message2.to_diaspora_xml, user3.person
|
||||
aspect.reload
|
||||
@post_count = aspect.posts.count
|
||||
@post_count1 = aspect1.posts.count
|
||||
|
|
@ -213,6 +215,8 @@ describe Aspect do
|
|||
end
|
||||
|
||||
it 'should not delete other peoples posts' do
|
||||
friend_users(user, aspect, user3, aspect3)
|
||||
user.receive message2.to_diaspora_xml, user3.person
|
||||
user.delete_person_from_aspect(user2.person.id, aspect.id)
|
||||
aspect.reload
|
||||
aspect.posts.should == [message2]
|
||||
|
|
@ -224,24 +228,24 @@ describe Aspect do
|
|||
aspect.reload
|
||||
aspect1.reload
|
||||
|
||||
aspect.person_ids.include?(user2.person.id).should be false
|
||||
aspect1.people.include?(user2.person).should be true
|
||||
aspect.people.include?(contact).should be_false
|
||||
aspect1.people.include?(contact).should be_true
|
||||
end
|
||||
|
||||
it "should not move a person who is not a friend" do
|
||||
proc{ user.move_friend(:friend_id => friend.id, :from => aspect.id, :to => aspect1.id) }.should raise_error /Can not add person you are not friends with/
|
||||
aspect.reload
|
||||
aspect1.reload
|
||||
aspect.people.include?(friend).should be false
|
||||
aspect1.people.include?(friend).should be false
|
||||
aspect.people.first(:person_id => friend.id).should be_nil
|
||||
aspect1.people.first(:person_id => friend.id).should be_nil
|
||||
end
|
||||
|
||||
it "should not move a person to a aspect that's not his" do
|
||||
proc {user.move_friend(:friend_id => user2.person.id, :from => aspect.id, :to => aspect2.id )}.should raise_error /Can not add person to an aspect you do not own/
|
||||
aspect.reload
|
||||
aspect2.reload
|
||||
aspect.people.include?(user2.person).should be true
|
||||
aspect2.people.include?(user2.person).should be false
|
||||
aspect.people.include?(contact).should be true
|
||||
aspect2.people.include?(contact).should be false
|
||||
end
|
||||
|
||||
it 'should move all posts by that user to the new aspect' do
|
||||
|
|
|
|||
31
spec/models/contact_spec.rb
Normal file
31
spec/models/contact_spec.rb
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
# Copyright (c) 2010, Diaspora Inc. This file is
|
||||
# licensed under the Affero General Public License version 3 or later. See
|
||||
# the COPYRIGHT file.
|
||||
|
||||
require 'spec_helper'
|
||||
|
||||
describe Contact do
|
||||
describe 'validations' do
|
||||
let(:contact){Contact.new}
|
||||
|
||||
it 'requires a user' do
|
||||
contact.valid?
|
||||
contact.errors.full_messages.should include "User can't be blank"
|
||||
end
|
||||
|
||||
it 'requires a person' do
|
||||
contact.valid?
|
||||
contact.errors.full_messages.should include "Person can't be blank"
|
||||
end
|
||||
|
||||
it 'has many aspects' do
|
||||
contact.associations[:aspects].type.should == :many
|
||||
end
|
||||
|
||||
it 'has at least one aspect' do
|
||||
contact.valid?
|
||||
contact.errors.full_messages.should include "Aspects can't be blank"
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
|
@ -68,7 +68,7 @@ describe User do
|
|||
it 'throws if you try to add someone you"re friends with' do
|
||||
friend_users(inviter, aspect, another_user, wrong_aspect)
|
||||
inviter.reload
|
||||
proc{inviter.invite_user(:email => another_user.email, :aspect_id => aspect.id)}.should raise_error /You are already friends with this person/
|
||||
proc{inviter.invite_user(:email => another_user.email, :aspect_id => aspect.id)}.should raise_error /You are already friends with that person/
|
||||
end
|
||||
|
||||
it 'sends a friend request to a user with that email into the aspect' do
|
||||
|
|
@ -126,7 +126,7 @@ describe User do
|
|||
u.reload
|
||||
inviter
|
||||
inviter.receive_salmon(u.salmon(u.accept_friend_request(request.id, aspect2.id)).xml_for(inviter.person))
|
||||
inviter.friends.include?(u.person).should be true
|
||||
inviter.contact_for(u.person).should_not be_nil
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -61,30 +61,47 @@ describe User do
|
|||
let!(:user) {Factory :user}
|
||||
let!(:first_aspect) {user.aspect(:name => 'bruisers')}
|
||||
let!(:second_aspect) {user.aspect(:name => 'losers')}
|
||||
let!(:user4) { Factory.create(:user_with_aspect)}
|
||||
|
||||
before do
|
||||
friend_users(user, first_aspect, user4, user4.aspects.first)
|
||||
friend_users(user, second_aspect, user2, user2.aspects.first)
|
||||
end
|
||||
|
||||
describe '#friends_not_in_aspect' do
|
||||
it 'finds the people who are not in the given aspect' do
|
||||
user4 = Factory.create(:user_with_aspect)
|
||||
friend_users(user, first_aspect, user4, user4.aspects.first)
|
||||
friend_users(user, second_aspect, user2, user2.aspects.first)
|
||||
|
||||
people = user.friends_not_in_aspect(first_aspect)
|
||||
people.should == [user2.person]
|
||||
end
|
||||
end
|
||||
|
||||
describe '#find_friend_by_id' do
|
||||
it 'should find a friend' do
|
||||
friend_users(user, first_aspect, user2, user2.aspects.first)
|
||||
user.find_friend_by_id(user2.person.id).should == user2.person
|
||||
describe '#person_objects' do
|
||||
it 'returns "person" objects for all of my friends' do
|
||||
people = user.person_objects
|
||||
people.size.should == 2
|
||||
[user4.person, user2.person].each{ |p| people.should include p }
|
||||
end
|
||||
|
||||
it 'should not find a non-friend' do
|
||||
user = Factory :user
|
||||
user.find_friend_by_id(user2.person.id).should be nil
|
||||
it 'should return people objects given a collection of contacts' do
|
||||
target_contacts = [user.contact_for(user2.person)]
|
||||
people = user.person_objects(target_contacts)
|
||||
people.should == [user2.person]
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
describe '#people_in_aspects' do
|
||||
it 'should return people objects for a users friend in each aspect' do
|
||||
people = user.people_in_aspects([first_aspect])
|
||||
people.should == [user4.person]
|
||||
people = user.people_in_aspects([second_aspect])
|
||||
people.should == [user2.person]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
describe '#albums_by_aspect' do
|
||||
let!(:first_aspect) {user2.aspect(:name => 'bruisers')}
|
||||
let!(:second_aspect) {user2.aspect(:name => 'losers')}
|
||||
|
|
@ -23,10 +23,9 @@ describe User do
|
|||
status_message = user2.post :status_message, :message => 'store this!', :to => aspect2.id
|
||||
|
||||
xml = status_message.to_diaspora_xml
|
||||
user2.destroy
|
||||
user2.delete
|
||||
status_message.destroy
|
||||
|
||||
user
|
||||
lambda {user.receive xml , user2.person}.should change(Post,:count).by(1)
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ describe Diaspora::UserModules::Friending do
|
|||
|
||||
let(:person_one) { Factory.create :person }
|
||||
let(:person_two) { Factory.create :person }
|
||||
let(:person_three) { Factory.create :person }
|
||||
|
||||
let(:user2) { Factory.create :user }
|
||||
let(:aspect2) { user2.aspect(:name => "aspect two") }
|
||||
|
|
@ -24,6 +25,41 @@ describe Diaspora::UserModules::Friending do
|
|||
Notifier.stub!(:request_accepted).and_return(deliverable)
|
||||
end
|
||||
|
||||
|
||||
describe '#contact_for' do
|
||||
|
||||
it 'returns a contact' do
|
||||
contact = Contact.create(:user => user, :person => person_one, :aspects => [aspect])
|
||||
user.friends << contact
|
||||
user.contact_for(person_one).should be_true
|
||||
end
|
||||
|
||||
it 'returns the correct contact' do
|
||||
contact = Contact.create(:user => user, :person => person_one, :aspects => [aspect])
|
||||
user.friends << contact
|
||||
|
||||
contact2 = Contact.create(:user => user, :person => person_two, :aspects => [aspect])
|
||||
user.friends << contact2
|
||||
|
||||
contact3 = Contact.create(:user => user, :person => person_three, :aspects => [aspect])
|
||||
user.friends << contact3
|
||||
|
||||
user.contact_for(person_two).person.should == person_two
|
||||
end
|
||||
|
||||
it 'returns nil for a non-contact' do
|
||||
user.contact_for(person_one).should be_nil
|
||||
end
|
||||
|
||||
it 'returns nil when someone else has contact with the target' do
|
||||
contact = Contact.create(:user => user, :person => person_one, :aspects => [aspect])
|
||||
user.friends << contact
|
||||
user2.contact_for(person_one).should be_nil
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
context 'friend requesting' do
|
||||
it "should assign a request to a aspect for the user that sent it out" do
|
||||
aspect.requests.size.should == 0
|
||||
|
|
@ -67,16 +103,15 @@ describe Diaspora::UserModules::Friending do
|
|||
end
|
||||
|
||||
it 'should be able to ignore a pending friend request' do
|
||||
proc { user.ignore_friend_request(request_for_user.id) }.should change (
|
||||
proc { user.ignore_friend_request(request_for_user.id) }.should change(
|
||||
user.reload.pending_requests, :count ).by(-1)
|
||||
end
|
||||
end
|
||||
|
||||
it 'should not be able to friend request an existing friend' do
|
||||
user.friends << friend
|
||||
user.save
|
||||
friend_users(user, aspect, user2, aspect2)
|
||||
|
||||
proc { user.send_friend_request_to(friend, aspect) }.should raise_error
|
||||
proc { user.send_friend_request_to(user2.person, aspect1) }.should raise_error
|
||||
end
|
||||
|
||||
it 'should not be able to friend request yourself' do
|
||||
|
|
@ -120,14 +155,14 @@ describe Diaspora::UserModules::Friending do
|
|||
proc {
|
||||
user2.accept_friend_request @request_three.id, aspect2.id
|
||||
}.should_not change(Person, :count)
|
||||
user2.friends.include?(user.person).should be true
|
||||
user2.contact_for(user.person).should_not be_nil
|
||||
end
|
||||
|
||||
it 'should not delete the ignored user on the same pod' do
|
||||
proc {
|
||||
user2.ignore_friend_request @request_three.id
|
||||
}.should_not change(Person, :count)
|
||||
user2.friends.include?(user.person).should be false
|
||||
user2.contact_for(user.person).should be_nil
|
||||
end
|
||||
|
||||
it 'sends an email to the receiving user' do
|
||||
|
|
@ -139,6 +174,7 @@ describe Diaspora::UserModules::Friending do
|
|||
|
||||
|
||||
end
|
||||
|
||||
context 'Two users receiving requests from one person' do
|
||||
before do
|
||||
user.receive @req_xml, person_one
|
||||
|
|
@ -148,28 +184,28 @@ describe Diaspora::UserModules::Friending do
|
|||
describe '#accept_friend_request' do
|
||||
it 'should both users should befriend the same person' do
|
||||
user.accept_friend_request @request.id, aspect.id
|
||||
user.friends.include?(person_one).should be true
|
||||
user.contact_for(person_one).should_not be_nil
|
||||
|
||||
user2.accept_friend_request @request_two.id, aspect2.id
|
||||
user2.friends.include?(person_one).should be true
|
||||
user2.contact_for(person_one).should_not be_nil
|
||||
end
|
||||
|
||||
it 'should keep the person around if one of the users rejects him' do
|
||||
user.accept_friend_request @request.id, aspect.id
|
||||
user.friends.include?(person_one).should be true
|
||||
user.contact_for(person_one).should_not be_nil
|
||||
|
||||
user2.ignore_friend_request @request_two.id
|
||||
user2.friends.include?(person_one).should be false
|
||||
user2.contact_for(person_one).should be_nil
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
it 'should keep the person around if the users ignores them' do
|
||||
user.ignore_friend_request user.pending_requests.first.id
|
||||
user.friends.include?(person_one).should be false
|
||||
user.contact_for(person_one).should be_nil
|
||||
|
||||
user2.ignore_friend_request user2.pending_requests.first.id #@request_two.id
|
||||
user2.friends.include?(person_one).should be false
|
||||
user2.contact_for(person_one).should be_nil
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -199,12 +235,12 @@ describe Diaspora::UserModules::Friending do
|
|||
user.accept_friend_request @request.id, aspect.id
|
||||
user.reload.pending_requests.size.should be 1
|
||||
user.friends.size.should be 1
|
||||
user.friends.include?(person_one).should be true
|
||||
user.contact_for(person_one).should_not be_nil
|
||||
|
||||
user.ignore_friend_request @request_two.id
|
||||
user.reload.pending_requests.size.should be 0
|
||||
user.friends.size.should be 1
|
||||
user.friends.include?(person_two).should be false
|
||||
user.contact_for(person_two).should be_nil
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -214,8 +250,9 @@ describe Diaspora::UserModules::Friending do
|
|||
end
|
||||
|
||||
it 'should unfriend the other user on the same seed' do
|
||||
lambda { user2.unfriend user.person }.should change {
|
||||
user2.friends.count }.by(-1)
|
||||
lambda {
|
||||
user2.unfriend user.person }.should change {
|
||||
user2.reload.friends.count }.by(-1)
|
||||
aspect2.reload.people.count.should == 0
|
||||
end
|
||||
|
||||
|
|
@ -227,6 +264,8 @@ describe Diaspora::UserModules::Friending do
|
|||
|
||||
it 'should remove the friend from all aspects they are in' do
|
||||
user.add_person_to_aspect(user2.person.id, aspect1.id)
|
||||
aspect.reload.people.count.should == 1
|
||||
aspect1.reload.people.count.should == 1
|
||||
lambda { user.unfriended_by user2.person }.should change {
|
||||
user.friends.count }.by(-1)
|
||||
aspect.reload.people.count.should == 0
|
||||
|
|
|
|||
|
|
@ -7,12 +7,14 @@
|
|||
|
||||
ENV["RAILS_ENV"] ||= 'test'
|
||||
require File.dirname(__FILE__) + "/../config/environment" unless defined?(Rails)
|
||||
require 'helper_methods'
|
||||
require 'rspec/rails'
|
||||
require 'database_cleaner'
|
||||
require 'webmock/rspec'
|
||||
|
||||
include Devise::TestHelpers
|
||||
include WebMock::API
|
||||
include HelperMethods
|
||||
|
||||
# Requires supporting files with custom matchers and macros, etc,
|
||||
# in ./support/ and its subdirectories.
|
||||
|
|
@ -33,86 +35,3 @@ end
|
|||
|
||||
ImageUploader.enable_processing = false
|
||||
|
||||
def stub_sockets
|
||||
Diaspora::WebSocket.stub!(:queue_to_user).and_return(true)
|
||||
Diaspora::WebSocket.stub!(:subscribe).and_return(true)
|
||||
Diaspora::WebSocket.stub!(:unsubscribe).and_return(true)
|
||||
end
|
||||
|
||||
def unstub_sockets
|
||||
Diaspora::WebSocket.unstub!(:queue_to_user)
|
||||
Diaspora::WebSocket.unstub!(:subscribe)
|
||||
Diaspora::WebSocket.unstub!(:unsubscribe)
|
||||
end
|
||||
|
||||
def stub_comment_signature_verification
|
||||
Comment.any_instance.stubs(:verify_signature).returns(true)
|
||||
end
|
||||
|
||||
def unstub_mocha_stubs
|
||||
Mocha::Mockery.instance.stubba.unstub_all
|
||||
end
|
||||
|
||||
def get_models
|
||||
models = []
|
||||
Dir.glob( File.dirname(__FILE__) + '/../app/models/*' ).each do |f|
|
||||
models << File.basename( f ).gsub( /^(.+).rb/, '\1')
|
||||
end
|
||||
models
|
||||
end
|
||||
|
||||
def message_queue
|
||||
User::QUEUE
|
||||
end
|
||||
|
||||
def friend_users(user1, aspect1, user2, aspect2)
|
||||
request = user1.send_friend_request_to(user2.person, aspect1)
|
||||
user2.receive_friend_request(request)
|
||||
reversed_request = user2.accept_friend_request( request.id, aspect2.id)
|
||||
user1.reload
|
||||
user1.receive reversed_request.to_diaspora_xml, user2.person
|
||||
user1.reload
|
||||
aspect1.reload
|
||||
user2.reload
|
||||
aspect2.reload
|
||||
end
|
||||
|
||||
def stub_success(address = 'abc@example.com', opts = {})
|
||||
host = address.split('@')[1]
|
||||
stub_request(:get, "https://#{host}/.well-known/host-meta").to_return(:status => 200, :body => host_xrd)
|
||||
stub_request(:get, "http://#{host}/.well-known/host-meta").to_return(:status => 200, :body => host_xrd)
|
||||
if opts[:diaspora] || host.include?("diaspora")
|
||||
stub_request(:get, /webfinger\/\?q=#{address}/).to_return(:status => 200, :body => finger_xrd)
|
||||
stub_request(:get, "http://#{host}/hcard/users/4c8eccce34b7da59ff000002").to_return(:status => 200, :body => hcard_response)
|
||||
else
|
||||
stub_request(:get, /webfinger\/\?q=#{address}/).to_return(:status => 200, :body => nonseed_finger_xrd)
|
||||
stub_request(:get, 'http://evan.status.net/hcard').to_return(:status => 200, :body => evan_hcard)
|
||||
end
|
||||
end
|
||||
|
||||
def stub_failure(address = 'abc@example.com')
|
||||
host = address.split('@')[1]
|
||||
stub_request(:get, "https://#{host}/.well-known/host-meta").to_return(:status => 200, :body => host_xrd)
|
||||
stub_request(:get, "http://#{host}/.well-known/host-meta").to_return(:status => 200, :body => host_xrd)
|
||||
stub_request(:get, /webfinger\/\?q=#{address}/).to_return(:status => 500)
|
||||
end
|
||||
|
||||
def host_xrd
|
||||
File.open(File.dirname(__FILE__) + '/fixtures/host_xrd').read
|
||||
end
|
||||
|
||||
def finger_xrd
|
||||
File.open(File.dirname(__FILE__) + '/fixtures/finger_xrd').read
|
||||
end
|
||||
|
||||
def hcard_response
|
||||
File.open(File.dirname(__FILE__) + '/fixtures/hcard_response').read
|
||||
end
|
||||
|
||||
def nonseed_finger_xrd
|
||||
File.open(File.dirname(__FILE__) + '/fixtures/nonseed_finger_xrd').read
|
||||
end
|
||||
|
||||
def evan_hcard
|
||||
File.open(File.dirname(__FILE__) + '/fixtures/evan_hcard').read
|
||||
end
|
||||
|
|
|
|||
Loading…
Reference in a new issue