Merge branch 'master' of github.com:diaspora/diaspora
This commit is contained in:
commit
34cb15c423
39 changed files with 340 additions and 172 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
|
@ -5,7 +5,7 @@
|
||||||
*~
|
*~
|
||||||
.bundle
|
.bundle
|
||||||
db/*.sqlite3
|
db/*.sqlite3
|
||||||
log/*.log
|
log/*
|
||||||
tmp/**/*
|
tmp/**/*
|
||||||
Gemfile.lock
|
Gemfile.lock
|
||||||
gpg/diaspora-development/*.gpg
|
gpg/diaspora-development/*.gpg
|
||||||
|
|
|
||||||
8
.pairs
Normal file
8
.pairs
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
pairs:
|
||||||
|
dg: Daniel Grippi; daniel
|
||||||
|
rs: Raphael Sofaer; raphael
|
||||||
|
iz: Ilya Zhitomirskiy; ilya
|
||||||
|
ms: Maxwell Salzberg; maxwell
|
||||||
|
email:
|
||||||
|
prefix: pair
|
||||||
|
domain: joindiaspora.com
|
||||||
|
|
@ -42,14 +42,30 @@ class GroupsController < ApplicationController
|
||||||
def update
|
def update
|
||||||
@group = Group.first(:id => params[:id])
|
@group = Group.first(:id => params[:id])
|
||||||
if @group.update_attributes(params[:group])
|
if @group.update_attributes(params[:group])
|
||||||
flash[:notice] = "Successfully updated group."
|
#flash[:notice] = "Successfully updated group."
|
||||||
redirect_to @group
|
redirect_to @group
|
||||||
else
|
else
|
||||||
render :action => 'edit'
|
render :action => 'edit'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def move_person
|
def move_friends
|
||||||
|
pp params
|
||||||
|
|
||||||
|
params[:moves].each{ |move|
|
||||||
|
move = move[1]
|
||||||
|
unless current_user.move_friend(move)
|
||||||
|
flash[:error] = "Group editing failed for friend #{Person.find_by_id( move[:friend_id] ).real_name}."
|
||||||
|
redirect_to Group.first, :action => "edit"
|
||||||
|
return
|
||||||
|
end
|
||||||
|
}
|
||||||
|
|
||||||
|
flash[:notice] = "Groups edited successfully."
|
||||||
|
redirect_to Group.first, :action => "edit"
|
||||||
|
|
||||||
|
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}"
|
flash[:error] = "didn't work #{params.inspect}"
|
||||||
end
|
end
|
||||||
|
|
@ -59,5 +75,4 @@ class GroupsController < ApplicationController
|
||||||
redirect_to Person.first(:id => params[:friend_id])
|
redirect_to Person.first(:id => params[:friend_id])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -14,11 +14,9 @@ class PeopleController < ApplicationController
|
||||||
def show
|
def show
|
||||||
@person = current_user.visible_person_by_id(params[:id])
|
@person = current_user.visible_person_by_id(params[:id])
|
||||||
@profile = @person.profile
|
@profile = @person.profile
|
||||||
@person_groups = current_user.groups_with_person(@person)
|
|
||||||
|
|
||||||
|
|
||||||
@groups_array = current_user.groups.collect{|x| [x.to_s, x.id]}
|
|
||||||
|
|
||||||
|
@groups_with_person = current_user.groups_with_person(@person)
|
||||||
|
@groups_dropdown_array = current_user.groups.collect{|x| [x.to_s, x.id]}
|
||||||
|
|
||||||
@posts = Post.where(:person_id => @person.id, :_id.in => current_user.visible_post_ids).paginate :page => params[:page], :order => 'created_at DESC'
|
@posts = Post.where(:person_id => @person.id, :_id.in => current_user.visible_post_ids).paginate :page => params[:page], :order => 'created_at DESC'
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,6 @@ class PublicsController < ApplicationController
|
||||||
Rails.logger.error("Received post #{params[:xml]} for nonexistent person #{params[:id]}")
|
Rails.logger.error("Received post #{params[:xml]} for nonexistent person #{params[:id]}")
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
Rails.logger.debug "PublicsController has received: #{params[:xml]}"
|
|
||||||
@user.receive params[:xml] if params[:xml]
|
@user.receive params[:xml] if params[:xml]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -57,6 +57,9 @@ class Comment
|
||||||
verify_signature(post_creator_signature, post.person)
|
verify_signature(post_creator_signature, post.person)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def signature_valid?
|
||||||
|
verify_signature(creator_signature, person)
|
||||||
|
end
|
||||||
|
|
||||||
protected
|
protected
|
||||||
def sign_if_my_post
|
def sign_if_my_post
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ class Group
|
||||||
end
|
end
|
||||||
|
|
||||||
def posts_by_person_id( id )
|
def posts_by_person_id( id )
|
||||||
id = ensure_bson id
|
id = id.to_id
|
||||||
posts.detect{|x| x.person.id == id }
|
posts.detect{|x| x.person.id == id }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@ class Person
|
||||||
xml_accessor :email
|
xml_accessor :email
|
||||||
xml_accessor :url
|
xml_accessor :url
|
||||||
xml_accessor :profile, :as => Profile
|
xml_accessor :profile, :as => Profile
|
||||||
|
xml_reader :exported_key
|
||||||
|
|
||||||
|
|
||||||
key :email, String, :unique => true
|
key :email, String, :unique => true
|
||||||
|
|
@ -52,13 +53,17 @@ class Person
|
||||||
end
|
end
|
||||||
|
|
||||||
def public_key_hash
|
def public_key_hash
|
||||||
Base64.encode64 OpenSSL::Digest::SHA256.new(self.export_key).to_s
|
Base64.encode64 OpenSSL::Digest::SHA256.new(self.exported_key).to_s
|
||||||
end
|
end
|
||||||
|
|
||||||
def export_key
|
def exported_key
|
||||||
encryption_key.public_key.export
|
encryption_key.public_key.export
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def exported_key= new_key
|
||||||
|
raise "Don't change a key" if serialized_key
|
||||||
|
@serialized_key = new_key
|
||||||
|
end
|
||||||
|
|
||||||
def owns?(post)
|
def owns?(post)
|
||||||
self.id == post.person.id
|
self.id == post.person.id
|
||||||
|
|
@ -77,6 +82,7 @@ class Person
|
||||||
end
|
end
|
||||||
|
|
||||||
protected
|
protected
|
||||||
|
|
||||||
def clean_url
|
def clean_url
|
||||||
self.url ||= "http://localhost:3000/" if self.class == User
|
self.url ||= "http://localhost:3000/" if self.class == User
|
||||||
if self.url
|
if self.url
|
||||||
|
|
@ -84,7 +90,9 @@ class Person
|
||||||
self.url = self.url + '/' if self.url[-1,1] != '/'
|
self.url = self.url + '/' if self.url[-1,1] != '/'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def remove_all_traces
|
def remove_all_traces
|
||||||
Post.all(:person_id => id).each{|p| p.delete}
|
Post.all(:person_id => id).each{|p| p.delete}
|
||||||
Album.all(:person_id => id).each{|p| p.delete}
|
Album.all(:person_id => id).each{|p| p.delete}
|
||||||
|
|
|
||||||
|
|
@ -63,6 +63,6 @@ class Photo < Post
|
||||||
end
|
end
|
||||||
|
|
||||||
def thumb_hash
|
def thumb_hash
|
||||||
{:thumb_url => image.url(:thumb_medium), :id => id, :album_id => album_id}
|
{:thumb_url => url(:thumb_medium), :id => id, :album_id => album_id}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ class Profile
|
||||||
end
|
end
|
||||||
|
|
||||||
def person
|
def person
|
||||||
Person.first(:id => self.person_id)
|
self._parent_document
|
||||||
end
|
end
|
||||||
|
|
||||||
##this needs to go once we move to Salmon
|
##this needs to go once we move to Salmon
|
||||||
|
|
|
||||||
|
|
@ -30,13 +30,13 @@ class Request
|
||||||
self.new(:destination_url => options[:to],
|
self.new(:destination_url => options[:to],
|
||||||
:callback_url => person.receive_url,
|
:callback_url => person.receive_url,
|
||||||
:person => person,
|
:person => person,
|
||||||
:exported_key => person.export_key,
|
:exported_key => person.exported_key,
|
||||||
:group_id => options[:into])
|
:group_id => options[:into])
|
||||||
end
|
end
|
||||||
|
|
||||||
def reverse_for accepting_user
|
def reverse_for accepting_user
|
||||||
self.person = accepting_user.person
|
self.person = accepting_user.person
|
||||||
self.exported_key = accepting_user.export_key
|
self.exported_key = accepting_user.exported_key
|
||||||
self.destination_url = self.callback_url
|
self.destination_url = self.callback_url
|
||||||
self.save
|
self.save
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -9,10 +9,12 @@ class User
|
||||||
key :friend_ids, Array
|
key :friend_ids, Array
|
||||||
key :pending_request_ids, Array
|
key :pending_request_ids, Array
|
||||||
key :visible_post_ids, Array
|
key :visible_post_ids, Array
|
||||||
|
key :visible_person_ids, Array
|
||||||
|
|
||||||
one :person, :class_name => 'Person', :foreign_key => :owner_id
|
one :person, :class_name => 'Person', :foreign_key => :owner_id
|
||||||
|
|
||||||
many :friends, :in => :friend_ids, :class_name => 'Person'
|
many :friends, :in => :friend_ids, :class_name => 'Person'
|
||||||
|
many :visible_people, :in => :visible_person_ids, :class_name => 'Person' # One of these needs to go
|
||||||
many :pending_requests, :in => :pending_request_ids, :class_name => 'Request'
|
many :pending_requests, :in => :pending_request_ids, :class_name => 'Request'
|
||||||
many :raw_visible_posts, :in => :visible_post_ids, :class_name => 'Post'
|
many :raw_visible_posts, :in => :visible_post_ids, :class_name => 'Post'
|
||||||
|
|
||||||
|
|
@ -48,10 +50,9 @@ class User
|
||||||
to_group = self.group_by_id(opts[:to])
|
to_group = self.group_by_id(opts[:to])
|
||||||
if from_group && to_group
|
if from_group && to_group
|
||||||
posts_to_move = from_group.posts.find_all_by_person_id(friend.id)
|
posts_to_move = from_group.posts.find_all_by_person_id(friend.id)
|
||||||
puts posts_to_move.inspect
|
|
||||||
to_group.people << friend
|
to_group.people << friend
|
||||||
to_group.posts << posts_to_move
|
to_group.posts << posts_to_move
|
||||||
from_group.person_ids.delete(ensure_bson(friend.id))
|
from_group.person_ids.delete(friend.id.to_id)
|
||||||
posts_to_move.each{ |x| from_group.post_ids.delete(x.id)}
|
posts_to_move.each{ |x| from_group.post_ids.delete(x.id)}
|
||||||
from_group.save
|
from_group.save
|
||||||
to_group.save
|
to_group.save
|
||||||
|
|
@ -166,7 +167,9 @@ class User
|
||||||
def receive xml
|
def receive xml
|
||||||
object = Diaspora::Parser.from_xml(xml)
|
object = Diaspora::Parser.from_xml(xml)
|
||||||
Rails.logger.debug("Receiving object:\n#{object.inspect}")
|
Rails.logger.debug("Receiving object:\n#{object.inspect}")
|
||||||
raise "Signature was not valid on: #{object.inspect}" unless object.signature_valid?
|
Rails.logger.debug("From: #{object.person.inspect}") if object.person
|
||||||
|
raise "In receive for #{self.real_name}, signature was not valid on: #{object.inspect}" unless object.signature_valid?
|
||||||
|
|
||||||
if object.is_a? Retraction
|
if object.is_a? Retraction
|
||||||
if object.type == 'Person' && object.signature_valid?
|
if object.type == 'Person' && object.signature_valid?
|
||||||
|
|
||||||
|
|
@ -181,7 +184,7 @@ class User
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
elsif object.is_a? Request
|
elsif object.is_a? Request
|
||||||
person = Diaspora::Parser.get_or_create_person_object_from_xml( xml )
|
person = Diaspora::Parser.parse_or_find_person_from_xml( xml )
|
||||||
person.serialized_key ||= object.exported_key
|
person.serialized_key ||= object.exported_key
|
||||||
object.person = person
|
object.person = person
|
||||||
object.person.save
|
object.person.save
|
||||||
|
|
@ -195,6 +198,14 @@ class User
|
||||||
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 << object.person
|
||||||
|
self.save
|
||||||
|
Rails.logger.debug("The person parsed from comment xml is #{object.person.inspect}") unless object.person.nil?
|
||||||
|
object.person.save
|
||||||
|
Rails.logger.debug("From: #{object.person.inspect}") if object.person
|
||||||
|
raise "In receive for #{self.real_name}, signature was not valid on: #{object.inspect}" unless object.post.person == self.person || object.verify_post_creator_signature
|
||||||
|
object.save
|
||||||
dispatch_comment object unless owns?(object)
|
dispatch_comment object unless owns?(object)
|
||||||
object.socket_to_uid(id) if (object.respond_to?(:socket_to_uid) && !self.owns?(object))
|
object.socket_to_uid(id) if (object.respond_to?(:socket_to_uid) && !self.owns?(object))
|
||||||
else
|
else
|
||||||
|
|
@ -237,7 +248,9 @@ class User
|
||||||
def visible_person_by_id( id )
|
def visible_person_by_id( id )
|
||||||
id = id.to_id
|
id = id.to_id
|
||||||
return self.person if id == self.person.id
|
return self.person if id == self.person.id
|
||||||
friends.detect{|x| x.id == id }
|
result = friends.detect{|x| x.id == id }
|
||||||
|
result = visible_people.detect{|x| x.id == id } unless result
|
||||||
|
result
|
||||||
end
|
end
|
||||||
|
|
||||||
def group_by_id( id )
|
def group_by_id( id )
|
||||||
|
|
@ -260,7 +273,7 @@ class User
|
||||||
end
|
end
|
||||||
|
|
||||||
def setup_person
|
def setup_person
|
||||||
self.person.serialized_key ||= generate_key.export
|
self.person.serialized_key ||= User.generate_key.export
|
||||||
self.person.email ||= email
|
self.person.email ||= email
|
||||||
self.person.save!
|
self.person.save!
|
||||||
end
|
end
|
||||||
|
|
@ -269,9 +282,6 @@ class User
|
||||||
self.groups.all.collect{|x| x.id}
|
self.groups.all.collect{|x| x.id}
|
||||||
end
|
end
|
||||||
protected
|
protected
|
||||||
def generate_key
|
|
||||||
OpenSSL::PKey::RSA::generate 1024
|
|
||||||
end
|
|
||||||
|
|
||||||
def self.generate_key
|
def self.generate_key
|
||||||
OpenSSL::PKey::RSA::generate 1024
|
OpenSSL::PKey::RSA::generate 1024
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ class ImageUploader < CarrierWave::Uploader::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
version :thumb_small do
|
version :thumb_small do
|
||||||
process :resize_to_fill => [30,30]
|
process :resize_to_fill => [50,50]
|
||||||
end
|
end
|
||||||
|
|
||||||
version :thumb_medium do
|
version :thumb_medium do
|
||||||
|
|
@ -24,7 +24,7 @@ class ImageUploader < CarrierWave::Uploader::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
version :thumb_large do
|
version :thumb_large do
|
||||||
process :resize_to_fill => [300,300]
|
process :resize_to_fill => [200,200]
|
||||||
end
|
end
|
||||||
|
|
||||||
version :scaled_full do
|
version :scaled_full do
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,9 @@
|
||||||
|
- content_for :head do
|
||||||
|
:javascript
|
||||||
|
$(document).ready(function(){
|
||||||
|
$("#add_album_button").fancybox();
|
||||||
|
});
|
||||||
|
|
||||||
.back= link_to "⇧ home", root_path
|
.back= link_to "⇧ home", root_path
|
||||||
%h1.big_text
|
%h1.big_text
|
||||||
Albums
|
Albums
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,5 @@
|
||||||
- content_for :head do
|
- content_for :head do
|
||||||
:javascript
|
= javascript_include_tag 'photos', 'jquery.html5_upload'
|
||||||
$(document).ready(function(){
|
|
||||||
reset_photo_fancybox();
|
|
||||||
});
|
|
||||||
|
|
||||||
.album_id{:id => @album.id, :style => "display:hidden;"}
|
.album_id{:id => @album.id, :style => "display:hidden;"}
|
||||||
.back= link_to '⇧ albums', albums_path
|
.back= link_to '⇧ albums', albums_path
|
||||||
|
|
|
||||||
|
|
@ -2,22 +2,25 @@
|
||||||
= javascript_include_tag 'jquery-ui-1.8.4.custom.min.js'
|
= javascript_include_tag 'jquery-ui-1.8.4.custom.min.js'
|
||||||
= javascript_include_tag 'group-edit.js'
|
= javascript_include_tag 'group-edit.js'
|
||||||
|
|
||||||
|
|
||||||
%h1.big_text
|
|
||||||
.back
|
.back
|
||||||
= link_to "⇧ #{@group.name}", @group
|
= link_to "⇧ #{@group.name}", @group
|
||||||
|
|
||||||
|
%h1{:class => 'big_text', :id => 'group_title'}
|
||||||
= "Editing Groups"
|
= "Editing Groups"
|
||||||
|
|
||||||
%ul
|
%ul#group_list
|
||||||
- for group in @groups
|
- for group in @groups
|
||||||
%li.group
|
%li{:class => 'group'}
|
||||||
= group.name
|
= group.name
|
||||||
%ul
|
%ul{:id => group.id}
|
||||||
stuff
|
dummy person for dropping onto
|
||||||
-for person in group.people
|
-for person in group.people
|
||||||
%li.person
|
%li{:class => 'person', :id => person.id, :from_group_id => group.id}
|
||||||
|
= image_tag(person.profile.image_url(:thumb_small),:size => "30x30") unless person.profile.image_url.nil?
|
||||||
= person.real_name
|
= person.real_name
|
||||||
|
%p
|
||||||
|
%br
|
||||||
|
= link_to 'Update Groups', '#', :class => 'button', :id => "move_friends_link"
|
||||||
|
|
||||||
#content_bottom
|
#content_bottom
|
||||||
.back
|
.back
|
||||||
|
|
|
||||||
|
|
@ -23,8 +23,6 @@
|
||||||
= csrf_meta_tag
|
= csrf_meta_tag
|
||||||
= yield(:head)
|
= yield(:head)
|
||||||
|
|
||||||
= javascript_include_tag 'jquery.html5_upload'
|
|
||||||
|
|
||||||
%body
|
%body
|
||||||
- flash.each do |name, msg|
|
- flash.each do |name, msg|
|
||||||
= content_tag :div, msg, :id => "flash_#{name}"
|
= content_tag :div, msg, :id => "flash_#{name}"
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@
|
||||||
|
|
||||||
%h1
|
%h1
|
||||||
= @person.real_name
|
= @person.real_name
|
||||||
- unless @person.id == current_user.person.id
|
- if @person != current_user.person && current_user.friends.include?(@person)
|
||||||
.right
|
.right
|
||||||
= link_to 'remove friend', @person, :confirm => 'Are you sure?', :method => :delete, :class => "button"
|
= link_to 'remove friend', @person, :confirm => 'Are you sure?', :method => :delete, :class => "button"
|
||||||
|
|
||||||
|
|
@ -13,15 +13,13 @@
|
||||||
-unless @posts.first.nil?
|
-unless @posts.first.nil?
|
||||||
%li
|
%li
|
||||||
%i= "last seen: #{how_long_ago(@posts.first)}"
|
%i= "last seen: #{how_long_ago(@posts.first)}"
|
||||||
|
- if @person != current_user.person && current_user.friends.include?(@person)
|
||||||
%li
|
%li
|
||||||
%i= "friends since: #{how_long_ago(@person)}"
|
%i= "friends since: #{how_long_ago(@person)}"
|
||||||
%li
|
%li
|
||||||
="groups: #{@person_groups}"
|
= form_tag move_friend_path
|
||||||
= "edit"
|
= select :to, :to, @groups_dropdown_array, :selected_value => @groups_with_person.first.id
|
||||||
= @groups_array.inspect
|
= hidden_field_tag :from, :from, :value => @groups_with_person.first.id
|
||||||
= form_tag move_person_path
|
|
||||||
= select :to, :to, @groups_array
|
|
||||||
= hidden_field_tag :from, :from, :value => @person_groups.first.id
|
|
||||||
= hidden_field_tag :friend_id, :friend_id, :value => @person.id
|
= hidden_field_tag :friend_id, :friend_id, :value => @person.id
|
||||||
= submit_tag "save"
|
= submit_tag "save"
|
||||||
%li
|
%li
|
||||||
|
|
|
||||||
|
|
@ -1,33 +1,3 @@
|
||||||
:javascript
|
|
||||||
$(function() {
|
|
||||||
$("#photo_image").html5_upload({
|
|
||||||
// WE INSERT ALBUM_ID PARAM HERE
|
|
||||||
url: "/photos?album_id=#{@album.id}",
|
|
||||||
sendBoundary: window.FormData || $.browser.mozilla,
|
|
||||||
setName: function(text) {
|
|
||||||
$("#progress_report_name").text(text);
|
|
||||||
},
|
|
||||||
onFinish: function(event, total){
|
|
||||||
$("#add_photo_button").html( "Add Photos" );
|
|
||||||
$("#add_photo_loader").fadeOut(400);
|
|
||||||
|
|
||||||
$("#photo_title_status").text("Done!");
|
|
||||||
$("#progress_report").html("Good job me!");
|
|
||||||
|
|
||||||
$("#add_photo_button").addClass("uploading_complete");
|
|
||||||
},
|
|
||||||
onStart: function(event, total){
|
|
||||||
$("#add_photo_button").html( "Uploading Photos" );
|
|
||||||
$("#add_photo_loader").fadeIn(400);
|
|
||||||
|
|
||||||
$("form").fadeOut(0);
|
|
||||||
$("#progress_report").fadeIn(0);
|
|
||||||
$("#photo_title_status").text("Uploading...");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
%h1
|
%h1
|
||||||
%span{:id=>"photo_title_status"}
|
%span{:id=>"photo_title_status"}
|
||||||
Add photos to
|
Add photos to
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,8 @@
|
||||||
%li.message{:id => post.id}
|
%li.message{:id => post.id}
|
||||||
|
|
||||||
= person_image_tag(post.person)
|
= person_image_tag(post.person)
|
||||||
|
|
||||||
|
.content
|
||||||
%span.from
|
%span.from
|
||||||
= link_to post.person.real_name, post.person
|
= link_to post.person.real_name, post.person
|
||||||
%b
|
%b
|
||||||
|
|
@ -8,12 +10,10 @@
|
||||||
= link_to post.album.name, object_path(post.album)
|
= link_to post.album.name, object_path(post.album)
|
||||||
|
|
||||||
%br
|
%br
|
||||||
|
|
||||||
= render "albums/album", :post => post.album, :current_user => current_user
|
= render "albums/album", :post => post.album, :current_user => current_user
|
||||||
|
|
||||||
= link_to (image_tag post.url(:thumb_medium)), object_path(post)
|
= link_to (image_tag post.url(:thumb_medium)), object_path(post)
|
||||||
|
|
||||||
%div.time
|
.info
|
||||||
= link_to(how_long_ago(post), photo_path(post))
|
= link_to(how_long_ago(post), photo_path(post))
|
||||||
\--
|
\--
|
||||||
= link_to "show comments (#{post.comments.count})", '#', :class => "show_post_comments"
|
= link_to "show comments (#{post.comments.count})", '#', :class => "show_post_comments"
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@
|
||||||
= link_to "All Groups", root_url
|
= link_to "All Groups", root_url
|
||||||
- for group in @groups
|
- for group in @groups
|
||||||
%li{:id => group.id, :class => ("selected" if current_group?(group))}
|
%li{:id => group.id, :class => ("selected" if current_group?(group))}
|
||||||
|
%span.group_name
|
||||||
= link_for_group group
|
= link_for_group group
|
||||||
%span{:class => '⚙'}
|
%span{:class => '⚙'}
|
||||||
= link_to "⚙", "#", :class => "edit_group_button"
|
= link_to "⚙", "#", :class => "edit_group_button"
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@
|
||||||
= link_to post.person.real_name, post.person
|
= link_to post.person.real_name, post.person
|
||||||
= auto_link sanitize post.message
|
= auto_link sanitize post.message
|
||||||
|
|
||||||
%div.info
|
.info
|
||||||
= link_to(how_long_ago(post), object_path(post))
|
= link_to(how_long_ago(post), object_path(post))
|
||||||
\--
|
\--
|
||||||
= link_to "show comments (#{post.comments.count})", '#', :class => "show_post_comments"
|
= link_to "show comments (#{post.comments.count})", '#', :class => "show_post_comments"
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,8 @@ Diaspora::Application.routes.draw do
|
||||||
match 'login', :to => 'devise/sessions#new', :as => "new_user_session"
|
match 'login', :to => 'devise/sessions#new', :as => "new_user_session"
|
||||||
match 'logout', :to => 'devise/sessions#destroy', :as => "destroy_user_session"
|
match 'logout', :to => 'devise/sessions#destroy', :as => "destroy_user_session"
|
||||||
match 'get_to_the_choppa', :to => 'devise/registrations#new', :as => "new_user_registration"
|
match 'get_to_the_choppa', :to => 'devise/registrations#new', :as => "new_user_registration"
|
||||||
match 'groups/move_person', :to => 'groups#move_person', :as => 'move_person'
|
match 'groups/move_friends', :to => 'groups#move_friends', :as => 'move_friends'
|
||||||
|
match 'groups/move_friend', :to => 'groups#move_friend', :as => 'move_friend'
|
||||||
#public routes
|
#public routes
|
||||||
#
|
#
|
||||||
match 'webfinger', :to => 'publics#webfinger'
|
match 'webfinger', :to => 'publics#webfinger'
|
||||||
|
|
|
||||||
|
|
@ -6,10 +6,10 @@ module Diaspora
|
||||||
Person.first(:id => id)
|
Person.first(:id => id)
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.get_or_create_person_object_from_xml(xml)
|
def self.parse_or_find_person_from_xml(xml)
|
||||||
doc = Nokogiri::XML(xml) { |cfg| cfg.noblanks }
|
doc = Nokogiri::XML(xml) { |cfg| cfg.noblanks }
|
||||||
person_xml = doc.xpath("//request/person").to_s
|
person_xml = doc.xpath("//person").to_s
|
||||||
person_id = doc.xpath("//request/person/_id").text.to_s
|
person_id = doc.xpath("//person/_id").text.to_s
|
||||||
person = Person.first(:_id => person_id)
|
person = Person.first(:_id => person_id)
|
||||||
person ? person : Person.from_xml( person_xml)
|
person ? person : Person.from_xml( person_xml)
|
||||||
end
|
end
|
||||||
|
|
@ -36,6 +36,5 @@ module Diaspora
|
||||||
raise e
|
raise e
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,10 @@
|
||||||
|
$('#move_friends_link').live( 'click',
|
||||||
|
function(){
|
||||||
|
$.post('/groups/move_friends',
|
||||||
|
{'moves' : $('#group_list').data()},
|
||||||
|
function(){ $('#group_title').html("Groups edited successfully!");});
|
||||||
|
});
|
||||||
|
|
||||||
$(function() {
|
$(function() {
|
||||||
$("li .person").draggable({
|
$("li .person").draggable({
|
||||||
revert: true
|
revert: true
|
||||||
|
|
@ -7,8 +14,14 @@ $(function() {
|
||||||
drop: function(event, ui) {
|
drop: function(event, ui) {
|
||||||
$(this).closest("ul").append(ui.draggable)
|
$(this).closest("ul").append(ui.draggable)
|
||||||
//$("<li class='person ui-draggable'></li>").text(ui.draggable.text()).appendTo(this).draggable();
|
//$("<li class='person ui-draggable'></li>").text(ui.draggable.text()).appendTo(this).draggable();
|
||||||
|
var move = {};
|
||||||
|
move[ 'friend_id' ] = ui.draggable[0].id
|
||||||
|
move[ 'to' ] = $(this)[0].id;
|
||||||
|
move[ 'from' ] = ui.draggable[0].getAttribute('from_group_id');
|
||||||
|
$('#group_list').data( ui.draggable[0].id, move);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
|
||||||
51
public/javascripts/photos.js
Normal file
51
public/javascripts/photos.js
Normal file
|
|
@ -0,0 +1,51 @@
|
||||||
|
$(document).ready(function(){
|
||||||
|
reset_photo_fancybox();
|
||||||
|
|
||||||
|
$("#add_photo_button").fancybox({
|
||||||
|
'onClosed' : function(){
|
||||||
|
if($("#add_photo_button").hasClass("uploading_complete")){
|
||||||
|
$("#add_photo_button").removeClass("uploading_complete");
|
||||||
|
reset_photo_fancybox();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
$(".image_thumb img").load( function() {
|
||||||
|
$(this).fadeIn("slow");
|
||||||
|
});
|
||||||
|
|
||||||
|
});//end document ready
|
||||||
|
|
||||||
|
function reset_photo_fancybox(){
|
||||||
|
album_id = $(".album_id")[0].id;
|
||||||
|
ajax = $.get("/photos/new?album_id=" + album_id, function(){
|
||||||
|
$("#new_photo_pane").html(ajax.responseText)
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
$("#photo_image").html5_upload({
|
||||||
|
// WE INSERT ALBUM_ID PARAM HERE
|
||||||
|
url: "/photos?album_id="+$(".album_id")[0].id,
|
||||||
|
sendBoundary: window.FormData || $.browser.mozilla,
|
||||||
|
setName: function(text) {
|
||||||
|
$("#progress_report_name").text(text);
|
||||||
|
},
|
||||||
|
onFinish: function(event, total){
|
||||||
|
$("#add_photo_button").html( "Add Photos" );
|
||||||
|
$("#add_photo_loader").fadeOut(400);
|
||||||
|
|
||||||
|
$("#photo_title_status").text("Done!");
|
||||||
|
$("#progress_report").html("Good job me!");
|
||||||
|
|
||||||
|
$("#add_photo_button").addClass("uploading_complete");
|
||||||
|
},
|
||||||
|
onStart: function(event, total){
|
||||||
|
$("#add_photo_button").html( "Uploading Photos" );
|
||||||
|
$("#add_photo_loader").fadeIn(400);
|
||||||
|
|
||||||
|
$("form.new_photo").fadeOut(0);
|
||||||
|
$("#progress_report").fadeIn(0);
|
||||||
|
$("#photo_title_status").text("Uploading...");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
@ -8,8 +8,6 @@ $(document).ready(function(){
|
||||||
|
|
||||||
$('#flash_notice, #flash_error, #flash_alert').delay(2500).slideUp(130);
|
$('#flash_notice, #flash_error, #flash_alert').delay(2500).slideUp(130);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$("div.image_cycle").cycle({
|
$("div.image_cycle").cycle({
|
||||||
fx: 'fade',
|
fx: 'fade',
|
||||||
random: 1,
|
random: 1,
|
||||||
|
|
@ -18,42 +16,64 @@ $(document).ready(function(){
|
||||||
});
|
});
|
||||||
|
|
||||||
//buttons//////
|
//buttons//////
|
||||||
|
|
||||||
|
|
||||||
$("#add_album_button").fancybox();
|
|
||||||
$("#add_group_button").fancybox();
|
$("#add_group_button").fancybox();
|
||||||
$("#add_request_button").fancybox({ 'titleShow': false });
|
$("#add_request_button").fancybox({ 'titleShow': false });
|
||||||
$("#add_photo_button").fancybox({
|
|
||||||
'onClosed' : function(){
|
|
||||||
if($("#add_photo_button").hasClass("uploading_complete")){
|
|
||||||
$("#add_photo_button").removeClass("uploading_complete");
|
|
||||||
reset_photo_fancybox();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
//pane_toggler_button("photo");
|
|
||||||
|
|
||||||
$("input[type='submit']").addClass("button");
|
$("input[type='submit']").addClass("button");
|
||||||
|
|
||||||
$(".image_thumb img").load( function() {
|
|
||||||
$(this).fadeIn("slow");
|
|
||||||
});
|
|
||||||
|
|
||||||
$(".image_cycle img").load( function() {
|
$(".image_cycle img").load( function() {
|
||||||
$(this).fadeIn("slow");
|
$(this).fadeIn("slow");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
$(".edit_group_button").click(function() {
|
||||||
|
|
||||||
|
var element = $(this).closest("li").children(".group_name").children("a");
|
||||||
|
var oldHTML = element.html();
|
||||||
|
|
||||||
|
var link = element.attr("href");
|
||||||
|
|
||||||
|
element.toggleClass("editing");
|
||||||
|
|
||||||
|
if( element.hasClass("editing") ) {
|
||||||
|
|
||||||
|
element.attr("contentEditable", true);
|
||||||
|
element.focus();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//remove newline action
|
||||||
|
$(element).keypress(function(e) {
|
||||||
|
if (e.which == 13) {
|
||||||
|
e.preventDefault();
|
||||||
|
element.attr("contentEditable", false);
|
||||||
|
element.toggleClass("editing");
|
||||||
|
element.blur();
|
||||||
|
|
||||||
|
//save changes
|
||||||
|
$.ajax({
|
||||||
|
type: "PUT",
|
||||||
|
url: link,
|
||||||
|
data: {"group" : {"name" : element.text() }}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
//update all other group links
|
||||||
|
$(element).keyup(function(e) {
|
||||||
|
$("a[href='"+link+"']").not(element).text(element.text());
|
||||||
|
});
|
||||||
|
|
||||||
|
} else {
|
||||||
|
element.attr("contentEditable", false);
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
});//end document ready
|
});//end document ready
|
||||||
|
|
||||||
function reset_photo_fancybox(){
|
|
||||||
album_id = $(".album_id")[0].id;
|
|
||||||
ajax = $.get("/photos/new?album_id=" + album_id, function(){
|
|
||||||
$("#new_photo_pane").html(ajax.responseText)
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function pane_toggler_button( name ) {
|
function pane_toggler_button( name ) {
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -11,12 +11,10 @@ body {
|
||||||
margin: 0; }
|
margin: 0; }
|
||||||
|
|
||||||
a {
|
a {
|
||||||
color: #018790;
|
|
||||||
color: #556270;
|
color: #556270;
|
||||||
text-decoration: none; }
|
text-decoration: none; }
|
||||||
a:hover {
|
a:hover {
|
||||||
color: white;
|
color: white;
|
||||||
background-color: #018790;
|
|
||||||
background-color: #556270; }
|
background-color: #556270; }
|
||||||
|
|
||||||
.avatar {
|
.avatar {
|
||||||
|
|
@ -381,9 +379,12 @@ label {
|
||||||
/* cycle it! */
|
/* cycle it! */
|
||||||
.album {
|
.album {
|
||||||
position: relative;
|
position: relative;
|
||||||
height: 300px;
|
height: 200px;
|
||||||
width: 300px;
|
width: 200px;
|
||||||
display: inline-block; }
|
display: inline-block; }
|
||||||
|
.album img {
|
||||||
|
width: 200px;
|
||||||
|
height: 200px; }
|
||||||
.album .name {
|
.album .name {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
z-index: 6;
|
z-index: 6;
|
||||||
|
|
@ -473,6 +474,8 @@ h1.big_text {
|
||||||
color: #999999; }
|
color: #999999; }
|
||||||
#group_nav ul > li a:hover {
|
#group_nav ul > li a:hover {
|
||||||
background: none; }
|
background: none; }
|
||||||
|
#group_nav ul > li a.editable:hover {
|
||||||
|
background: yellow; }
|
||||||
#group_nav ul .⚙ {
|
#group_nav ul .⚙ {
|
||||||
margin-left: 4px; }
|
margin-left: 4px; }
|
||||||
#group_nav ul .⚙ a {
|
#group_nav ul .⚙ a {
|
||||||
|
|
@ -569,3 +572,7 @@ h1.big_text {
|
||||||
#global_search form label {
|
#global_search form label {
|
||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
margin-top: -3px; }
|
margin-top: -3px; }
|
||||||
|
|
||||||
|
.editing, .editing:hover {
|
||||||
|
background-color: yellow;
|
||||||
|
border: 1px #666666 solid; }
|
||||||
|
|
|
||||||
|
|
@ -10,14 +10,12 @@ body
|
||||||
:padding 2em
|
:padding 2em
|
||||||
:margin 0
|
:margin 0
|
||||||
a
|
a
|
||||||
:color #018790
|
|
||||||
:color #556270
|
:color #556270
|
||||||
:text
|
:text
|
||||||
:decoration none
|
:decoration none
|
||||||
&:hover
|
&:hover
|
||||||
:color #fff
|
:color #fff
|
||||||
:background
|
:background
|
||||||
:color #018790
|
|
||||||
:color #556270
|
:color #556270
|
||||||
|
|
||||||
.avatar
|
.avatar
|
||||||
|
|
@ -480,10 +478,14 @@ label
|
||||||
/* cycle it! */
|
/* cycle it! */
|
||||||
.album
|
.album
|
||||||
:position relative
|
:position relative
|
||||||
:height 300px
|
:height 200px
|
||||||
:width 300px
|
:width 200px
|
||||||
:display inline-block
|
:display inline-block
|
||||||
|
|
||||||
|
img
|
||||||
|
:width 200px
|
||||||
|
:height 200px
|
||||||
|
|
||||||
.name
|
.name
|
||||||
:position absolute
|
:position absolute
|
||||||
:z-index 6
|
:z-index 6
|
||||||
|
|
@ -601,6 +603,8 @@ h1.big_text
|
||||||
:color #999
|
:color #999
|
||||||
&:hover
|
&:hover
|
||||||
:background none
|
:background none
|
||||||
|
&.editable:hover
|
||||||
|
:background yellow
|
||||||
|
|
||||||
.⚙
|
.⚙
|
||||||
:margin
|
:margin
|
||||||
|
|
@ -738,4 +742,7 @@ h1.big_text
|
||||||
:margin
|
:margin
|
||||||
:top -3px
|
:top -3px
|
||||||
|
|
||||||
|
.editing, .editing:hover
|
||||||
|
:background
|
||||||
|
:color yellow
|
||||||
|
:border 1px #666 solid
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ describe GroupsController do
|
||||||
@user = Factory.create(:user)
|
@user = Factory.create(:user)
|
||||||
@user.group(:name => "lame-os")
|
@user.group(:name => "lame-os")
|
||||||
@person = Factory.create(:person)
|
@person = Factory.create(:person)
|
||||||
request.env['warden'] = mock_model(Warden, :authenticate? => @user, :authenticate! => @user, :authenticate => @user)
|
sign_in :user, @user
|
||||||
end
|
end
|
||||||
|
|
||||||
it "on index sets a variable containing all a user's friends when a user is signed in" do
|
it "on index sets a variable containing all a user's friends when a user is signed in" do
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,6 @@ describe PeopleController do
|
||||||
render_views
|
render_views
|
||||||
before do
|
before do
|
||||||
@user = Factory.create(:user)
|
@user = Factory.create(:user)
|
||||||
request.env['warden'] = mock_model(Warden, :authenticate? => @user, :authenticate! => @user, :authenticate => @user)
|
|
||||||
|
|
||||||
sign_in :user, @user
|
sign_in :user, @user
|
||||||
@user.group(:name => "lame-os")
|
@user.group(:name => "lame-os")
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ describe PublicsController do
|
||||||
before do
|
before do
|
||||||
@user = Factory.create(:user)
|
@user = Factory.create(:user)
|
||||||
@user.person.save
|
@user.person.save
|
||||||
request.env['warden'] = mock_model(Warden, :authenticate? => @user, :authenticate! => @user, :authenticate => @user)
|
sign_in :user, @user
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'receive endpoint' do
|
describe 'receive endpoint' do
|
||||||
|
|
|
||||||
|
|
@ -6,15 +6,11 @@ class SocketsController
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'SocketsController' do
|
describe SocketsController do
|
||||||
render_views
|
render_views
|
||||||
before do
|
before do
|
||||||
@user = Factory.create(:user)
|
@user = Factory.create(:user)
|
||||||
SocketsController.unstub!(:new)
|
|
||||||
@controller = SocketsController.new
|
@controller = SocketsController.new
|
||||||
@controller.request = mock_model(Request, :env =>
|
|
||||||
{'warden' => mock_model(Warden, :authenticate? => @user, :authenticate! => @user, :authenticate => @user)})
|
|
||||||
stub_sockets_controller
|
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should unstub the websockets' do
|
it 'should unstub the websockets' do
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@ describe Diaspora::Parser do
|
||||||
@xml = Factory.build(:status_message).to_diaspora_xml
|
@xml = Factory.build(:status_message).to_diaspora_xml
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should be able to correctly handle comments' do
|
it 'should be able to correctly handle comments with person in db' do
|
||||||
person = Factory.create(:person, :email => "test@testing.com")
|
person = Factory.create(:person, :email => "test@testing.com")
|
||||||
post = Factory.create(:status_message, :person => @user.person)
|
post = Factory.create(:status_message, :person => @user.person)
|
||||||
comment = Factory.build(:comment, :post => post, :person => person, :text => "Freedom!")
|
comment = Factory.build(:comment, :post => post, :person => person, :text => "Freedom!")
|
||||||
|
|
@ -30,6 +30,23 @@ describe Diaspora::Parser do
|
||||||
comment.post.should == post
|
comment.post.should == post
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'should be able to correctly handle person on a comment with person not in db' do
|
||||||
|
commenter = Factory.create(:user)
|
||||||
|
commenter_group = commenter.group :name => "bruisers"
|
||||||
|
friend_users(@user, @group, commenter, commenter_group)
|
||||||
|
post = @user.post :status_message, :message => "hello", :to => @group.id
|
||||||
|
comment = commenter.comment "Fool!", :on => post
|
||||||
|
|
||||||
|
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.email.should == commenter.person.email
|
||||||
|
parsed_person.profile.should_not be_nil
|
||||||
|
end
|
||||||
|
|
||||||
it 'should marshal retractions' do
|
it 'should marshal retractions' do
|
||||||
person = Factory.create(:person)
|
person = Factory.create(:person)
|
||||||
message = Factory.create(:status_message, :person => person)
|
message = Factory.create(:status_message, :person => person)
|
||||||
|
|
|
||||||
|
|
@ -22,8 +22,8 @@ describe Salmon do
|
||||||
x.magic_sig.signable_string.should == z.magic_sig.signable_string
|
x.magic_sig.signable_string.should == z.magic_sig.signable_string
|
||||||
|
|
||||||
|
|
||||||
x.verified_for_key?(OpenSSL::PKey::RSA.new(@user.export_key)).should be true
|
x.verified_for_key?(OpenSSL::PKey::RSA.new(@user.exported_key)).should be true
|
||||||
z.verified_for_key?(OpenSSL::PKey::RSA.new(@user.export_key)).should be true
|
z.verified_for_key?(OpenSSL::PKey::RSA.new(@user.exported_key)).should be true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,10 @@ describe Comment do
|
||||||
describe "user" do
|
describe "user" do
|
||||||
before do
|
before do
|
||||||
@user = Factory.create :user
|
@user = Factory.create :user
|
||||||
@user.person.save
|
@group = @user.group(:name => "Doofuses")
|
||||||
|
|
||||||
|
@user2 = Factory.create(:user)
|
||||||
|
@group2 = @user2.group(:name => "Lame-faces")
|
||||||
end
|
end
|
||||||
it "should be able to comment on his own status" do
|
it "should be able to comment on his own status" do
|
||||||
status = Factory.create(:status_message, :person => @user.person)
|
status = Factory.create(:status_message, :person => @user.person)
|
||||||
|
|
@ -31,10 +34,7 @@ describe Comment do
|
||||||
|
|
||||||
describe 'comment propagation' do
|
describe 'comment propagation' do
|
||||||
before do
|
before do
|
||||||
@group = @user.group(:name => "Doofuses")
|
|
||||||
|
|
||||||
@user2 = Factory.create(:user)
|
|
||||||
@group2 = @user2.group(:name => "Lame-faces")
|
|
||||||
|
|
||||||
request = @user.send_friend_request_to(@user2.receive_url, @group.id)
|
request = @user.send_friend_request_to(@user2.receive_url, @group.id)
|
||||||
reversed_request = @user2.accept_friend_request( request.id, @group2.id )
|
reversed_request = @user2.accept_friend_request( request.id, @group2.id )
|
||||||
|
|
@ -79,5 +79,16 @@ describe Comment do
|
||||||
@user.receive(comment.to_diaspora_xml)
|
@user.receive(comment.to_diaspora_xml)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
describe 'serialization' do
|
||||||
|
it 'should serialize the commenter' do
|
||||||
|
commenter = Factory.create(:user)
|
||||||
|
commenter_group = commenter.group :name => "bruisers"
|
||||||
|
friend_users(@user, @group, commenter, commenter_group)
|
||||||
|
post = @user.post :status_message, :message => "hello", :to => @group.id
|
||||||
|
comment = commenter.comment "Fool!", :on => post
|
||||||
|
comment.person.should_not == @user.person
|
||||||
|
comment.to_diaspora_xml.include?(commenter.person.id.to_s).should be true
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,10 @@ describe User do
|
||||||
|
|
||||||
@user2 = Factory.create(:user)
|
@user2 = Factory.create(:user)
|
||||||
@group2 = @user2.group(:name => 'losers')
|
@group2 = @user2.group(:name => 'losers')
|
||||||
|
|
||||||
|
@user3 = Factory.create(:user)
|
||||||
|
@group3 = @user3.group(:name => 'heroes')
|
||||||
|
|
||||||
friend_users(@user, @group, @user2, @group2)
|
friend_users(@user, @group, @user2, @group2)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -39,8 +43,7 @@ describe User do
|
||||||
|
|
||||||
describe 'post refs' do
|
describe 'post refs' do
|
||||||
before do
|
before do
|
||||||
@user3 = Factory.create(:user)
|
|
||||||
@group3 = @user3.group(:name => 'heroes')
|
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should add the post to that user's posts when a user posts it" do
|
it "should add the post to that user's posts when a user posts it" do
|
||||||
|
|
@ -130,4 +133,36 @@ describe User do
|
||||||
Post.count.should be 1
|
Post.count.should be 1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe 'comments' do
|
||||||
|
it 'should correctly marshal a stranger for the downstream user' do
|
||||||
|
|
||||||
|
friend_users(@user, @group, @user3, @group3)
|
||||||
|
post = @user.post :status_message, :message => "hello", :to => @group.id
|
||||||
|
|
||||||
|
@user2.receive post.to_diaspora_xml
|
||||||
|
@user3.receive post.to_diaspora_xml
|
||||||
|
|
||||||
|
comment = @user2.comment('tada',:on => post)
|
||||||
|
@user.receive comment.to_diaspora_xml
|
||||||
|
@user.reload
|
||||||
|
|
||||||
|
commenter_id = @user2.person.id
|
||||||
|
|
||||||
|
@user2.person.delete
|
||||||
|
@user2.delete
|
||||||
|
comment_id = comment.id
|
||||||
|
|
||||||
|
comment.delete
|
||||||
|
@user3.receive comment.to_diaspora_xml
|
||||||
|
@user3.reload
|
||||||
|
|
||||||
|
new_comment = Comment.find_by_id(comment_id)
|
||||||
|
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
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -21,29 +21,27 @@ RSpec.configure do |config|
|
||||||
config.before(:suite) do
|
config.before(:suite) do
|
||||||
DatabaseCleaner.clean_with(:truncation)
|
DatabaseCleaner.clean_with(:truncation)
|
||||||
stub_signature_verification
|
stub_signature_verification
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
config.before(:each) do
|
config.before(:each) do
|
||||||
DatabaseCleaner.start
|
DatabaseCleaner.start
|
||||||
stub_sockets_controller
|
stub_sockets
|
||||||
end
|
end
|
||||||
|
|
||||||
config.after(:each) do
|
config.after(:each) do
|
||||||
DatabaseCleaner.clean
|
DatabaseCleaner.clean
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
def stub_sockets_controller
|
def stub_sockets
|
||||||
mock_sockets_controller = mock('sockets mock')
|
Diaspora::WebSocket.stub!(:push_to_user).and_return(true)
|
||||||
mock_sockets_controller.stub!(:incoming).and_return(true)
|
Diaspora::WebSocket.stub!(:subscribe).and_return(true)
|
||||||
mock_sockets_controller.stub!(:new_subscriber).and_return(true)
|
Diaspora::WebSocket.stub!(:unsubscribe).and_return(true)
|
||||||
mock_sockets_controller.stub!(:outgoing).and_return(true)
|
|
||||||
mock_sockets_controller.stub!(:delete_subscriber).and_return(true)
|
|
||||||
SocketsController.stub!(:new).and_return(mock_sockets_controller)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def stub_signature_verification
|
def stub_signature_verification
|
||||||
(get_models.map{|model| model.camelize.constantize} - [User]).each do |model|
|
(get_models.map{|model| model.camelize.constantize} - [User]).each do |model|
|
||||||
model.any_instance.stubs(:signature_valid?).returns(true)
|
model.any_instance.stubs(:verify_signature).returns(true)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,7 @@ describe 'user encryption' do
|
||||||
it 'should send over a public key' do
|
it 'should send over a public key' do
|
||||||
message_queue.stub!(:add_post_request)
|
message_queue.stub!(:add_post_request)
|
||||||
request = @user.send_friend_request_to("http://example.com/", @group.id)
|
request = @user.send_friend_request_to("http://example.com/", @group.id)
|
||||||
request.to_diaspora_xml.include?( @user.export_key).should be true
|
request.to_diaspora_xml.include?( @user.exported_key).should be true
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should receive and marshal a public key from a request' do
|
it 'should receive and marshal a public key from a request' do
|
||||||
|
|
@ -41,7 +41,7 @@ describe 'user encryption' do
|
||||||
remote_user.encryption_key.nil?.should== false
|
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
|
id = remote_user.person.id
|
||||||
original_key = remote_user.export_key
|
original_key = remote_user.exported_key
|
||||||
|
|
||||||
request = remote_user.send_friend_request_to(
|
request = remote_user.send_friend_request_to(
|
||||||
@user.receive_url, remote_user.group(:name => "temp").id)
|
@user.receive_url, remote_user.group(:name => "temp").id)
|
||||||
|
|
@ -52,10 +52,10 @@ describe 'user encryption' do
|
||||||
remote_user.destroy
|
remote_user.destroy
|
||||||
|
|
||||||
person_count = Person.all.count
|
person_count = Person.all.count
|
||||||
proc {@user.receive xml}.should_not raise_error /Signature was not valid/
|
proc {@user.receive xml}.should_not raise_error /ignature was not valid/
|
||||||
Person.all.count.should == person_count + 1
|
Person.all.count.should == person_count + 1
|
||||||
new_person = Person.first(:id => id)
|
new_person = Person.first(:id => id)
|
||||||
new_person.export_key.should == original_key
|
new_person.exported_key.should == original_key
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -125,7 +125,7 @@ describe 'user encryption' do
|
||||||
xml = message.to_diaspora_xml
|
xml = message.to_diaspora_xml
|
||||||
message.destroy
|
message.destroy
|
||||||
Post.count.should be 0
|
Post.count.should be 0
|
||||||
proc {@user.receive xml}.should raise_error /Signature was not valid/
|
proc {@user.receive xml}.should raise_error /ignature was not valid/
|
||||||
Post.count.should be 0
|
Post.count.should be 0
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue