Cleanup stray whitespace

This commit is contained in:
Jamie Wilkinson 2010-09-16 10:01:29 +08:00 committed by Diaspora
parent 0c6c4af277
commit fbdd50172d
83 changed files with 418 additions and 418 deletions

View file

@ -12,25 +12,25 @@ class AlbumsController < ApplicationController
@albums = current_user.albums_by_aspect(@aspect).paginate
respond_with @albums, :aspect => @aspect
end
def create
aspect = params[:album][:to]
@album = current_user.post(:album, params[:album])
flash[:notice] = "You've created an album called #{@album.name}."
redirect_to :action => :show, :id => @album.id, :aspect => aspect
end
def new
@album = Album.new
end
def destroy
@album = Album.find_by_id params[:id]
@album.destroy
flash[:notice] = "Album #{@album.name} deleted."
respond_with :location => albums_url
end
def show
@photo = Photo.new
@album = Album.find_by_id params[:id]
@ -47,7 +47,7 @@ class AlbumsController < ApplicationController
def update
@album = Album.find_params_by_id params[:id]
if @album.update_attributes params[:album]
flash[:notice] = "Album #{@album.name} successfully edited."
flash[:notice] = "Album #{@album.name} successfully edited."
respond_with @album
else
flash[:error] = "Failed to edit album #{@album.name}."

View file

@ -4,9 +4,9 @@
class ApplicationController < ActionController::Base
protect_from_forgery :except => :receive
before_filter :set_friends_and_status, :except => [:create, :update]
before_filter :count_requests
@ -19,7 +19,7 @@ class ApplicationController < ActionController::Base
"application"
end
end
def set_friends_and_status
if current_user
if params[:aspect] == nil || params[:aspect] == 'all'
@ -27,7 +27,7 @@ class ApplicationController < ActionController::Base
else
@aspect = current_user.aspect_by_id( params[:aspect])
end
@aspects = current_user.aspects
@friends = current_user.friends
end
@ -36,5 +36,5 @@ class ApplicationController < ActionController::Base
def count_requests
@request_count = Request.for_user(current_user).size if current_user
end
end

View file

@ -19,18 +19,18 @@ class AspectsController < ApplicationController
flash[:notice] = "Click on the plus on the left side to tell Diaspora who can see your new aspect."
respond_with :location => aspects_manage_path
end
def new
@aspect = Aspect.new
end
def destroy
@aspect = Aspect.find_by_id params[:id]
@aspect.destroy
flash[:notice] = "You are no longer sharing the aspect called #{@aspect.name}."
respond_with :location => aspects_url
end
def show
@aspect = Aspect.find_by_id params[:id]
@friends = @aspect.people
@ -66,7 +66,7 @@ class AspectsController < ApplicationController
end
def move_friend
unless current_user.move_friend( :friend_id => params[:friend_id], :from => params[:from], :to => params[:to][:to])
unless current_user.move_friend( :friend_id => params[:friend_id], :from => params[:from], :to => params[:to][:to])
flash[:error] = "didn't work #{params.inspect}"
end
if aspect = Aspect.first(:id => params[:to][:to])

View file

@ -5,7 +5,7 @@
class CommentsController < ApplicationController
before_filter :authenticate_user!
respond_to :html
respond_to :json, :only => :show

View file

@ -10,14 +10,14 @@ class DevUtilitiesController < ApplicationController
def warzombie
render :nothing => true
if current_user.email == "tom@tom.joindiaspora.com" && StatusMessage.where(:message => "There's a bomb in the lasagna!?").first == nil
current_user.post(:status_message, :message => "There's a bomb in the lasagna!?")
current_user.post(:status_message, :message => "There's a bomb in the lasagna!?")
current_user.post(:status_message, :message => "xkcd \nhttp://xkcd.com/743/" )
current_user.post(:status_message, :message => "I switched to Motoroi today, a Motorola Android-based phone, in Korea. Now, I am using Android phones in both the U.S. and Korea", :created_at => Time.now-930)
current_user.post(:status_message, :message => "I had 5 hours to study for it :-( GREs on Thursday. Wunderbar.", :created_at => Time.now-43990)
current_user.post(:status_message, :message => "Spotted in toy story 3: google maps, OSX, and windows XP. Two out of three isn't bad.", :created_at => Time.now-4390)
current_user.post(:status_message, :message => "Reddit\nhttp://reddit.com", :created_at => Time.now-54390)
current_user.post(:status_message, :message => "Commercials for IE make me SO MAD and my friends just don't get why.", :created_at => Time.now-30900)
current_user.post(:status_message, :message => "Zombo.com\nhttp://zombo.com", :created_at => Time.now-9090)
current_user.post(:status_message, :message => "Zombo.com\nhttp://zombo.com", :created_at => Time.now-9090)
current_user.post(:status_message, :message => "Why do I have \"No More Heroes\" by Westlife on repeat all day?", :created_at => Time.now-590000)
current_user.post(:status_message, :message => "Mmm. Friday night. Acknowledged.", :created_at => Time.now-503900)
current_user.post(:status_message, :message => "Getting a universal remote is the epitome of laziness, I do declare.", :created_at => Time.now-4400)
@ -30,7 +30,7 @@ def warzombie
render :nothing => true
bkr_info = backer_info
if current_user.email == "tom@tom.joindiaspora.com"
if current_user.email == "tom@tom.joindiaspora.com"
bkr_info.each do |backer|
backer_email = "#{backer['username']}@#{backer['username']}.joindiaspora.com"
rel_hash = relationship_flow(backer_email)
@ -43,13 +43,13 @@ def warzombie
def zombiefriendaccept
render :nothing => true
Request.all.each{|r|
Request.all.each{|r|
current_user.accept_and_respond(r.id, current_user.aspects.first.id)
}
end
def backer_info
config = YAML.load_file(File.dirname(__FILE__) + '/../../config/deploy_config.yml')
config = YAML.load_file(File.dirname(__FILE__) + '/../../config/deploy_config.yml')
config['servers']['backer']
end
@ -67,28 +67,28 @@ def warzombie
album = Album.create(:person => current_user.person, :name => "Profile Photos")
current_user.raw_visible_posts << album
current_user.save
backer_number = YAML.load_file(Rails.root.join('config','backer_number.yml'))[:seed_number].to_i
username = backer_info[backer_number]['username'].gsub(/ /,'').downcase
@fixture_name = File.dirname(__FILE__) + "/../../public/images/user/#{username}.jpg"
photo = Photo.new(:person => current_user.person, :album => album)
photo.image.store! File.open(@fixture_name)
photo.save
photo.reload
current_user.raw_visible_posts << photo
current_user.save
current_user.update_profile(:image_url => photo.url(:thumb_medium))
current_user.save
end
def log
@log = `tail -n 200 log/development.log`
render "shared/log"
end
end

View file

@ -8,27 +8,27 @@ class PeopleController < ApplicationController
respond_to :html
respond_to :json, :only => [:index, :show]
def index
@aspects_dropdown_array = current_user.aspects.collect{|x| [x.to_s, x.id]}
@aspects_dropdown_array = current_user.aspects.collect{|x| [x.to_s, x.id]}
@people = Person.search params[:q]
respond_with @people
end
def show
@person = current_user.visible_person_by_id(params[:id])
@profile = @person.profile
@aspects_with_person = current_user.aspects_with_person(@person)
@aspects_dropdown_array = current_user.aspects.collect{|x| [x.to_s, x.id]}
@aspects_dropdown_array = current_user.aspects.collect{|x| [x.to_s, x.id]}
@posts = current_user.visible_posts_from_others(:from => @person).paginate :page => params[:page], :order => 'created_at DESC'
@latest_status_message = current_user.raw_visible_posts.find_all_by__type_and_person_id("StatusMessage", params[:id]).last
@post_count = @posts.count
respond_with @person
end
def destroy
current_user.unfriend(current_user.visible_person_by_id(params[:id]))
respond_with :location => root_url
end
end

View file

@ -8,9 +8,9 @@ class PhotosController < ApplicationController
respond_to :html
respond_to :json, :only => :show
def create
album = Album.find_by_id params[:album_id]
begin
@ -30,15 +30,15 @@ class PhotosController < ApplicationController
Tempfile.send(:define_method, "original_filename") {return file_name}
##############
params[:user_file] = file
params[:user_file] = file
@photo = current_user.post(:photo, params)
respond_to do |format|
format.json{render(:layout => false , :json => {"success" => true, "data" => @photo}.to_json )}
end
rescue TypeError
message = "Photo upload failed. Are you sure an image was added?"
respond_with :location => album, :error => message
@ -53,20 +53,20 @@ class PhotosController < ApplicationController
raise e
end
end
def new
@photo = Photo.new
@album = current_user.album_by_id(params[:album_id])
render :partial => 'new_photo'
end
def destroy
@photo = Photo.find_by_id params[:id]
@photo.destroy
flash[:notice] = "Photo deleted."
respond_with :location => @photo.album
end
def show
@photo = Photo.find_by_id params[:id]
@album = @photo.album

View file

@ -7,7 +7,7 @@ class PublicsController < ApplicationController
require 'lib/diaspora/parser'
include Diaspora::Parser
layout false
def hcard
@person = Person.find_by_id params[:id]
puts @person
@ -26,7 +26,7 @@ class PublicsController < ApplicationController
render 'webfinger', :content_type => 'application/xrd+xml'
end
end
def receive
render :nothing => true
return unless params[:xml]
@ -38,5 +38,5 @@ class PublicsController < ApplicationController
end
@user.receive_salmon params[:xml]
end
end

View file

@ -5,7 +5,7 @@
class RequestsController < ApplicationController
before_filter :authenticate_user!
include RequestsHelper
include RequestsHelper
respond_to :html
@ -25,24 +25,24 @@ class RequestsController < ApplicationController
respond_with :location => requests_url
end
end
def new
@request = Request.new
end
def create
aspect = current_user.aspect_by_id(params[:request][:aspect_id])
begin
begin
rel_hash = relationship_flow(params[:request][:destination_url])
rescue Exception => e
flash[:error] = "No diaspora seed found with this email!"
flash[:error] = "No diaspora seed found with this email!"
respond_with :location => aspect
return
end
Rails.logger.debug("Sending request: #{rel_hash}")
begin
@request = current_user.send_friend_request_to(rel_hash[:friend], aspect)
rescue Exception => e

View file

@ -3,7 +3,7 @@
# the COPYRIGHT file.
class SocketsController < ApplicationController
class SocketsController < ApplicationController
include ApplicationHelper
include SocketsHelper
include Rails.application.routes.url_helpers
@ -11,10 +11,10 @@ class SocketsController < ApplicationController
def incoming(msg)
Rails.logger.info("Socket received connection to: #{msg}")
end
def outgoing(uid,object,opts={})
@_request = ActionDispatch::Request.new({})
Diaspora::WebSocket.push_to_user(uid, action_hash(uid, object, opts))
end
end

View file

@ -14,13 +14,13 @@ class StatusMessagesController < ApplicationController
@status_message = current_user.post(:status_message, params[:status_message])
respond_with @status_message
end
def destroy
@status_message = StatusMessage.find_by_id params[:id]
@status_message.destroy
respond_with :location => root_url
end
def show
@status_message = StatusMessage.find_by_id params[:id]
respond_with @status_message

View file

@ -25,7 +25,7 @@ class UsersController < ApplicationController
def update
@user = User.find_by_id params[:id]
prep_image_url(params[:user])
@user.update_profile params[:user]
respond_with(@user, :location => root_url)
end
@ -35,8 +35,8 @@ class UsersController < ApplicationController
def prep_image_url(params)
if params[:profile][:image_url].empty?
params[:profile].delete(:image_url)
else
else
params[:profile][:image_url] = "http://" + request.host + ":" + request.port.to_s + params[:profile][:image_url]
end
end
end
end

View file

@ -11,7 +11,7 @@ module AlbumsHelper
link_to 'Friends Albums', albums_path({:friends => true})
end
end
def your_albums_link
if params[:friends]
link_to 'Your Albums', albums_path

View file

@ -4,28 +4,28 @@
module ApplicationHelper
def current_aspect?(aspect)
!@aspect.is_a?(Symbol) && @aspect.id == aspect.id
end
def object_path(object, opts = {})
eval("#{object.class.to_s.underscore}_path(object, opts)")
end
def object_fields(object)
object.attributes.keys
object.attributes.keys
end
def mine?(post)
current_user.owns? post
end
def type_partial(post)
class_name = post.class.name.to_s.underscore
"#{class_name.pluralize}/#{class_name}"
end
def how_long_ago(obj)
"#{time_ago_in_words(obj.created_at)} ago."
end
@ -63,7 +63,7 @@ module ApplicationHelper
def new_request(request_count)
"new_requests" if request_count > 0
end
def post_yield_tag(post)
(':' + post.id.to_s).to_sym
end

View file

@ -6,7 +6,7 @@
module ErrorMessagesHelper
# Render error messages for the given objects. The :message and :header_message options are allowed.
def error_messages_for(*objects)
options = objects.extract_options!
options = objects.extract_options!
options[:header_message] ||= "Invalid Fields"
options[:message] ||= "Correct the following errors and try again."
messages = objects.compact.map { |o| o.errors.full_messages }.flatten
@ -17,7 +17,7 @@ module ErrorMessagesHelper
end
end
end
module FormBuilderAdditions
def error_messages(options = {})
@template.error_messages_for(@object, options)

View file

@ -12,15 +12,15 @@ module LayoutHelper
content_for(:title) { page_title.to_s }
@show_title = show_title
end
def show_title?
@show_title
end
def stylesheet(*args)
content_for(:head) { stylesheet_link_tag(*args) }
end
def javascript(*args)
content_for(:head) { javascript_include_tag(*args) }
end

View file

@ -4,13 +4,13 @@
module PeopleHelper
def search_or_index
if params[:q]
" results for #{params[:q]}"
else
" people on pod is aware of"
end
end
end

View file

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

View file

@ -15,7 +15,7 @@ module PublicsHelper
elsif opts[:verify] == 'async'
202
end
else
else
400
end
end

View file

@ -9,7 +9,7 @@ module RequestsHelper
if diaspora?(profile)
:friend
else
:none
:none
end
end

View file

@ -4,8 +4,8 @@
module SocketsHelper
include ApplicationHelper
include ApplicationHelper
def obj_id(object)
(object.is_a? Post) ? object.id : object.post_id
end
@ -16,10 +16,10 @@ module SocketsHelper
v = render_to_string(:partial => type_partial(object), :locals => {:post => object, :current_user => user}) unless object.is_a? Retraction
rescue Exception => e
Rails.logger.error("web socket view rendering failed for object #{object.inspect}.")
raise e
raise e
end
action_hash = {:class =>object.class.to_s.underscore.pluralize, :html => v, :post_id => obj_id(object)}
action_hash.merge! opts
action_hash.merge! opts
if object.is_a? Photo
action_hash[:photo_hash] = object.thumb_hash
elsif object.is_a? StatusMessage
@ -34,6 +34,6 @@ module SocketsHelper
action_hash.to_json
end
end

View file

@ -16,12 +16,12 @@ class Album < Post
validates_presence_of :name, :person
before_destroy :destroy_photos
def self.mine_or_friends(friend_param, current_user)
friend_param ? Album.find_all_by_person_id(current_user.friend_ids) : current_user.person.albums
end
def prev_photo(photo)
n_photo = self.photos.where(:created_at.lt => photo.created_at).sort(:created_at.desc).first
n_photo ? n_photo : self.photos.sort(:created_at.desc).first

View file

@ -5,7 +5,7 @@
class Aspect
include MongoMapper::Document
key :name, String
key :person_ids, Array
key :request_ids, Array
@ -20,11 +20,11 @@ class Aspect
validates_presence_of :name
timestamps!
def to_s
name
end
def posts_by_person_id( id )
id = id.to_id
posts.detect{|x| x.person.id == id }

View file

@ -9,12 +9,12 @@ class Comment
include Diaspora::Webhooks
include Encryptable
include Diaspora::Socketable
xml_accessor :text
xml_accessor :person, :as => Person
xml_accessor :post_id
xml_accessor :_id
xml_accessor :_id
key :text, String
key :post_id, ObjectId
key :person_id, ObjectId
@ -26,17 +26,17 @@ class Comment
validates_presence_of :text
timestamps!
#ENCRYPTION
xml_accessor :creator_signature
xml_accessor :post_creator_signature
key :creator_signature, String
key :post_creator_signature, String
def signable_accessors
accessors = self.class.roxml_attrs.collect{|definition|
accessors = self.class.roxml_attrs.collect{|definition|
definition.accessor}
accessors.delete 'person'
accessors.delete 'creator_signature'
@ -45,16 +45,16 @@ class Comment
end
def signable_string
signable_accessors.collect{|accessor|
signable_accessors.collect{|accessor|
(self.send accessor.to_sym).to_s}.join ';'
end
def verify_post_creator_signature
verify_signature(post_creator_signature, post.person)
end
def signature_valid?
verify_signature(creator_signature, person)
end
end

View file

@ -15,10 +15,10 @@ class Person
xml_accessor :url
xml_accessor :profile, :as => Profile
xml_reader :exported_key
key :url, String
key :diaspora_handle, String, :unique => true
key :serialized_key, String
key :serialized_key, String
key :owner_id, ObjectId
@ -30,11 +30,11 @@ class Person
before_destroy :remove_all_traces
before_validation :clean_url
validates_presence_of :url, :profile, :serialized_key
validates_presence_of :url, :profile, :serialized_key
validates_format_of :url, :with =>
/^(https?):\/\/[a-z0-9]+([\-\.]{1}[a-z0-9]+)*(\.[a-z]{2,5})?(:[0-9]{1,5})?(\/.*)?$/ix
def self.search(query)
Person.all('$where' => "function() { return this.diaspora_handle.match(/^#{query}/i) ||
this.profile.first_name.match(/^#{query}/i) ||
@ -80,7 +80,7 @@ class Person
def self.by_webfinger( identifier )
local_person = Person.first(:diaspora_handle => identifier.gsub('acct:', ''))
if local_person
local_person
elsif !identifier.include?("localhost")
@ -102,9 +102,9 @@ class Person
guid = profile.links.select{|x| x.rel == 'http://joindiaspora.com/guid'}.first.href
new_person.id = guid
new_person.diaspora_handle = identifier
hcard = HCard.find profile.hcard.first[:href]
new_person.url = hcard[:url]
@ -115,7 +115,7 @@ class Person
nil
end
end
def remote?
owner.nil?
end

View file

@ -7,10 +7,10 @@ class Photo < Post
require 'carrierwave/orm/mongomapper'
include MongoMapper::Document
mount_uploader :image, ImageUploader
xml_accessor :remote_photo
xml_accessor :caption
xml_reader :album_id
xml_reader :album_id
key :album_id, ObjectId
key :caption, String
@ -29,7 +29,7 @@ class Photo < Post
def self.instantiate(params = {})
image_file = params[:user_file]
params.delete :user_file
photo = Photo.new(params)
photo.image.store! image_file
photo.save
@ -39,7 +39,7 @@ class Photo < Post
def validate_album_person
album.person_id == person_id
end
def remote_photo
image.url.nil? ? (remote_photo_path + '/' + remote_photo_name) : image.url
end
@ -63,7 +63,7 @@ class Photo < Post
users = Person.all('profile.image_url' => image.url(:thumb_medium) )
users.each{ |user|
user.profile.update_attributes!(:image_url => nil)
}
}
end
def thumb_hash

View file

@ -3,10 +3,10 @@
# the COPYRIGHT file.
class Post
class Post
require 'lib/encryptable'
include MongoMapper::Document
include ApplicationHelper
include ApplicationHelper
include ROXML
include Diaspora::Webhooks
include Diaspora::Socketable
@ -15,16 +15,16 @@ class Post
xml_accessor :person, :as => Person
key :person_id, ObjectId
key :user_refs, Integer, :default => 0
key :user_refs, Integer, :default => 0
many :comments, :class_name => 'Comment', :foreign_key => :post_id
belongs_to :person, :class_name => 'Person'
timestamps!
cattr_reader :per_page
@@per_page = 10
before_destroy :propogate_retraction
after_destroy :destroy_comments
@ -41,12 +41,12 @@ class Post
}
}
end
protected
def destroy_comments
comments.each{|c| c.destroy}
end
def propogate_retraction
self.person.owner.retract(self)
end

View file

@ -23,7 +23,7 @@ class Profile
def person_id
self._parent_document.id
end
def person
self._parent_document
end

View file

@ -22,7 +22,7 @@ class Request
key :exported_key, String
belongs_to :person
validates_presence_of :destination_url, :callback_url
before_validation :clean_link
@ -32,19 +32,19 @@ class Request
def self.instantiate(options = {})
person = options[:from]
self.new(:destination_url => options[:to],
:callback_url => person.receive_url,
:callback_url => person.receive_url,
:person => person,
:exported_key => person.exported_key,
:aspect_id => options[:into])
end
def reverse_for accepting_user
self.person = accepting_user.person
self.exported_key = accepting_user.exported_key
self.destination_url = self.callback_url
self.save
end
protected
def clean_link
if self.destination_url

View file

@ -43,7 +43,7 @@ class Retraction
def self.person_id_from(object)
object.is_a?(Person) ? object.id : object.person.id
end
def person
Person.find_by_id(self.person_id)
end

View file

@ -4,14 +4,14 @@
class StatusMessage < Post
xml_name :status_message
xml_accessor :message
key :message, String
validates_presence_of :message
def to_activity
<<-XML
<entry>
@ -24,7 +24,7 @@ class StatusMessage < Post
</entry>
XML
end
def latest_hash
{ :text => message}
end

View file

@ -17,14 +17,14 @@ class User
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable
key :username, :unique => true
key :friend_ids, Array
key :pending_request_ids, Array
key :visible_post_ids, Array
key :visible_person_ids, Array
key :url, String
one :person, :class_name => 'Person', :foreign_key => :owner_id
many :friends, :in => :friend_ids, :class_name => 'Person'
@ -38,7 +38,7 @@ class User
after_create :seed_aspects
before_validation_on_create :downcase_username
def self.find_for_authentication(conditions={})
if conditions[:username] =~ /^([\w\.%\+\-]+)@([\w\-]+\.)+([\w]{2,})$/i # email regex
conditions[:email] = conditions.delete(:username)
@ -46,7 +46,7 @@ class User
conditions[:username].downcase!
end
super
end
end
######## Making things work ########
key :email, String
@ -58,7 +58,7 @@ class User
def real_name
"#{person.profile.first_name.to_s} #{person.profile.last_name.to_s}"
end
######### Aspects ######################
def aspect( opts = {} )
opts[:user] = self
@ -69,7 +69,7 @@ class User
return true if opts[:to] == opts[:from]
friend = Person.first(:_id => opts[:friend_id])
if self.friend_ids.include?(friend.id)
from_aspect = self.aspect_by_id(opts[:from])
from_aspect = self.aspect_by_id(opts[:from])
to_aspect = self.aspect_by_id(opts[:to])
if from_aspect && to_aspect
posts_to_move = from_aspect.posts.find_all_by_person_id(friend.id)
@ -126,7 +126,7 @@ class User
aspects = self.aspects.find_all_by_id( aspect_ids )
end
#send to the aspects
target_people = []
target_people = []
aspects.each{ |aspect|
aspect.posts << post
@ -146,7 +146,7 @@ class User
Rails.logger.debug("Adding xml for #{self} to message queue to #{url}")
QUEUE.add_post_request( person.receive_url, person.encrypt(xml) )
QUEUE.process
end
def salmon( post, opts = {} )
@ -164,7 +164,7 @@ class User
end
comment
end
def build_comment( text, options = {})
raise "must comment on something!" unless options[:on]
comment = Comment.new(:person_id => self.person.id, :text => text, :post => options[:on])
@ -184,10 +184,10 @@ class User
push_to_people comment, people_in_aspects(aspects_with_post(comment.post.id))
elsif owns? comment
comment.save
salmon comment, :to => comment.post.person
salmon comment, :to => comment.post.person
end
end
######### Posts and Such ###############
def retract( post )
aspect_ids = aspects_with_post( post.id )
@ -250,9 +250,9 @@ class User
elsif object.is_a? Profile
person = Diaspora::Parser.owner_id_from_xml xml
person.profile = object
person.save
person.save
elsif object.is_a?(Comment)
elsif object.is_a?(Comment)
object.person = Diaspora::Parser.parse_or_find_person_from_xml( xml ).save if object.person.nil?
self.visible_people = self.visible_people | [object.person]
self.save
@ -269,12 +269,12 @@ class User
Rails.logger.debug("Saving object: #{object}")
object.user_refs += 1
object.save
self.raw_visible_posts << object
self.save
aspects = self.aspects_with_person(object.person)
aspects.each{ |aspect|
aspects.each{ |aspect|
aspect.posts << object
aspect.save
object.socket_to_uid(id, :aspect_ids => [aspect.id]) if (object.respond_to?(:socket_to_uid) && !self.owns?(object))
@ -295,11 +295,11 @@ class User
aspect(:name => "Family")
aspect(:name => "Work")
end
def self.create(opts ={})
puts opts.inspect
end
end
def terse_url
terse = self.url.gsub(/(https?:|www\.)\/\//, '')
terse = terse.chop! if terse[-1, 1] == '/'

View file

@ -23,7 +23,7 @@ module Diaspora
# Add additional load paths for your own custom dirs
#config.autoload_paths += %W(#{config.root}/lib)
config.autoload_paths += %W(#{config.root}/lib)
# Only load the plugins named here, in the order given (default is alphabetical).
# :all can be used as a placeholder for all plugins not explicitly named
# config.plugins = [ :exception_notification, :ssl_requirement, :all ]

View file

@ -14,7 +14,7 @@ set :deploy_to, all['deploy_to']
#set :current_dir, ""
# Source code
set :scm, :git
set :user, all['user']
set :user, all['user']
#set :user, ARGV[0]
set :password, all['password'] if all['password']
set :scm_verbose, true
@ -29,9 +29,9 @@ set :rails_env, ENV['rails_env'] || ENV['RAILS_ENV'] || all['default_env']
role :tom, "tom.joindiaspora.com"
backers.each{ |backer|
role :backer, "#{backer['username']}.joindiaspora.com", :number => backer['number']
role :backer, "#{backer['username']}.joindiaspora.com", :number => backer['number']
}
#role :ci, "ci.joindiaspora.com"
# If you are using Passenger mod_rails uncomment this:
# if you're still using the script/reapear helper you will need
@ -47,19 +47,19 @@ end
namespace :deploy do
task :symlink_images do
run "mkdir -p #{shared_path}/uploads"
run "ln -s -f #{shared_path}/uploads #{current_path}/public/uploads"
run "ln -s -f #{shared_path}/uploads #{current_path}/public/uploads"
end
task :symlink_bundle do
run "mkdir -p #{shared_path}/bundle"
run "ln -s -f #{shared_path}/bundle #{current_path}/vendor/bundle"
run "ln -s -f #{shared_path}/bundle #{current_path}/vendor/bundle"
end
task :start do
start_mongo
start_thin
end
task :start_mongo do
run("mkdir -p -v #{current_path}/log/db/ ")
run("mkdir -p -v #{shared_path}/db/")
@ -75,36 +75,36 @@ namespace :deploy do
stop_thin
run("killall -s 2 mongod || true")
end
task :stop_thin do
run("killall -s 2 ruby || true")
run("killall -s 2 ruby || true")
#run("cd #{current_path} && bundle exec thin stop -C config/thin.yml || true")
end
task :restart, :roles => :app, :except => { :no_release => true } do
stop
stop
start
end
task :bundle_gems do
run "cd #{current_path} && bundle install"
end
task :reinstall_old_bundler do
#run ("rm #{current_path}/Gemfile.lock || true")
run 'gem list | cut -d" " -f1 | xargs gem uninstall -aIx || true '
run "gem install bundler -v 0.9.26 || true"
end
task :update_bundler do
run 'gem install bundler'
end
task :migrate do
end
end
namespace :cloud do
task :reboot do
run('reboot')
@ -116,11 +116,11 @@ namespace :cloud do
end
end
namespace :db do
task :purge, :roles => [:tom, :backer] do
run "cd #{current_path} && bundle exec rake db:purge --trace RAILS_ENV=#{rails_env}"
end
task :tom_seed, :roles => :tom do
run "cd #{current_path} && bundle exec rake db:seed:tom --trace RAILS_ENV=#{rails_env}"
run "curl -silent -u tom@tom.joindiaspora.com:evankorth http://tom.joindiaspora.com/zombiefriends"
@ -137,7 +137,7 @@ namespace :db do
}
run "cd #{current_path} && bundle exec rake db:seed:backer --trace RAILS_ENV=#{rails_env}"
end
task :reset do
purge
backer_seed

View file

@ -31,7 +31,7 @@ Diaspora::Application.configure do
config.action_mailer.delivery_method = :test
config.active_support.deprecation = :stderr
config.threadsafe!
# Use SQL instead of Active Record's schema dumper when creating the test database.
# This is necessary if your schema can't be completely dumped by the schema dumper,
@ -46,5 +46,5 @@ begin
rescue LoadError => ignore_if_database_cleaner_not_present
puts "Error on cleaner"
end
end

View file

@ -48,10 +48,10 @@ Devise.setup do |config|
# ==> Configuration for :confirmable
# The time you want to give your user to confirm his account. During this time
# he will be able to access your application without confirming. Default is nil.
# When confirm_within is zero, the user won't be able to sign in without confirming.
# You can use this to let your user access some features of your application
# without confirming the account, but blocking it after a certain period
# (ie 2 days).
# When confirm_within is zero, the user won't be able to sign in without confirming.
# You can use this to let your user access some features of your application
# without confirming the account, but blocking it after a certain period
# (ie 2 days).
# config.confirm_within = 2.days
# ==> Configuration for :rememberable

View file

@ -5,7 +5,7 @@
# Be sure to restart your server when you modify this file.
# Add new inflection rules using the following format
# Add new inflection rules using the following format
# (all these examples are active by default):
ActiveSupport::Inflector.inflections do |inflect|
# inflect.plural /^(ox)$/i, '\1en'

View file

@ -7,6 +7,6 @@
# Your secret key for verifying the integrity of signed cookies.
# If you change this key, all old signed cookies will become invalid!
# Make sure the secret is at least 30 characters and all random,
# Make sure the secret is at least 30 characters and all random,
# no regular words or you'll be exposed to dictionary attacks.
Rails.application.config.secret_token = 'ea08916110cae7f10fe9e1f7c7cb8c1fee13c3c3bee35180ac3061c370bd9ad985f28fcf2eb5f5684d0d618855efdeb862918628e994ed3e7fc806777428ef40'

View file

@ -8,15 +8,15 @@ require 'eventmachine'
require "lib/diaspora/websocket"
EM.next_tick {
Diaspora::WebSocket.initialize_channels
EventMachine::WebSocket.start(
:host => "0.0.0.0",
:host => "0.0.0.0",
:port => APP_CONFIG[:socket_port],
:debug =>APP_CONFIG[:socket_debug]) do |ws|
ws.onopen {
sid = Diaspora::WebSocket.subscribe(ws.request['Path'].gsub('/',''), ws)
ws.onmessage { |msg| SocketsController.new.incoming(msg) }
ws.onclose { Diaspora::WebSocket.unsubscribe(ws.request['Path'].gsub('/',''), sid) }

View file

@ -15,7 +15,7 @@ package :mongodb, :provides => :database do
version '1.4.3'
binary "http://downloads.mongodb.org/linux/mongodb-linux-x86_64-static-legacy-#{version}.tgz" do
post :install, "ln -s -f /usr/local/bin/mongodb-linux-x86_64-static-#{version}/bin/mongod /usr/bin/mongod"
post :install, "ln -s -f /usr/local/bin/mongodb-linux-x86_64-static-#{version}/bin/mongod /usr/bin/mongod"
end
end

View file

@ -20,16 +20,16 @@ package :tools do
end
package :vim do
apt 'vim' do
apt 'vim' do
post :install, run("rm -r -f /root/vim-files")
end
apt 'vim' do
apt 'vim' do
post :install, run("git clone git://github.com/zhitomirskiyi/vim-files.git /root/vim-files")
end
apt 'vim' do
post :install, run("ln -s -f /root/vim-files/vimrc /root/.vimrc")
apt 'vim' do
post :install, run("ln -s -f /root/vim-files/vimrc /root/.vimrc")
end
apt 'vim' do
apt 'vim' do
post :install, run("ln -s -f -T /root/vim-files /root/.vim")
end
end

View file

@ -13,18 +13,18 @@ end
package :privkey do
description 'checkout from github with it'
transfer "#{File.dirname(__FILE__)}/../deploy_key/id_rsa", '/root/.ssh/id_rsa', :render => false do
transfer "#{File.dirname(__FILE__)}/../deploy_key/id_rsa", '/root/.ssh/id_rsa', :render => false do
pre :install, "rm -rf /root/.ssh/ && mkdir -p /root/.ssh/"
post :install, "chmod go-rwx /root/.ssh/id_rsa"
end
end
package :pubkey do
transfer "#{File.dirname(__FILE__)}/../deploy_key/id_rsa.pub", '/root/.ssh/id_rsa.pub', :render => false
transfer "#{File.dirname(__FILE__)}/../deploy_key/id_rsa.pub", '/root/.ssh/id_rsa.pub', :render => false
requires :privkey
requires :known_hosts
end
package :known_hosts do
transfer "#{File.dirname(__FILE__)}/../deploy_key/known_hosts", '/root/.ssh/known_hosts', :render => false
transfer "#{File.dirname(__FILE__)}/../deploy_key/known_hosts", '/root/.ssh/known_hosts', :render => false
end

View file

@ -43,6 +43,6 @@ deployment do
binary do
prefix '/usr/local/bin'
archives '/usr/local/sources'
end
end
end

View file

@ -4,7 +4,7 @@
# This file is auto-generated from the current state of the database. Instead of editing this file,
# This file is auto-generated from the current state of the database. Instead of editing this file,
# please use the migrations feature of Active Record to incrementally modify your database, and
# then regenerate this schema definition.
#

View file

@ -15,7 +15,7 @@
require 'config/environment'
def create
config = YAML.load_file(File.dirname(__FILE__) + '/../../config/deploy_config.yml')
config = YAML.load_file(File.dirname(__FILE__) + '/../../config/deploy_config.yml')
backer_info = config['servers']['backer']
backer_number = YAML.load_file(Rails.root.join('config','backer_number.yml'))[:seed_number].to_i
@ -28,7 +28,7 @@ def create
:url=> "http://#{username}.joindiaspora.com/",
:person => Person.new(
:diaspora_handle => "#{username}@#{username}.joindiaspora.com",
:profile => Profile.new( :first_name => backer_info[backer_number]['given_name'], :last_name => backer_info[backer_number]['family_name'],
:profile => Profile.new( :first_name => backer_info[backer_number]['given_name'], :last_name => backer_info[backer_number]['family_name'],
:image_url => "http://#{username}.joindiaspora.com/images/user/#{username}.jpg"),
:url=> "http://#{username}.joindiaspora.com/")
)

View file

@ -28,7 +28,7 @@ user2 = User.instantiate!( :email => "korth@tom.joindiaspora.com",
:password => "evankorth",
:password_confirmation => "evankorth",
:person => Person.new( :diaspora_handle => "korth@tom.joindiaspora.com",
:url => url,
:url => url,
:profile => Profile.new( :first_name => "Evan",
:last_name => "Korth")))

View file

@ -27,7 +27,7 @@ user2 = User.instantiate!( :email => "korth@tom.joindiaspora.com",
:username => "korth",
:url => remote_url,
:person => { :diaspora_handle => "korth@tom.joindiaspora.com",
:url => remote_url,
:url => remote_url,
:profile => { :first_name => "Evan",
:last_name => "Korth",
:image_url => "http://tom.joindiaspora.com/images/user/korth.jpg"}})

View file

@ -12,7 +12,7 @@ module Rack
@options = options
end
def call(env)
def call(env)
if env['HTTP_USER_AGENT'] =~ /MSIE/
if env['HTTP_USER_AGENT'] =~ /chromeframe/

View file

@ -20,28 +20,28 @@ module Diaspora
aspect.requests << request
aspect.save
salmon request, :to => desired_friend
end
request
end
def accept_friend_request(friend_request_id, aspect_id)
request = Request.find_by_id(friend_request_id)
pending_requests.delete(request)
activate_friend(request.person, aspect_by_id(aspect_id))
request.reverse_for(self)
request
end
def dispatch_friend_acceptance(request, requester)
salmon request, :to => requester
request.destroy unless request.callback_url.include? url
end
end
def accept_and_respond(friend_request_id, aspect_id)
requester = Request.find_by_id(friend_request_id).person
reversed_request = accept_friend_request(friend_request_id, aspect_id)
@ -61,7 +61,7 @@ module Diaspora
def receive_friend_request(friend_request)
Rails.logger.info("receiving friend request #{friend_request.to_json}")
if request_from_me?(friend_request)
aspect = self.aspect_by_id(friend_request.aspect_id)
activate_friend(friend_request.person, aspect)
@ -83,7 +83,7 @@ module Diaspora
salmon( retraction, :to => bad_friend)
remove_friend(bad_friend)
end
def remove_friend(bad_friend)
raise "Friend not deleted" unless self.friend_ids.delete( bad_friend.id )
aspects.each{|g| g.person_ids.delete( bad_friend.id )}

View file

@ -7,14 +7,14 @@
module Diaspora
module WebSocket
def self.initialize_channels
@channels = {}
@channels = {}
end
def self.push_to_user(uid, data)
Rails.logger.debug "Websocketing to #{uid}"
@channels[uid.to_s][0].push(data) if @channels[uid.to_s]
end
def self.subscribe(uid, ws)
Rails.logger.debug "Subscribing socket to #{uid}"
self.ensure_channel(uid)
@ -40,7 +40,7 @@ module Diaspora
def socket_to_uid(id, opts={})
SocketsController.new.outgoing(id, self, opts)
end
def unsocket_from_uid(id, opts={})
SocketsController.new.outgoing(id, Retraction.for(self), opts)
end

View file

@ -10,9 +10,9 @@
end
def signature_valid?
verify_signature(creator_signature, person)
verify_signature(creator_signature, person)
end
def verify_signature(signature, person)
if person.nil?
Rails.logger.info("Verifying sig on #{signable_string} but no person is here")
@ -29,7 +29,7 @@
Rails.logger.debug("Validity: #{validity}")
validity
end
def sign_with_key(key)
Rails.logger.debug("Signing #{signable_string}")
Base64.encode64(key.sign "SHA", signable_string)

View file

@ -11,7 +11,7 @@ module Encryptor
ciphertext = aes_encrypt(cleartext, aes_key)
encrypted_key = encrypt_aes_key aes_key
cipher_hash = {:aes_key => encrypted_key, :ciphertext => ciphertext}
Base64.encode64( cipher_hash.to_json )
Base64.encode64( cipher_hash.to_json )
end
def gen_aes_key

View file

@ -4,12 +4,12 @@
class MessageHandler
class MessageHandler
NUM_TRIES = 3
TIMEOUT = 5 #seconds
def initialize
@queue = EM::Queue.new
end
@ -41,12 +41,12 @@ class MessageHandler
Rails.logger.info("Failure from #{query.destination}, retrying...")
query.try_count +=1
@queue.push query unless query.try_count >= NUM_TRIES
@queue.push query unless query.try_count >= NUM_TRIES
process
}
} unless @queue.size == 0
end
def send_to_seed(message, http_response)
#DO SOMETHING!
end

View file

@ -66,7 +66,7 @@ module Salmon
uri = doc.search('uri').text
slap.author_email = uri.split("acct:").last
slap
slap
end
def self.create(user, activity)
@ -98,10 +98,10 @@ ENTRY
end
end
# Decode URL-safe-Base64. This implements
# Decode URL-safe-Base64. This implements
def self.decode64url(str)
# remove whitespace
sans_whitespace = str.gsub(/\s/, '')
@ -115,7 +115,7 @@ ENTRY
end
# def verified?
#
#
# end
# Check whether this envelope's signature can be verified with the
@ -128,7 +128,7 @@ ENTRY
signature = Base64.urlsafe_decode64(self.magic_sig.sig)
signed_data = self.magic_sig.signable_string# Base64.urlsafe_decode64(self.magic_sig.signable_string)
public_key.verify(OpenSSL::Digest::SHA256.new, signature, signed_data )
end
@ -197,7 +197,7 @@ ENTRY
env.sig = Base64.urlsafe_encode64(
user.encryption_key.sign OpenSSL::Digest::SHA256.new, env.signable_string )
env
end

View file

@ -5,18 +5,18 @@
require File.dirname(__FILE__) + '/../spec_helper'
include ApplicationHelper
include ApplicationHelper
describe AspectsController do
render_views
before do
@user = Factory.create(:user)
@user.aspect(:name => "lame-os")
@person = Factory.create(:person)
sign_in :user, @user
sign_in :user, @user
end
it "on index sets a variable containing all a user's friends when a user is signed in" do
sign_in :user, @user
sign_in :user, @user
Factory.create :person
get :index
assigns[:friends].should == @user.friends

View file

@ -5,13 +5,13 @@
require File.dirname(__FILE__) + '/../spec_helper'
describe PeopleController do
render_views
before do
@user = Factory.create(:user)
sign_in :user, @user
sign_in :user, @user
@user.aspect(:name => "lame-os")
end
@ -20,7 +20,7 @@ describe PeopleController do
Person.should_receive(:search)
get :index, :q => "Eu"
end
it 'should go to the current_user show page' do
get :show, :id => @user.person.id
end

View file

@ -5,13 +5,13 @@
require File.dirname(__FILE__) + '/../spec_helper'
describe PublicsController do
render_views
before do
@user = Factory.create(:user)
sign_in :user, @user
sign_in :user, @user
end
describe 'receive endpoint' do
@ -19,7 +19,7 @@ describe PublicsController do
post :receive, :id =>@user.person.id
response.code.should == '200'
end
it 'should accept a post from another node and save the information' do
user2 = Factory.create(:user)
message = user2.build_post(:status_message, :message => "hi")
@ -46,20 +46,20 @@ describe PublicsController do
req = @user2.send_friend_request_to(@user.person, aspect)
@xml = @user.person.encrypt(@user2.salmon(req, :to => @user.person).to_xml)
req.delete
@user2.reload
@user2.pending_requests.count.should be 1
end
it 'should add the pending request to the right user if the target person exists locally' do
it 'should add the pending request to the right user if the target person exists locally' do
@user2.delete
post :receive, :id => @user.person.id, :xml => @xml
assigns(:user).should eq(@user)
end
it 'should add the pending request to the right user if the target person does not exist locally' do
it 'should add the pending request to the right user if the target person does not exist locally' do
Person.should_receive(:by_webfinger).with(@user2.person.diaspora_handle).and_return(@user2.person)
@user2.person.delete
@user2.delete

View file

@ -5,11 +5,11 @@
require File.dirname(__FILE__) + '/../spec_helper'
include ApplicationHelper
include RequestsHelper
include ApplicationHelper
include RequestsHelper
describe RequestsController do
render_views
before do
before do
@user = Factory.create :user
stub_success("tom@tom.joindiaspora.com")

View file

@ -13,7 +13,7 @@ class SocketsController
end
describe SocketsController do
render_views
render_views
before do
@user = Factory.create(:user)
@controller = SocketsController.new
@ -23,14 +23,14 @@ describe SocketsController do
Diaspora::WebSocket.initialize_channels
@controller.class.should == SocketsController
end
describe 'actionhash' do
before do
@aspect = @user.aspect :name => "losers"
@message = @user.post :status_message, :message => "post through user for victory", :to => @aspect.id
@fixture_name = File.dirname(__FILE__) + '/../fixtures/button.png'
end
it 'should actionhash photos' do
pending "Figure out how to make the photo posting api work in specs, it needs a file type"
@album = @user.post(:album, :name => "Loser faces", :to => @aspect.id)

View file

@ -34,7 +34,7 @@ Factory.define :user do |u|
u.sequence(:email) {|n| "bob#{n}@aol.com"}
u.password "bluepin7"
u.password_confirmation "bluepin7"
u.person { |a| Factory.create(:person_with_user, :owner_id => a._id)}
u.person { |a| Factory.create(:person_with_user, :owner_id => a._id)}
end
Factory.define :status_message do |m|

View file

@ -6,7 +6,7 @@
require File.dirname(__FILE__) + '/../spec_helper'
include ApplicationHelper
include ApplicationHelper
describe ApplicationHelper do
before do
@user = Factory.create(:user)

View file

@ -6,7 +6,7 @@
require File.dirname(__FILE__) + '/../spec_helper'
include PublicsHelper
include PublicsHelper
describe PublicsHelper do
before do
@user = Factory.create(:user)

View file

@ -10,8 +10,8 @@ include RequestsHelper
describe RequestsHelper do
before do
before do
stub_success("tom@tom.joindiaspora.com")
stub_success("evan@status.net")
@tom = Redfinger.finger('tom@tom.joindiaspora.com')

View file

@ -6,7 +6,7 @@
require File.dirname(__FILE__) + '/../spec_helper'
include ApplicationHelper
include ApplicationHelper
include Diaspora::Parser
@ -19,40 +19,40 @@ describe Diaspora::Parser do
@user2 = Factory.create(:user)
end
describe "parsing compliant XML object" do
describe "parsing compliant XML object" do
before do
@xml = Factory.build(:status_message).to_diaspora_xml
@xml = Factory.build(:status_message).to_diaspora_xml
end
it 'should be able to correctly handle comments with person in db' do
person = Factory.create(:person, :diaspora_handle => "test@testing.com")
post = Factory.create(:status_message, :person => @user.person)
comment = Factory.build(:comment, :post => post, :person => person, :text => "Freedom!")
xml = comment.to_diaspora_xml
xml = comment.to_diaspora_xml
comment = Diaspora::Parser.from_xml(xml)
comment.text.should == "Freedom!"
comment.person.should == person
comment.post.should == post
end
it 'should be able to correctly handle person on a comment with person not in db' do
commenter = Factory.create(:user)
commenter_aspect = commenter.aspect :name => "bruisers"
friend_users(@user, @aspect, commenter, commenter_aspect)
post = @user.post :status_message, :message => "hello", :to => @aspect.id
comment = commenter.comment "Fool!", :on => post
xml = comment.to_diaspora_xml
xml = comment.to_diaspora_xml
commenter.delete
commenter.person.delete
parsed_person = Diaspora::Parser::parse_or_find_person_from_xml(xml)
parsed_person.save.should be true
parsed_person.diaspora_handle.should == commenter.person.diaspora_handle
parsed_person.profile.should_not be_nil
end
it 'should marshal retractions' do
person = Factory.create(:person)
message = Factory.create(:status_message, :person => person)
@ -63,14 +63,14 @@ describe Diaspora::Parser do
@user.receive xml
StatusMessage.count.should == 0
end
it "should create a new person upon getting a person request" do
person_count = Person.all.count
request = Request.instantiate(:to =>"http://www.google.com/", :from => @person)
original_person_id = @person.id
xml = request.to_diaspora_xml
xml = request.to_diaspora_xml
@person.destroy
Person.all.count.should == person_count -1
@user.receive xml
@ -80,19 +80,19 @@ describe Diaspora::Parser do
url = "http://" + request.callback_url.split("/")[2] + "/"
Person.where(:url => url).first.id.should == original_person_id
end
it "should not create a new person if the person is already here" do
person_count = Person.all.count
request = Request.instantiate(:to =>"http://www.google.com/", :from => @user2.person)
original_person_id = @user2.person.id
xml = request.to_diaspora_xml
Person.all.count.should be person_count
@user.receive xml
Person.all.count.should be person_count
@user2.reload
@user2.person.reload
@user2.person.serialized_key.include?("PRIVATE").should be true
@ -101,12 +101,12 @@ describe Diaspora::Parser do
Person.where(:url => url).first.id.should == original_person_id
end
it "should activate the Person if I initiated a request to that url" do
it "should activate the Person if I initiated a request to that url" do
request = @user.send_friend_request_to( @user2.person, @aspect)
request.reverse_for @user2
request.reverse_for @user2
xml = request.to_diaspora_xml
xml = request.to_diaspora_xml
@user2.person.destroy
@user2.destroy
@ -114,7 +114,7 @@ describe Diaspora::Parser do
@user.receive xml
new_person = Person.first(:url => @user2.person.url)
new_person.nil?.should be false
@user.reload
@aspect.reload
@aspect.people.include?(new_person).should be true
@ -125,16 +125,16 @@ describe Diaspora::Parser do
it 'should process retraction for a person' do
person_count = Person.all.count
request = @user.send_friend_request_to( @user2.person, @aspect)
request.reverse_for @user2
xml = request.to_diaspora_xml
request.reverse_for @user2
xml = request.to_diaspora_xml
retraction = Retraction.for(@user2)
retraction_xml = retraction.to_diaspora_xml
@user2.person.destroy
@user2.destroy
@user.receive xml
@aspect.reload
aspect_people_count = @aspect.people.size
#They are now friends
@ -146,7 +146,7 @@ describe Diaspora::Parser do
@aspect.reload
@aspect.people.size.should == aspect_people_count -1
end
it 'should marshal a profile for a person' do
#Create person
person = Factory.create(:person)
@ -160,20 +160,20 @@ describe Diaspora::Parser do
#Build xml for profile, clear profile
xml = person.profile.to_diaspora_xml
reloaded_person = Person.first(:id => id)
reloaded_person = Person.first(:id => id)
reloaded_person.profile = nil
reloaded_person.save(:validate => false)
#Make sure profile is cleared
Person.first(:id => id).profile.should be nil
Person.first(:id => id).profile.should be nil
old_profile.first_name.should == 'bob'
#Marshal profile
@user.receive xml
#Check that marshaled profile is the same as old profile
person = Person.first(:id => person.id)
person.profile.should_not be nil
person.profile.should_not be nil
person.profile.first_name.should == old_profile.first_name
person.profile.last_name.should == old_profile.last_name
person.profile.image_url.should == old_profile.image_url

View file

@ -9,13 +9,13 @@ require File.dirname(__FILE__) + '/../spec_helper'
describe MessageHandler do
before do
@handler = MessageHandler.new
@message_body = "I want to pump you up"
@message_body = "I want to pump you up"
@message_urls = ["http://www.google.com/", "http://yahoo.com/", "http://foo.com/"]
end
describe 'GET messages' do
describe 'creating a GET query' do
describe 'creating a GET query' do
it 'should be able to add a GET query to the queue with required destinations' do
EventMachine.run{
@handler.add_get_request(@message_urls)
@ -31,8 +31,8 @@ describe MessageHandler do
request = FakeHttpRequest.new(:success)
request.should_receive(:get).and_return(request)
EventMachine::HttpRequest.stub!(:new).and_return(request)
EventMachine.run {
EventMachine.run {
@handler.add_get_request("http://www.google.com/")
@handler.size.should == 1
@handler.process
@ -60,14 +60,14 @@ describe MessageHandler do
end
describe 'POST messages' do
it 'should be able to add a post message to the queue' do
EventMachine.run {
@handler.size.should ==0
@handler.add_post_request(@message_urls.first, @message_body)
@handler.size.should == 1
EventMachine.stop
}
end
@ -86,26 +86,26 @@ describe MessageHandler do
request.should_receive(:post).and_return(request)
EventMachine::HttpRequest.stub!(:new).and_return(request)
EventMachine.run{
@handler.add_post_request(@message_urls.first, @message_body)
@handler.size.should == 1
@handler.process
@handler.size.should == 0
@handler.size.should == 0
EventMachine.stop
EventMachine.stop
}
end
end
describe "Mixed Queries" do
describe "Mixed Queries" do
it 'should process both POST and GET requests in the same queue' do
request = FakeHttpRequest.new(:success)
request.should_receive(:get).exactly(3).times.and_return(request)
request.should_receive(:post).exactly(3).times.and_return(request)
EventMachine::HttpRequest.stub!(:new).and_return(request)
EventMachine.run{
@handler.add_post_request(@message_urls,@message_body)
@handler.size.should == 3
@ -124,7 +124,7 @@ describe MessageHandler do
request.should_receive(:get).exactly(1).times.and_return(request)
request.should_receive(:post).exactly(1).times.and_return(request)
@handler.should_receive(:send_to_seed).once
EventMachine::HttpRequest.stub!(:new).and_return(request)
EventMachine.run{
@ -143,7 +143,7 @@ class FakeHttpRequest
def initialize(callback_wanted)
@callback = callback_wanted
end
def response
def response
end
def post; end

View file

@ -22,21 +22,21 @@ describe Salmon do
@sent_salmon.magic_sig.sig.should == @parsed_salmon.magic_sig.sig
@sent_salmon.magic_sig.signable_string.should == @parsed_salmon.magic_sig.signable_string
@parsed_salmon.verified_for_key?(OpenSSL::PKey::RSA.new(@user.exported_key)).should be true
@sent_salmon.verified_for_key?(OpenSSL::PKey::RSA.new(@user.exported_key)).should be true
end
it 'should return the data so it can be "received"' do
xml = @post.to_diaspora_xml
@parsed_salmon.data.should == xml
end
it 'should parse out the authors diaspora_handle' do
@parsed_salmon.author_email.should == @user.person.diaspora_handle
@parsed_salmon.author_email.should == @user.person.diaspora_handle
end

View file

@ -5,7 +5,7 @@
require File.dirname(__FILE__) + '/spec_helper'
describe 'making sure the spec runner works' do
it 'should not delete the database mid-spec' do
@ -13,11 +13,11 @@ describe 'making sure the spec runner works' do
Factory.create(:user)
User.count.should == 1
end
it 'should make sure the last user no longer exsists' do
User.count.should == 0
end
it 'should factory create a user with a person saved' do
user = Factory.create(:user)
loaded_user = User.first(:id => user.id)
@ -26,12 +26,12 @@ describe 'making sure the spec runner works' do
describe 'testing a before do block' do
before do
Factory.create(:user)
end
it 'should have cleaned before the before do block runs' do
User.count.should == 1
end
end
end

View file

@ -52,9 +52,9 @@ describe Album do
photo.image.store! File.open @fixture_name
@photos << photo
end
@album.photos += @photos
@album.photos += @photos
end
it 'should traverse the album correctly' do
#should retrieve the next photo relative to a given photo
@album.next_photo(@photos[1]).id.should == @photos[2].id
@ -65,7 +65,7 @@ describe Album do
#wrapping
#does next photo of last to first
@album.next_photo(@photos[2]).id.should == @photos[0].id
#does previous photo of first to last
@album.prev_photo(@photos[0]).id.should == @photos[2].id
end

View file

@ -28,19 +28,19 @@ describe Aspect do
it 'should be able to have other users' do
aspect = @user.aspect(:name => 'losers', :people => [@user2.person])
aspect.people.include?(@user.person).should be false
aspect.people.include?(@user2.person).should be true
aspect.people.include?(@user2.person).should be true
aspect.people.size.should == 1
end
end
it 'should be able to have users and people' do
aspect = @user.aspect(:name => 'losers', :people => [@user2.person, @friend_2])
aspect.people.include?(@user.person).should be false
aspect.people.include?(@user2.person).should be true
aspect.people.include?(@friend_2).should be true
aspect.people.include?(@user2.person).should be true
aspect.people.include?(@friend_2).should be true
aspect.people.size.should == 2
end
end
describe 'querying' do
before do
@aspect = @user.aspect(:name => 'losers')
@ -71,12 +71,12 @@ describe Aspect do
end
describe 'posting' do
it 'should add post to aspect via post method' do
aspect = @user.aspect(:name => 'losers', :people => [@friend])
status_message = @user.post( :status_message, :message => "hey", :to => aspect.id )
aspect.reload
aspect.posts.include?(status_message).should be true
end
@ -87,24 +87,24 @@ describe Aspect do
friend_users(@user, aspect, @user2, aspect2)
message = @user2.post(:status_message, :message => "Hey Dude", :to => aspect2.id)
@user.receive message.to_diaspora_xml
aspect.reload
aspect.posts.include?(message).should be true
@user.visible_posts(:by_members_of => aspect).include?(message).should be true
end
it 'should retract the post from the aspects as well' do
it 'should retract the post from the aspects as well' do
aspect = @user.aspect(:name => 'losers')
aspect2 = @user2.aspect(:name => 'winners')
friend_users(@user, aspect, @user2, aspect2)
message = @user2.post(:status_message, :message => "Hey Dude", :to => aspect2.id)
@user.receive message.to_diaspora_xml
aspect.reload
aspect.post_ids.include?(message.id).should be true
retraction = @user2.retract(message)
@ -141,24 +141,24 @@ describe Aspect do
@aspect.people.include?(@friend).should be false
@aspect3.people.include?(@friend).should be false
end
it "should not move a person to a aspect that's not his" do
@user.move_friend(:friend_id => @user2.person.id, :from => @aspect.id, :to => @aspect2.id)
@aspect.reload
@aspect2.reload
@aspect.people.include?(@user2.person).should be true
@aspect.people.include?(@user2.person).should be true
@aspect2.people.include?(@user2.person).should be false
end
it 'should move all the by that user to the new aspect' do
message = @user2.post(:status_message, :message => "Hey Dude", :to => @aspect2.id)
@user.receive message.to_diaspora_xml
@aspect.reload
@aspect.posts.count.should be 1
@aspect3.posts.count.should be 0
@user.reload
@user.move_friend(:friend_id => @user2.person.id, :from => @aspect.id, :to => @aspect3.id)
@aspect.reload

View file

@ -27,7 +27,7 @@ describe Comment do
person= Factory.create :person
status = Factory.create(:status_message, :person => person)
@user.comment "sup dog", :on => status
StatusMessage.first.comments.first.text.should == "sup dog"
StatusMessage.first.comments.first.person.should == @user.person
end
@ -45,7 +45,7 @@ describe Comment do
@person = Factory.create(:person)
@user.activate_friend(@person, Aspect.first(:id => @aspect.id))
@person2 = Factory.create(:person)
@person2 = Factory.create(:person)
@person_status = Factory.build(:status_message, :person => @person)
@user.reload
@ -54,7 +54,7 @@ describe Comment do
@aspect.reload
@user.reload
end
it 'should have the post in the aspects post list' do
aspect = Aspect.first(:id => @aspect.id)
aspect.people.size.should == 2
@ -65,32 +65,32 @@ describe Comment do
User::QUEUE.should_receive(:add_post_request)
@user.comment "yo", :on => @person_status
end
it 'should send a user comment on his own post to lots of people' do
User::QUEUE.should_receive(:add_post_request).twice
@user.comment "yo", :on => @user_status
end
it 'should send a comment a person made on your post to all people' do
comment = Comment.new(:person_id => @person.id, :text => "balls", :post => @user_status)
User::QUEUE.should_receive(:add_post_request).twice
@user.receive(comment.to_diaspora_xml)
end
it 'should send a comment a user made on your post to all people' do
comment = @user2.comment( "balls", :on => @user_status)
User::QUEUE.should_receive(:add_post_request).twice
@user.receive(comment.to_diaspora_xml)
end
it 'should not send a comment a person made on his own post to anyone' do
User::QUEUE.should_not_receive(:add_post_request)
comment = Comment.new(:person_id => @person.id, :text => "balls", :post => @person_status)
@user.receive(comment.to_diaspora_xml)
end
it 'should not send a comment a person made on a person post to anyone' do
User::QUEUE.should_not_receive(:add_post_request)
comment = Comment.new(:person_id => @person2.id, :text => "balls", :post => @person_status)

View file

@ -21,7 +21,7 @@ describe Person do
end
describe 'xml' do
before do
before do
@xml = @person.to_xml.to_s
end
@ -33,7 +33,7 @@ describe Person do
@xml.include?("first_name").should == true
end
end
it 'should know when a post belongs to it' do
person_message = Factory.create(:status_message, :person => @person)
person_two = Factory.create(:person)
@ -51,7 +51,7 @@ describe Person do
Factory.create(:status_message, :person => person)
status_message = Factory.create(:status_message, :person => @person)
Factory.create(:comment, :person_id => person.id, :text => "yes i do", :post => status_message)
Factory.create(:comment, :person_id => person.id, :text => "i love you", :post => status_message)
Factory.create(:comment, :person_id => person.id, :text => "hello", :post => status_message)
@ -68,9 +68,9 @@ describe Person do
it 'should not delete an orphaned friend' do
request = @user.send_friend_request_to @person, @aspect
@user.activate_friend(@person, @aspect)
@user.activate_friend(@person, @aspect)
@user.reload
Person.all.count.should == 3
@user.friends.count.should == 1
@user.unfriend(@person)
@ -83,12 +83,12 @@ describe Person do
request = @user.send_friend_request_to @person, @aspect
request2 = @user2.send_friend_request_to @person, @aspect2
@user.activate_friend(@person, @aspect)
@user.activate_friend(@person, @aspect)
@user2.activate_friend(@person, @aspect2)
@user.reload
@user2.reload
Person.all.count.should == 3
@user.friends.count.should == 1
@user2.friends.count.should == 1
@ -128,19 +128,19 @@ describe Person do
end
it 'should yield search results on partial names' do
people = Person.search("Eu")
people = Person.search("Eu")
people.include?(@friend_two).should == true
people.include?(@friend_one).should == false
people.include?(@friend_three).should == false
people.include?(@friend_four).should == false
people = Person.search("Wei")
people = Person.search("Wei")
people.include?(@friend_two).should == true
people.include?(@friend_one).should == false
people.include?(@friend_three).should == false
people.include?(@friend_four).should == false
people = Person.search("Gri")
people = Person.search("Gri")
people.include?(@friend_one).should == true
people.include?(@friend_four).should == true
people.include?(@friend_two).should == false
@ -159,18 +159,18 @@ describe Person do
tom = Person.by_webfinger('tom@tom.joindiaspora.com')
tom.real_name.include?("Hamiltom").should be true
end
describe 'wall posting' do
describe 'wall posting' do
it 'should be able to post on another persons wall' do
pending
#user2 is in user's aspect, user is in aspect2 on user
friend_users(@user, @aspect, @user2, @aspect2)
@user.person.post_to_wall(:person => @user2.person, :message => "youve got a great smile")
@user.person.wall_posts.count.should == 1
end
end
end
end

View file

@ -22,8 +22,8 @@ describe Photo do
it 'should have a constructor' do
pending "Figure out how to make the photo posting api work in specs, it needs a file type"
image = File.open(@fixture_name)
photo = Photo.instantiate(:person => @user.person, :album => @album, :user_file => [image])
image = File.open(@fixture_name)
photo = Photo.instantiate(:person => @user.person, :album => @album, :user_file => [image])
photo.created_at.nil?.should be false
photo.image.read.nil?.should be false
end
@ -82,13 +82,13 @@ describe Photo do
end
end
describe 'with encryption' do
before do
unstub_mocha_stubs
end
after do
stub_signature_verification
end
@ -99,15 +99,15 @@ describe Photo do
photo.save.should == true
photo.signature_valid?.should be true
end
end
describe 'remote photos' do
it 'should write the url on serialization' do
it 'should write the url on serialization' do
@photo.image = File.open(@fixture_name)
@photo.image.store!
@photo.save
xml = @photo.to_xml.to_s
xml.include?(@photo.image.url).should be true
@ -124,7 +124,7 @@ describe Photo do
@photo.save
@photo.reload
url = @photo.url
thumb_url = @photo.url :thumb_medium
@ -133,7 +133,7 @@ describe Photo do
@photo.destroy
@user.receive xml
new_photo = Photo.first(:id => id)
new_photo.url.nil?.should be false
new_photo.url.include?(url).should be true

View file

@ -11,7 +11,7 @@ describe Post do
@user = Factory.create(:user, :email => "bob@aol.com")
@user.person.save
end
describe 'xml' do
before do
@message = Factory.create(:status_message, :person => @user.person)

View file

@ -18,13 +18,13 @@ describe Profile do
@person.profile.first_name = "Bob"
@person.profile.valid?.should be true
end
it "should include a last name" do
@person.profile = Factory.build(:profile, :last_name => nil)
@person.profile.valid?.should be false
@person.profile.last_name = "Smith"
@person.profile.valid?.should be true
end
end
end

View file

@ -6,7 +6,7 @@
require File.dirname(__FILE__) + '/../spec_helper'
describe Request do
describe Request do
before do
@user = Factory.create(:user)
@aspect = @user.aspect(:name => "dudes")
@ -19,7 +19,7 @@ describe Request do
person_request.valid?.should be true
end
it 'should generate xml for the User as a Person' do
it 'should generate xml for the User as a Person' do
request = @user.send_friend_request_to Factory.create(:person), @aspect
@ -31,14 +31,14 @@ describe Request do
xml.include?(@user.profile.last_name).should be true
end
it 'should allow me to see only friend requests sent to me' do
it 'should allow me to see only friend requests sent to me' do
remote_person = Factory.build(:person, :diaspora_handle => "robert@grimm.com", :url => "http://king.com/")
Request.instantiate(:into => @aspect.id, :from => @user.person, :to => remote_person.receive_url).save
Request.instantiate(:into => @aspect.id, :from => @user.person, :to => remote_person.receive_url).save
Request.instantiate(:into => @aspect.id, :from => @user.person, :to => remote_person.receive_url).save
Request.instantiate(:into => @aspect.id, :from => remote_person, :to => @user.receive_url).save
Request.for_user(@user).all.count.should == 1
end

View file

@ -12,13 +12,13 @@ describe StatusMessage do
@aspect = @user.aspect(:name => "losers")
end
it "should have a message" do
it "should have a message" do
n = Factory.build(:status_message, :message => nil)
n.valid?.should be false
n.message = "wales"
n.valid?.should be true
end
it 'should be postable through the user' do
status = @user.post(:status_message, :message => "Users do things", :to => @aspect.id)
end
@ -28,9 +28,9 @@ describe StatusMessage do
message = Factory.create(:status_message, :message => "I hate WALRUSES!", :person => @user.person)
message.to_xml.to_s.should include "<message>I hate WALRUSES!</message>"
end
it 'should marshal serialized XML to object' do
xml = "<statusmessage><message>I hate WALRUSES!</message></statusmessage>"
it 'should marshal serialized XML to object' do
xml = "<statusmessage><message>I hate WALRUSES!</message></statusmessage>"
parsed = StatusMessage.from_xml(xml)
parsed.message.should == "I hate WALRUSES!"
parsed.valid?.should be_true

View file

@ -13,7 +13,7 @@ describe User do
@aspect1 = @user.aspect(:name => 'heroes')
@user2 = Factory.create(:user)
@aspect2 = @user2.aspect(:name => 'losers')
@aspect2 = @user2.aspect(:name => 'losers')
@user3 = Factory.create(:user)
@aspect3 = @user3.aspect(:name => 'heroes')
@ -27,7 +27,7 @@ describe User do
end
it 'should not be able to post without a aspect' do
proc {@user.post(:status_message, :message => "heyheyhey")}.should raise_error /You must post to someone/
proc {@user.post(:status_message, :message => "heyheyhey")}.should raise_error /You must post to someone/
end
it 'should put the post in the aspect post array' do
@ -61,7 +61,7 @@ describe User do
@user.should_receive(:salmon).twice
@user.push_to_people(@post, [@user2.person, @user3.person])
end
end
end

View file

@ -13,7 +13,7 @@ describe User do
@aspect = @user.aspect(:name => 'heroes')
@user2 = Factory.create(:user)
@aspect2 = @user2.aspect(:name => 'losers')
@aspect2 = @user2.aspect(:name => 'losers')
@user3 = Factory.create(:user)
@aspect3 = @user3.aspect(:name => 'heroes')
@ -30,14 +30,14 @@ describe User do
status_message.destroy
StatusMessage.all.size.should == 0
@user.receive( xml )
Post.all(:person_id => person.id).first.message.should == 'store this!'
StatusMessage.all.size.should == 1
end
it 'should not create new aspects on message receive' do
num_aspects = @user.aspects.size
(0..5).each{ |n|
status_message = @user2.post :status_message, :message => "store this #{n}!", :to => @aspect2.id
xml = status_message.to_diaspora_xml
@ -51,7 +51,7 @@ describe User do
before do
end
it "should add the post to that user's posts when a user posts it" do
status_message = @user.post :status_message, :message => "hi", :to => @aspect.id
@user.reload
@ -64,12 +64,12 @@ describe User do
@user.reload
@user.raw_visible_posts.count.should == 1
@user.unfriend(@user2.person)
@user.reload
@user.raw_visible_posts.count.should == 0
Post.count.should be 1
end
@ -79,14 +79,14 @@ describe User do
@user.reload
@user.raw_visible_posts.count.should == 1
person = @user2.person
@user2.destroy
@user.unfriend(person)
@user.reload
@user.raw_visible_posts.count.should == 0
Post.count.should be 0
end
@ -96,10 +96,10 @@ describe User do
@user.reload
@user.raw_visible_posts.count.should == 1
status_message.reload
status_message.user_refs.should == 1
@user.unfriend(@user2.person)
status_message.reload
@ -108,7 +108,7 @@ describe User do
status_message.reload
status_message.user_refs.should == 0
Post.count.should be 1
end
@ -123,10 +123,10 @@ describe User do
@user3.reload
@user.raw_visible_posts.count.should == 1
status_message.reload
status_message.user_refs.should == 2
@user.unfriend(@user2.person)
status_message.reload
@ -135,14 +135,14 @@ describe User do
status_message.reload
status_message.user_refs.should == 1
Post.count.should be 1
end
end
describe 'comments' do
it 'should correctly marshal a stranger for the downstream user' do
friend_users(@user, @aspect, @user3, @aspect3)
post = @user.post :status_message, :message => "hello", :to => @aspect.id
@ -167,7 +167,7 @@ describe User do
new_comment.should_not be_nil
new_comment.person.should_not be_nil
new_comment.person.profile.should_not be_nil
@user3.visible_person_by_id(commenter_id).should_not be_nil
end
end

View file

@ -49,7 +49,7 @@ describe User do
end
it 'should not be able to friend request an existing friend' do friend = Factory.create(:person)
@user.friends << friend
@user.save
@ -63,7 +63,7 @@ describe User do
before do
@person_one = Factory.create :person
@person_one.save
@user2 = Factory.create :user
@aspect2 = @user2.aspect(:name => "aspect two")
@ -90,7 +90,7 @@ describe User do
@user2.receive @req_three_xml
@user2.pending_requests.size.should be 1
@user2.accept_friend_request @request_three.id, @aspect2.id
@user2.friends.include?(@user.person).should be true
@user2.friends.include?(@user.person).should be true
Person.all.count.should be 3
end
@ -99,21 +99,21 @@ describe User do
@user2.receive @req_three_xml
@user2.pending_requests.size.should be 1
@user2.ignore_friend_request @request_three.id
@user2.friends.include?(@user.person).should be false
@user2.friends.include?(@user.person).should be false
Person.all.count.should be 3
end
it 'should both users should befriend the same person' do
@user.receive @req_xml
@user.pending_requests.size.should be 1
@user.accept_friend_request @request.id, @aspect.id
@user.friends.include?(@person_one).should be true
@user.friends.include?(@person_one).should be true
@user2.receive @req_two_xml
@user2.pending_requests.size.should be 1
@user2.accept_friend_request @request_two.id, @aspect2.id
@user2.friends.include?(@person_one).should be true
@user2.friends.include?(@person_one).should be true
Person.all.count.should be 3
end
@ -122,12 +122,12 @@ describe User do
@user.receive @req_xml
@user.pending_requests.size.should be 1
@user.accept_friend_request @request.id, @aspect.id
@user.friends.include?(@person_one).should be true
@user.friends.include?(@person_one).should be true
@user2.receive @req_two_xml
@user2.pending_requests.size.should be 1
@user2.ignore_friend_request @request_two.id
@user2.friends.include?(@person_one).should be false
@user2.friends.include?(@person_one).should be false
Person.all.count.should be 3
end
@ -135,12 +135,12 @@ describe User do
@user.receive @req_xml
@user.pending_requests.size.should be 1
@user.ignore_friend_request @user.pending_requests.first.id
@user.friends.include?(@person_one).should be false
@user.friends.include?(@person_one).should be false
@user2.receive @req_two_xml
@user2.pending_requests.size.should be 1
@user2.ignore_friend_request @user2.pending_requests.first.id#@request_two.id
@user2.friends.include?(@person_one).should be false
@user2.friends.include?(@person_one).should be false
Person.all.count.should be 3
end
@ -158,9 +158,9 @@ describe User do
@request = Request.instantiate(:to => @user.receive_url, :from => @person_one)
@request_two = Request.instantiate(:to => @user.receive_url, :from => @person_two)
end
after do
@user.receive_friend_request @request
@user.receive_friend_request @request
@person_two.destroy
@user.pending_requests.size.should be 1
@ -188,9 +188,9 @@ describe User do
before do
@user2 = Factory.create :user
@aspect2 = @user2.aspect(:name => "Gross people")
request = @user.send_friend_request_to( @user2, @aspect)
request.reverse_for @user2
request.reverse_for @user2
@user2.activate_friend(@user.person, @aspect2)
@user.receive request.to_diaspora_xml
end
@ -201,7 +201,7 @@ describe User do
@user.friends.count.should == 1
@user2.friends.count.should == 1
@user2.unfriend @user.person
@user2.friends.count.should be 0

View file

@ -20,7 +20,7 @@ describe User do
@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)

View file

@ -13,11 +13,11 @@ describe User do
end
describe 'profiles' do
it 'should be able to update their profile and send it to their friends' do
it 'should be able to update their profile and send it to their friends' do
Factory.create(:person)
updated_profile = {:profile => {:first_name => 'bob', :last_name => 'billytown', :image_url => "http://clown.com"}}
@user.update_profile(updated_profile).should == true
@user.profile.image_url.should == "http://clown.com"
end

View file

@ -74,7 +74,7 @@ end
def friend_users(user1, aspect1, user2, aspect2)
request = user1.send_friend_request_to(user2.person, aspect1)
reversed_request = user2.accept_friend_request( request.id, aspect2.id)
reversed_request = user2.accept_friend_request( request.id, aspect2.id)
user1.receive reversed_request.to_diaspora_xml
end

View file

@ -45,24 +45,24 @@ describe 'user encryption' do
it 'should receive and marshal a public key from a request' do
remote_user = Factory.build(:user)
remote_user.encryption_key.nil?.should== false
#should move this to friend request, but i found it here
#should move this to friend request, but i found it here
id = remote_user.person.id
original_key = remote_user.exported_key
request = remote_user.send_friend_request_to(
@user.person, remote_user.aspect(:name => "temp"))
xml = request.to_diaspora_xml
remote_user.person.destroy
remote_user.destroy
person_count = Person.all.count
proc {@user.receive xml}.should_not raise_error /ignature was not valid/
Person.all.count.should == person_count + 1
new_person = Person.first(:id => id)
new_person.exported_key.should == original_key
end
end
end
describe 'encryption' do