From fbdd50172dff5c272a2150be2c95f361374ecbe1 Mon Sep 17 00:00:00 2001 From: Jamie Wilkinson Date: Thu, 16 Sep 2010 10:01:29 +0800 Subject: [PATCH] Cleanup stray whitespace --- app/controllers/albums_controller.rb | 10 +-- app/controllers/application_controller.rb | 10 +-- app/controllers/aspects_controller.rb | 8 +-- app/controllers/comments_controller.rb | 2 +- app/controllers/dev_utilities_controller.rb | 26 ++++---- app/controllers/people_controller.rb | 12 ++-- app/controllers/photos_controller.rb | 16 ++--- app/controllers/publics_controller.rb | 6 +- app/controllers/requests_controller.rb | 14 ++-- app/controllers/sockets_controller.rb | 6 +- app/controllers/status_messages_controller.rb | 4 +- app/controllers/users_controller.rb | 6 +- app/helpers/albums_helper.rb | 2 +- app/helpers/application_helper.rb | 12 ++-- app/helpers/error_messages_helper.rb | 4 +- app/helpers/layout_helper.rb | 6 +- app/helpers/people_helper.rb | 4 +- app/helpers/photos_helper.rb | 2 +- app/helpers/publics_helper.rb | 2 +- app/helpers/requests_helper.rb | 2 +- app/helpers/sockets_helper.rb | 10 +-- app/models/album.rb | 4 +- app/models/aspect.rb | 6 +- app/models/comment.rb | 20 +++--- app/models/person.rb | 18 +++--- app/models/photo.rb | 10 +-- app/models/post.rb | 16 ++--- app/models/profile.rb | 2 +- app/models/request.rb | 8 +-- app/models/retraction.rb | 2 +- app/models/status_message.rb | 8 +-- app/models/user.rb | 38 +++++------ config/application.rb | 2 +- config/deploy.rb | 36 +++++------ config/environments/test.rb | 4 +- config/initializers/devise.rb | 8 +-- config/initializers/inflections.rb | 2 +- config/initializers/secret_token.rb | 2 +- config/initializers/socket.rb | 8 +-- config/sprinkle/packages/database.rb | 2 +- config/sprinkle/packages/essential.rb | 10 +-- config/sprinkle/packages/scm.rb | 6 +- config/sprinkle/provision.rb | 2 +- db/schema.rb | 2 +- db/seeds/backer.rb | 4 +- db/seeds/dev.rb | 2 +- db/seeds/tom.rb | 2 +- lib/chrome_frame.rb | 2 +- lib/diaspora/user/friending.rb | 16 ++--- lib/diaspora/websocket.rb | 8 +-- lib/encryptable.rb | 6 +- lib/encryptor.rb | 2 +- lib/message_handler.rb | 10 +-- lib/salmon/salmon.rb | 12 ++-- spec/controllers/aspects_controller_spec.rb | 6 +- spec/controllers/people_controller_spec.rb | 6 +- spec/controllers/publics_controller_spec.rb | 16 ++--- spec/controllers/requests_controller_spec.rb | 6 +- spec/controllers/sockets_controller_spec.rb | 6 +- spec/factories.rb | 2 +- spec/helpers/application_helper_spec.rb | 2 +- spec/helpers/publics_helper_spec.rb | 2 +- spec/helpers/requests_helper_spec.rb | 4 +- spec/lib/diaspora_parser_spec.rb | 64 +++++++++---------- spec/lib/message_handler_spec.rb | 30 ++++----- spec/lib/salmon_salmon_spec.rb | 8 +-- spec/misc_spec.rb | 12 ++-- spec/models/album_spec.rb | 6 +- spec/models/aspect_spec.rb | 32 +++++----- spec/models/comments_spec.rb | 18 +++--- spec/models/person_spec.rb | 30 ++++----- spec/models/photo_spec.rb | 20 +++--- spec/models/post_spec.rb | 2 +- spec/models/profile_spec.rb | 4 +- spec/models/request_spec.rb | 10 +-- spec/models/status_message_spec.rb | 10 +-- spec/models/user/posting_spec.rb | 8 +-- spec/models/user/receive_spec.rb | 34 +++++----- spec/models/user/user_friending_spec.rb | 32 +++++----- spec/models/user/visible_posts_spec.rb | 2 +- spec/models/user_spec.rb | 6 +- spec/spec_helper.rb | 2 +- spec/user_encryption_spec.rb | 12 ++-- 83 files changed, 418 insertions(+), 418 deletions(-) diff --git a/app/controllers/albums_controller.rb b/app/controllers/albums_controller.rb index f2047e0c2..f4d797a46 100644 --- a/app/controllers/albums_controller.rb +++ b/app/controllers/albums_controller.rb @@ -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}." diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 80ab618f8..f0ca5bfc8 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -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 diff --git a/app/controllers/aspects_controller.rb b/app/controllers/aspects_controller.rb index ac9f1f837..87c41f097 100644 --- a/app/controllers/aspects_controller.rb +++ b/app/controllers/aspects_controller.rb @@ -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]) diff --git a/app/controllers/comments_controller.rb b/app/controllers/comments_controller.rb index cf70d884a..dc115ab5b 100644 --- a/app/controllers/comments_controller.rb +++ b/app/controllers/comments_controller.rb @@ -5,7 +5,7 @@ class CommentsController < ApplicationController before_filter :authenticate_user! - + respond_to :html respond_to :json, :only => :show diff --git a/app/controllers/dev_utilities_controller.rb b/app/controllers/dev_utilities_controller.rb index 8533696b7..bcb0dd4f7 100644 --- a/app/controllers/dev_utilities_controller.rb +++ b/app/controllers/dev_utilities_controller.rb @@ -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 diff --git a/app/controllers/people_controller.rb b/app/controllers/people_controller.rb index 648af9f2d..78b0803c0 100644 --- a/app/controllers/people_controller.rb +++ b/app/controllers/people_controller.rb @@ -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 diff --git a/app/controllers/photos_controller.rb b/app/controllers/photos_controller.rb index f233a3a91..cefc8f5d6 100644 --- a/app/controllers/photos_controller.rb +++ b/app/controllers/photos_controller.rb @@ -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 diff --git a/app/controllers/publics_controller.rb b/app/controllers/publics_controller.rb index 9b0e6e37e..07cf63dc8 100644 --- a/app/controllers/publics_controller.rb +++ b/app/controllers/publics_controller.rb @@ -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 diff --git a/app/controllers/requests_controller.rb b/app/controllers/requests_controller.rb index 42bbe856a..5983c0e2e 100644 --- a/app/controllers/requests_controller.rb +++ b/app/controllers/requests_controller.rb @@ -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 diff --git a/app/controllers/sockets_controller.rb b/app/controllers/sockets_controller.rb index b997fe629..2852a7160 100644 --- a/app/controllers/sockets_controller.rb +++ b/app/controllers/sockets_controller.rb @@ -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 diff --git a/app/controllers/status_messages_controller.rb b/app/controllers/status_messages_controller.rb index d126d2da8..5a588fb99 100644 --- a/app/controllers/status_messages_controller.rb +++ b/app/controllers/status_messages_controller.rb @@ -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 diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 87b6f1e70..4a36672bc 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -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 diff --git a/app/helpers/albums_helper.rb b/app/helpers/albums_helper.rb index 5f4194558..50b7fbaf7 100644 --- a/app/helpers/albums_helper.rb +++ b/app/helpers/albums_helper.rb @@ -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 diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 169b86485..6c4240578 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -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 diff --git a/app/helpers/error_messages_helper.rb b/app/helpers/error_messages_helper.rb index 8f057ee1c..699070b70 100644 --- a/app/helpers/error_messages_helper.rb +++ b/app/helpers/error_messages_helper.rb @@ -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) diff --git a/app/helpers/layout_helper.rb b/app/helpers/layout_helper.rb index b6931d8b5..2398771a3 100644 --- a/app/helpers/layout_helper.rb +++ b/app/helpers/layout_helper.rb @@ -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 diff --git a/app/helpers/people_helper.rb b/app/helpers/people_helper.rb index 3631ce041..37d18d20f 100644 --- a/app/helpers/people_helper.rb +++ b/app/helpers/people_helper.rb @@ -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 diff --git a/app/helpers/photos_helper.rb b/app/helpers/photos_helper.rb index e18a99391..2d0ddad6e 100644 --- a/app/helpers/photos_helper.rb +++ b/app/helpers/photos_helper.rb @@ -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 diff --git a/app/helpers/publics_helper.rb b/app/helpers/publics_helper.rb index af84ee3a2..9e76f59f7 100644 --- a/app/helpers/publics_helper.rb +++ b/app/helpers/publics_helper.rb @@ -15,7 +15,7 @@ module PublicsHelper elsif opts[:verify] == 'async' 202 end - else + else 400 end end diff --git a/app/helpers/requests_helper.rb b/app/helpers/requests_helper.rb index 60489c36e..32ce79fd9 100644 --- a/app/helpers/requests_helper.rb +++ b/app/helpers/requests_helper.rb @@ -9,7 +9,7 @@ module RequestsHelper if diaspora?(profile) :friend else - :none + :none end end diff --git a/app/helpers/sockets_helper.rb b/app/helpers/sockets_helper.rb index 7202fd3ed..cbe465e7b 100644 --- a/app/helpers/sockets_helper.rb +++ b/app/helpers/sockets_helper.rb @@ -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 diff --git a/app/models/album.rb b/app/models/album.rb index b0998521f..10737bdfa 100644 --- a/app/models/album.rb +++ b/app/models/album.rb @@ -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 diff --git a/app/models/aspect.rb b/app/models/aspect.rb index 591b8427d..96f94e8fe 100644 --- a/app/models/aspect.rb +++ b/app/models/aspect.rb @@ -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 } diff --git a/app/models/comment.rb b/app/models/comment.rb index 5c14f6608..3fa986503 100644 --- a/app/models/comment.rb +++ b/app/models/comment.rb @@ -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 diff --git a/app/models/person.rb b/app/models/person.rb index 095c88293..121fdde56 100644 --- a/app/models/person.rb +++ b/app/models/person.rb @@ -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 diff --git a/app/models/photo.rb b/app/models/photo.rb index b89cd251b..8792911f3 100644 --- a/app/models/photo.rb +++ b/app/models/photo.rb @@ -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 diff --git a/app/models/post.rb b/app/models/post.rb index da54a9326..e2dd53d3d 100644 --- a/app/models/post.rb +++ b/app/models/post.rb @@ -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 diff --git a/app/models/profile.rb b/app/models/profile.rb index 365ecf4fd..f03843226 100644 --- a/app/models/profile.rb +++ b/app/models/profile.rb @@ -23,7 +23,7 @@ class Profile def person_id self._parent_document.id end - + def person self._parent_document end diff --git a/app/models/request.rb b/app/models/request.rb index 0043a61c9..da62edd93 100644 --- a/app/models/request.rb +++ b/app/models/request.rb @@ -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 diff --git a/app/models/retraction.rb b/app/models/retraction.rb index 23c0e6fea..9c1f13f45 100644 --- a/app/models/retraction.rb +++ b/app/models/retraction.rb @@ -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 diff --git a/app/models/status_message.rb b/app/models/status_message.rb index b56d5f1ff..f75536205 100644 --- a/app/models/status_message.rb +++ b/app/models/status_message.rb @@ -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 @@ -24,7 +24,7 @@ class StatusMessage < Post XML end - + def latest_hash { :text => message} end diff --git a/app/models/user.rb b/app/models/user.rb index f2a213d1c..c02ea7d5b 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -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] == '/' diff --git a/config/application.rb b/config/application.rb index 3beb23b5f..ef8a567a5 100644 --- a/config/application.rb +++ b/config/application.rb @@ -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 ] diff --git a/config/deploy.rb b/config/deploy.rb index 446f8f7a6..51664fb6a 100644 --- a/config/deploy.rb +++ b/config/deploy.rb @@ -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 diff --git a/config/environments/test.rb b/config/environments/test.rb index 41aefad35..4e17d81e8 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -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 diff --git a/config/initializers/devise.rb b/config/initializers/devise.rb index d882f6038..9f483a8bf 100644 --- a/config/initializers/devise.rb +++ b/config/initializers/devise.rb @@ -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 diff --git a/config/initializers/inflections.rb b/config/initializers/inflections.rb index ba731fa19..3171994ee 100644 --- a/config/initializers/inflections.rb +++ b/config/initializers/inflections.rb @@ -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' diff --git a/config/initializers/secret_token.rb b/config/initializers/secret_token.rb index de86a04fa..c61c96d33 100644 --- a/config/initializers/secret_token.rb +++ b/config/initializers/secret_token.rb @@ -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' diff --git a/config/initializers/socket.rb b/config/initializers/socket.rb index 198036c2f..1fd09fd93 100644 --- a/config/initializers/socket.rb +++ b/config/initializers/socket.rb @@ -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) } diff --git a/config/sprinkle/packages/database.rb b/config/sprinkle/packages/database.rb index cabfeba3e..ab0eb1614 100644 --- a/config/sprinkle/packages/database.rb +++ b/config/sprinkle/packages/database.rb @@ -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 diff --git a/config/sprinkle/packages/essential.rb b/config/sprinkle/packages/essential.rb index 7c00d9d0d..fba076e27 100644 --- a/config/sprinkle/packages/essential.rb +++ b/config/sprinkle/packages/essential.rb @@ -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 diff --git a/config/sprinkle/packages/scm.rb b/config/sprinkle/packages/scm.rb index 410f91a87..722baab39 100644 --- a/config/sprinkle/packages/scm.rb +++ b/config/sprinkle/packages/scm.rb @@ -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 diff --git a/config/sprinkle/provision.rb b/config/sprinkle/provision.rb index f980f8b3f..f04866431 100644 --- a/config/sprinkle/provision.rb +++ b/config/sprinkle/provision.rb @@ -43,6 +43,6 @@ deployment do binary do prefix '/usr/local/bin' archives '/usr/local/sources' - end + end end diff --git a/db/schema.rb b/db/schema.rb index df5a09c9b..a4f92eb4b 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -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. # diff --git a/db/seeds/backer.rb b/db/seeds/backer.rb index 975409be3..b32b62377 100644 --- a/db/seeds/backer.rb +++ b/db/seeds/backer.rb @@ -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/") ) diff --git a/db/seeds/dev.rb b/db/seeds/dev.rb index f95c1aa50..12c728ddf 100644 --- a/db/seeds/dev.rb +++ b/db/seeds/dev.rb @@ -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"))) diff --git a/db/seeds/tom.rb b/db/seeds/tom.rb index c67c2732c..af6f737a9 100644 --- a/db/seeds/tom.rb +++ b/db/seeds/tom.rb @@ -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"}}) diff --git a/lib/chrome_frame.rb b/lib/chrome_frame.rb index 4fc42b7de..10ef3dea3 100644 --- a/lib/chrome_frame.rb +++ b/lib/chrome_frame.rb @@ -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/ diff --git a/lib/diaspora/user/friending.rb b/lib/diaspora/user/friending.rb index 50aae336a..cf55a2bf0 100644 --- a/lib/diaspora/user/friending.rb +++ b/lib/diaspora/user/friending.rb @@ -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 )} diff --git a/lib/diaspora/websocket.rb b/lib/diaspora/websocket.rb index 796484dd7..fc79559f6 100644 --- a/lib/diaspora/websocket.rb +++ b/lib/diaspora/websocket.rb @@ -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 diff --git a/lib/encryptable.rb b/lib/encryptable.rb index fa9c96045..ba36d6ec3 100644 --- a/lib/encryptable.rb +++ b/lib/encryptable.rb @@ -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) diff --git a/lib/encryptor.rb b/lib/encryptor.rb index 63f9ee890..ed9fbedb1 100644 --- a/lib/encryptor.rb +++ b/lib/encryptor.rb @@ -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 diff --git a/lib/message_handler.rb b/lib/message_handler.rb index b2b399298..7149ee65e 100644 --- a/lib/message_handler.rb +++ b/lib/message_handler.rb @@ -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 diff --git a/lib/salmon/salmon.rb b/lib/salmon/salmon.rb index 61b58a334..931598691 100644 --- a/lib/salmon/salmon.rb +++ b/lib/salmon/salmon.rb @@ -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 diff --git a/spec/controllers/aspects_controller_spec.rb b/spec/controllers/aspects_controller_spec.rb index c6f85838d..a186e8b7c 100644 --- a/spec/controllers/aspects_controller_spec.rb +++ b/spec/controllers/aspects_controller_spec.rb @@ -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 diff --git a/spec/controllers/people_controller_spec.rb b/spec/controllers/people_controller_spec.rb index f0f3c0462..badfdf496 100644 --- a/spec/controllers/people_controller_spec.rb +++ b/spec/controllers/people_controller_spec.rb @@ -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 diff --git a/spec/controllers/publics_controller_spec.rb b/spec/controllers/publics_controller_spec.rb index 86f013ae2..91f0e0371 100644 --- a/spec/controllers/publics_controller_spec.rb +++ b/spec/controllers/publics_controller_spec.rb @@ -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 diff --git a/spec/controllers/requests_controller_spec.rb b/spec/controllers/requests_controller_spec.rb index 7da3d062e..f0864abe1 100644 --- a/spec/controllers/requests_controller_spec.rb +++ b/spec/controllers/requests_controller_spec.rb @@ -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") diff --git a/spec/controllers/sockets_controller_spec.rb b/spec/controllers/sockets_controller_spec.rb index c8316b82c..4104d0d51 100644 --- a/spec/controllers/sockets_controller_spec.rb +++ b/spec/controllers/sockets_controller_spec.rb @@ -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) diff --git a/spec/factories.rb b/spec/factories.rb index 1a6177363..918a210f2 100644 --- a/spec/factories.rb +++ b/spec/factories.rb @@ -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| diff --git a/spec/helpers/application_helper_spec.rb b/spec/helpers/application_helper_spec.rb index 4e3b70c96..4b89c7b31 100644 --- a/spec/helpers/application_helper_spec.rb +++ b/spec/helpers/application_helper_spec.rb @@ -6,7 +6,7 @@ require File.dirname(__FILE__) + '/../spec_helper' -include ApplicationHelper +include ApplicationHelper describe ApplicationHelper do before do @user = Factory.create(:user) diff --git a/spec/helpers/publics_helper_spec.rb b/spec/helpers/publics_helper_spec.rb index 44a0c869f..70e9d4606 100644 --- a/spec/helpers/publics_helper_spec.rb +++ b/spec/helpers/publics_helper_spec.rb @@ -6,7 +6,7 @@ require File.dirname(__FILE__) + '/../spec_helper' -include PublicsHelper +include PublicsHelper describe PublicsHelper do before do @user = Factory.create(:user) diff --git a/spec/helpers/requests_helper_spec.rb b/spec/helpers/requests_helper_spec.rb index 3e90a509d..2d2be1acb 100644 --- a/spec/helpers/requests_helper_spec.rb +++ b/spec/helpers/requests_helper_spec.rb @@ -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') diff --git a/spec/lib/diaspora_parser_spec.rb b/spec/lib/diaspora_parser_spec.rb index dbc11237c..cdd1063ab 100644 --- a/spec/lib/diaspora_parser_spec.rb +++ b/spec/lib/diaspora_parser_spec.rb @@ -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 diff --git a/spec/lib/message_handler_spec.rb b/spec/lib/message_handler_spec.rb index db97872d0..00db2a1b8 100644 --- a/spec/lib/message_handler_spec.rb +++ b/spec/lib/message_handler_spec.rb @@ -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 diff --git a/spec/lib/salmon_salmon_spec.rb b/spec/lib/salmon_salmon_spec.rb index 74be347d4..a14ef8f77 100644 --- a/spec/lib/salmon_salmon_spec.rb +++ b/spec/lib/salmon_salmon_spec.rb @@ -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 diff --git a/spec/misc_spec.rb b/spec/misc_spec.rb index 34850913b..14f1d4c3e 100644 --- a/spec/misc_spec.rb +++ b/spec/misc_spec.rb @@ -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 diff --git a/spec/models/album_spec.rb b/spec/models/album_spec.rb index 2edebecf6..189361622 100644 --- a/spec/models/album_spec.rb +++ b/spec/models/album_spec.rb @@ -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 diff --git a/spec/models/aspect_spec.rb b/spec/models/aspect_spec.rb index bb14e2055..5931970cf 100644 --- a/spec/models/aspect_spec.rb +++ b/spec/models/aspect_spec.rb @@ -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 diff --git a/spec/models/comments_spec.rb b/spec/models/comments_spec.rb index 5a0199b61..1c20354cf 100644 --- a/spec/models/comments_spec.rb +++ b/spec/models/comments_spec.rb @@ -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) diff --git a/spec/models/person_spec.rb b/spec/models/person_spec.rb index f41c14b3e..bffe37f85 100644 --- a/spec/models/person_spec.rb +++ b/spec/models/person_spec.rb @@ -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 diff --git a/spec/models/photo_spec.rb b/spec/models/photo_spec.rb index da65f43fc..516c16df8 100644 --- a/spec/models/photo_spec.rb +++ b/spec/models/photo_spec.rb @@ -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 diff --git a/spec/models/post_spec.rb b/spec/models/post_spec.rb index c3d3777b1..dc9d4a9b8 100644 --- a/spec/models/post_spec.rb +++ b/spec/models/post_spec.rb @@ -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) diff --git a/spec/models/profile_spec.rb b/spec/models/profile_spec.rb index ad2a7a6be..b5bd8f9a5 100644 --- a/spec/models/profile_spec.rb +++ b/spec/models/profile_spec.rb @@ -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 diff --git a/spec/models/request_spec.rb b/spec/models/request_spec.rb index 24968ce76..72a3b8dc1 100644 --- a/spec/models/request_spec.rb +++ b/spec/models/request_spec.rb @@ -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 diff --git a/spec/models/status_message_spec.rb b/spec/models/status_message_spec.rb index 8a4ebdd12..005038bf1 100644 --- a/spec/models/status_message_spec.rb +++ b/spec/models/status_message_spec.rb @@ -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 "I hate WALRUSES!" end - - it 'should marshal serialized XML to object' do - xml = "I hate WALRUSES!" + + it 'should marshal serialized XML to object' do + xml = "I hate WALRUSES!" parsed = StatusMessage.from_xml(xml) parsed.message.should == "I hate WALRUSES!" parsed.valid?.should be_true diff --git a/spec/models/user/posting_spec.rb b/spec/models/user/posting_spec.rb index 5c1c6eb70..b1f6f71a8 100644 --- a/spec/models/user/posting_spec.rb +++ b/spec/models/user/posting_spec.rb @@ -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 diff --git a/spec/models/user/receive_spec.rb b/spec/models/user/receive_spec.rb index 89d60dfff..37648a98c 100644 --- a/spec/models/user/receive_spec.rb +++ b/spec/models/user/receive_spec.rb @@ -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 diff --git a/spec/models/user/user_friending_spec.rb b/spec/models/user/user_friending_spec.rb index 62e536966..bef8fa416 100644 --- a/spec/models/user/user_friending_spec.rb +++ b/spec/models/user/user_friending_spec.rb @@ -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 diff --git a/spec/models/user/visible_posts_spec.rb b/spec/models/user/visible_posts_spec.rb index 9f6a140b8..ffb220531 100644 --- a/spec/models/user/visible_posts_spec.rb +++ b/spec/models/user/visible_posts_spec.rb @@ -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) diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index 887f599e5..a02f5271a 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -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 diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 52a03e47e..9d6317d30 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -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 diff --git a/spec/user_encryption_spec.rb b/spec/user_encryption_spec.rb index 76e9d900e..33b86d52c 100644 --- a/spec/user_encryption_spec.rb +++ b/spec/user_encryption_spec.rb @@ -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