MS merging in master again
This commit is contained in:
commit
68bd5bf5f5
20 changed files with 76 additions and 76 deletions
|
|
@ -37,8 +37,6 @@ def warzombie
|
||||||
|
|
||||||
def zombiefriendaccept
|
def zombiefriendaccept
|
||||||
render :nothing => true
|
render :nothing => true
|
||||||
set_profile_photo
|
|
||||||
|
|
||||||
Request.all.each{|r|
|
Request.all.each{|r|
|
||||||
current_user.accept_and_respond(r.id, current_user.groups.first.id)
|
current_user.accept_and_respond(r.id, current_user.groups.first.id)
|
||||||
}
|
}
|
||||||
|
|
@ -58,13 +56,25 @@ def warzombie
|
||||||
end
|
end
|
||||||
|
|
||||||
def set_profile_photo
|
def set_profile_photo
|
||||||
album = current_user.post(:album, :name => "Profile Photos")
|
|
||||||
|
render :nothing => true
|
||||||
|
album = current_user.post( :album, :to => current_user.all_group_ids, :name => "Profile Photos")
|
||||||
|
|
||||||
backer_number = YAML.load_file(Rails.root.join('config','backer_number.yml'))[:seed_number].to_i
|
backer_number = YAML.load_file(Rails.root.join('config','backer_number.yml'))[:seed_number].to_i
|
||||||
username = backer_info[backer_number]['username'].gsub(/ /,'').downcase
|
username = backer_info[backer_number]['username'].gsub(/ /,'').downcase
|
||||||
photo = current_user.post(:photo, :album_id => album.id,
|
|
||||||
:user_file => "public/images/users/#{username}.jpg")
|
@fixture_name = File.dirname(__FILE__) + "/../../public/images/user/#{username}.jpg"
|
||||||
|
|
||||||
current_user.update_profile(:image_url => photo.url)
|
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
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,7 @@ 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)
|
||||||
|
|
||||||
@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'
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ class StatusMessagesController < ApplicationController
|
||||||
before_filter :authenticate_user!
|
before_filter :authenticate_user!
|
||||||
|
|
||||||
def create
|
def create
|
||||||
params[:status_message][:group_ids] = params[:group_ids]
|
params[:status_message][:to] = params[:group_ids]
|
||||||
@status_message = current_user.post(:status_message, params[:status_message])
|
@status_message = current_user.post(:status_message, params[:status_message])
|
||||||
|
|
||||||
if @status_message.created_at
|
if @status_message.created_at
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ 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 :_post_ids, Array
|
||||||
|
|
||||||
one :person, :class_name => 'Person', :foreign_key => :owner_id
|
one :person, :class_name => 'Person', :foreign_key => :owner_id
|
||||||
|
|
||||||
|
|
@ -62,8 +62,14 @@ class User
|
||||||
def post(class_name, options = {})
|
def post(class_name, options = {})
|
||||||
options[:person] = self.person
|
options[:person] = self.person
|
||||||
|
|
||||||
group_ids = options[:group_ids]
|
group_ids = options[:to]
|
||||||
options.delete(:group_ids)
|
|
||||||
|
raise "You must post to someone." if group_ids.nil? || group_ids.empty?
|
||||||
|
|
||||||
|
group_ids = [group_ids] unless group_ids.is_a? Array
|
||||||
|
|
||||||
|
group_ids.map!{|gid| ensure_bson gid }
|
||||||
|
options.delete(:to)
|
||||||
|
|
||||||
model_class = class_name.to_s.camelize.constantize
|
model_class = class_name.to_s.camelize.constantize
|
||||||
|
|
||||||
|
|
@ -72,7 +78,7 @@ class User
|
||||||
post.save
|
post.save
|
||||||
|
|
||||||
|
|
||||||
groups = self.groups.find_all_by_id(group_ids)
|
groups = self.groups.find_all_by_id( group_ids )
|
||||||
target_people = []
|
target_people = []
|
||||||
|
|
||||||
groups.each{ |group|
|
groups.each{ |group|
|
||||||
|
|
@ -81,7 +87,7 @@ class User
|
||||||
target_people = target_people | group.people
|
target_people = target_people | group.people
|
||||||
}
|
}
|
||||||
|
|
||||||
post.socket_to_uid(id, :group_ids => groups.map{|g| g.id}) if post.respond_to?(:socket_to_uid)
|
post.socket_to_uid(id, :group_ids => group_ids) if post.respond_to?(:socket_to_uid)
|
||||||
post.push_to( target_people )
|
post.push_to( target_people )
|
||||||
|
|
||||||
self.raw_visible_posts << post
|
self.raw_visible_posts << post
|
||||||
|
|
@ -254,7 +260,7 @@ class User
|
||||||
end
|
end
|
||||||
|
|
||||||
def groups_with_person person
|
def groups_with_person person
|
||||||
id = ensure_bson person.id
|
id = ensure_bson person.object_id
|
||||||
groups.select {|group| group.person_ids.include? id}
|
groups.select {|group| group.person_ids.include? id}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -266,6 +272,9 @@ class User
|
||||||
self.person.save!
|
self.person.save!
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def all_group_ids
|
||||||
|
self.groups.all.collect{|x| x.id}
|
||||||
|
end
|
||||||
protected
|
protected
|
||||||
def generate_key
|
def generate_key
|
||||||
OpenSSL::PKey::RSA::generate 1024
|
OpenSSL::PKey::RSA::generate 1024
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@
|
||||||
|
|
||||||
= javascript_include_tag 'fancybox/jquery.fancybox-1.3.1.pack'
|
= javascript_include_tag 'fancybox/jquery.fancybox-1.3.1.pack'
|
||||||
|
|
||||||
= javascript_include_tag 'view', 'publisher', 'image_picker', 'group_nav'
|
= javascript_include_tag 'view', 'image_picker', 'group_nav'
|
||||||
= render 'js/websocket_js'
|
= render 'js/websocket_js'
|
||||||
|
|
||||||
= csrf_meta_tag
|
= csrf_meta_tag
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,6 @@
|
||||||
%h1
|
%h1
|
||||||
= @person.real_name
|
= @person.real_name
|
||||||
- unless @person.id == current_user.person.id
|
- unless @person.id == current_user.person.id
|
||||||
|
|
||||||
.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"
|
||||||
|
|
||||||
|
|
@ -16,6 +15,8 @@
|
||||||
%i= "last seen: #{how_long_ago(@posts.first)}"
|
%i= "last seen: #{how_long_ago(@posts.first)}"
|
||||||
%li
|
%li
|
||||||
%i= "friends since: #{how_long_ago(@person)}"
|
%i= "friends since: #{how_long_ago(@person)}"
|
||||||
|
%li
|
||||||
|
="groups: #{@person_groups}"
|
||||||
%li
|
%li
|
||||||
url:
|
url:
|
||||||
= @person.url
|
= @person.url
|
||||||
|
|
@ -31,7 +32,7 @@
|
||||||
%h3= "stream - #{@post_count} item(s)"
|
%h3= "stream - #{@post_count} item(s)"
|
||||||
%ul#stream
|
%ul#stream
|
||||||
- for post in @posts
|
- for post in @posts
|
||||||
= render type_partial(post), :post => post
|
= render type_partial(post), :post => post unless post.class == Album
|
||||||
= will_paginate @posts
|
= will_paginate @posts
|
||||||
- else
|
- else
|
||||||
%h3 no posts to display!
|
%h3 no posts to display!
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,7 @@ Diaspora::Application.routes.draw do
|
||||||
match 'zombiefriends', :to => "dev_utilities#zombiefriends"
|
match 'zombiefriends', :to => "dev_utilities#zombiefriends"
|
||||||
match 'zombiefriendaccept', :to => "dev_utilities#zombiefriendaccept"
|
match 'zombiefriendaccept', :to => "dev_utilities#zombiefriendaccept"
|
||||||
match 'set_backer_number', :to => "dev_utilities#set_backer_number"
|
match 'set_backer_number', :to => "dev_utilities#set_backer_number"
|
||||||
|
match 'set_profile_photo', :to => "dev_utilities#set_profile_photo"
|
||||||
|
|
||||||
#routes for devise, not really sure you will need to mess with this in the future, lets put default,
|
#routes for devise, not really sure you will need to mess with this in the future, lets put default,
|
||||||
#non mutable stuff in anohter file
|
#non mutable stuff in anohter file
|
||||||
|
|
|
||||||
|
|
@ -19,8 +19,7 @@ def create
|
||||||
:password => "#{username+backer_info[backer_number]['pin'].to_s}",
|
:password => "#{username+backer_info[backer_number]['pin'].to_s}",
|
||||||
:person => Person.new(
|
:person => Person.new(
|
||||||
:email => "#{username}@#{username}.joindiaspora.com",
|
:email => "#{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/users/#{username}.jpg"),
|
|
||||||
:url=> "http://#{username}.joindiaspora.com/")
|
:url=> "http://#{username}.joindiaspora.com/")
|
||||||
)
|
)
|
||||||
user.person.save
|
user.person.save
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,6 @@ module Diaspora
|
||||||
|
|
||||||
module Socketable
|
module Socketable
|
||||||
def socket_to_uid(id, opts={})
|
def socket_to_uid(id, opts={})
|
||||||
puts "#{id}, #{self}, #{opts}"
|
|
||||||
SocketsController.new.outgoing(id, self, opts)
|
SocketsController.new.outgoing(id, self, opts)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,20 +0,0 @@
|
||||||
$(document).ready( function() {
|
|
||||||
|
|
||||||
$("#publisher_content_pickers .status_message").click(selectPublisherTab);
|
|
||||||
$("#publisher_content_pickers .bookmark").click(selectPublisherTab);
|
|
||||||
$("#publisher_content_pickers .blog").click(selectPublisherTab);
|
|
||||||
$("#publisher_content_pickers .photo").click(selectPublisherTab);
|
|
||||||
|
|
||||||
function selectPublisherTab(evt){
|
|
||||||
evt.preventDefault();
|
|
||||||
var form_id = "#new_" + this.className
|
|
||||||
if( $(form_id).css("display") == "none" ) {
|
|
||||||
$("#publisher_content_pickers").children("li").removeClass("selected");
|
|
||||||
$("#publisher_form form").fadeOut(50);
|
|
||||||
|
|
||||||
$(this).toggleClass("selected");
|
|
||||||
$(form_id).delay(50).fadeIn(200);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
@ -185,6 +185,7 @@ h1
|
||||||
:weight 200
|
:weight 200
|
||||||
:color #999
|
:color #999
|
||||||
|
|
||||||
|
|
||||||
h3
|
h3
|
||||||
:position relativex
|
:position relativex
|
||||||
:font
|
:font
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@ describe 'SocketsController' do
|
||||||
|
|
||||||
describe 'actionhash' do
|
describe 'actionhash' do
|
||||||
before do
|
before do
|
||||||
@message = @user.post :status_message, :message => "post through user for victory"
|
@message = @user.post :status_message, :message => "post through user for victory", :to => @user.group(:name => "losers").id
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should actionhash posts' do
|
it 'should actionhash posts' do
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ include Salmon
|
||||||
describe Salmon do
|
describe Salmon do
|
||||||
it 'should verify the signature on a roundtrip' do
|
it 'should verify the signature on a roundtrip' do
|
||||||
@user = Factory.create :user
|
@user = Factory.create :user
|
||||||
@post = @user.post :status_message, :message => "hi"
|
@post = @user.post :status_message, :message => "hi", :to => @user.group(:name => "sdg").id
|
||||||
x = Salmon::SalmonSlap.create(@user, @post.to_diaspora_xml)
|
x = Salmon::SalmonSlap.create(@user, @post.to_diaspora_xml)
|
||||||
|
|
||||||
z = Salmon::SalmonSlap.parse x.to_xml
|
z = Salmon::SalmonSlap.parse x.to_xml
|
||||||
|
|
@ -29,7 +29,7 @@ describe Salmon do
|
||||||
|
|
||||||
it 'should return the data so it can be "received"' do
|
it 'should return the data so it can be "received"' do
|
||||||
@user = Factory.create :user
|
@user = Factory.create :user
|
||||||
@post = @user.post :status_message, :message => "hi"
|
@post = @user.post :status_message, :message => "hi", :to => @user.group(:name => "sdg").id
|
||||||
x = Salmon::SalmonSlap.create(@user, @post.to_diaspora_xml)
|
x = Salmon::SalmonSlap.create(@user, @post.to_diaspora_xml)
|
||||||
|
|
||||||
z = Salmon::SalmonSlap.parse x.to_xml
|
z = Salmon::SalmonSlap.parse x.to_xml
|
||||||
|
|
|
||||||
|
|
@ -6,9 +6,8 @@ describe Diaspora do
|
||||||
|
|
||||||
describe Webhooks do
|
describe Webhooks do
|
||||||
before do
|
before do
|
||||||
@user = Factory.create(:user, :email => "bob@aol.com")
|
@user = Factory.create(:user, :email => "bob@aol.com")
|
||||||
@user.person.save
|
@group = @user.group(:name => "losers")
|
||||||
@person = Factory.create(:person)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "body" do
|
describe "body" do
|
||||||
|
|
@ -22,7 +21,7 @@ describe Diaspora do
|
||||||
|
|
||||||
it "should send an owners post to their people" do
|
it "should send an owners post to their people" do
|
||||||
message_queue.should_receive :process
|
message_queue.should_receive :process
|
||||||
@user.post :status_message, :message => "hi"
|
@user.post :status_message, :message => "hi", :to => @group.id
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should check that it does not send a person's post to an owners people" do
|
it "should check that it does not send a person's post to an owners people" do
|
||||||
|
|
@ -30,16 +29,6 @@ describe Diaspora do
|
||||||
Factory.create(:status_message, :person => Factory.create(:person))
|
Factory.create(:status_message, :person => Factory.create(:person))
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should ensure one url is created for every person" do
|
|
||||||
5.times {@user.friends << Factory.create(:person)}
|
|
||||||
@user.save
|
|
||||||
|
|
||||||
@post.person.owner.reload
|
|
||||||
|
|
||||||
@post.people_with_permissions.size.should == 5
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -70,7 +70,7 @@ describe Group do
|
||||||
it 'should add post to group via post method' do
|
it 'should add post to group via post method' do
|
||||||
group = @user.group(:name => 'losers', :people => [@friend])
|
group = @user.group(:name => 'losers', :people => [@friend])
|
||||||
|
|
||||||
status_message = @user.post( :status_message, :message => "hey", :group_ids => [group.id] )
|
status_message = @user.post( :status_message, :message => "hey", :to => group.id )
|
||||||
|
|
||||||
group.reload
|
group.reload
|
||||||
group.posts.include?(status_message).should be true
|
group.posts.include?(status_message).should be true
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ require File.dirname(__FILE__) + '/../spec_helper'
|
||||||
describe Retraction do
|
describe Retraction do
|
||||||
before do
|
before do
|
||||||
@user = Factory.create(:user)
|
@user = Factory.create(:user)
|
||||||
@post = @user.post(:status_message, :message => "Destroy!")
|
@post = @user.post :status_message, :message => "Destroy!", :to => @user.group(:name => "losers").id
|
||||||
@person = Factory.create(:person)
|
@person = Factory.create(:person)
|
||||||
@user.friends << @person
|
@user.friends << @person
|
||||||
@user.save
|
@user.save
|
||||||
|
|
|
||||||
11
spec/models/user/posting_spec.rb
Normal file
11
spec/models/user/posting_spec.rb
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
require File.dirname(__FILE__) + '/../../spec_helper'
|
||||||
|
|
||||||
|
describe User do
|
||||||
|
before do
|
||||||
|
@user = Factory.create(:user)
|
||||||
|
@group = @user.group(:name => 'heroes')
|
||||||
|
end
|
||||||
|
it 'should not be able to post without a group' do
|
||||||
|
proc {@user.post(:status_message, :message => "heyheyhey")}.should raise_error /You must post to someone/
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
@ -8,12 +8,11 @@ describe User do
|
||||||
|
|
||||||
@user2 = Factory.create(:user)
|
@user2 = Factory.create(:user)
|
||||||
@group2 = @user2.group(:name => 'losers')
|
@group2 = @user2.group(:name => 'losers')
|
||||||
#Factory.create :friend, @user
|
|
||||||
friend_users(@user, @group, @user2, @group2)
|
friend_users(@user, @group, @user2, @group2)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should be able to parse and store a status message from xml' do
|
it 'should be able to parse and store a status message from xml' do
|
||||||
status_message = @user2.post :status_message, :message => 'store this!'
|
status_message = @user2.post :status_message, :message => 'store this!', :to => @group2.id
|
||||||
person = @user2.person
|
person = @user2.person
|
||||||
|
|
||||||
xml = status_message.to_diaspora_xml
|
xml = status_message.to_diaspora_xml
|
||||||
|
|
@ -30,7 +29,7 @@ describe User do
|
||||||
num_groups = @user.groups.size
|
num_groups = @user.groups.size
|
||||||
|
|
||||||
(0..5).each{ |n|
|
(0..5).each{ |n|
|
||||||
status_message = @user2.post :status_message, :message => "store this #{n}!"
|
status_message = @user2.post :status_message, :message => "store this #{n}!", :to => @group2.id
|
||||||
xml = status_message.to_diaspora_xml
|
xml = status_message.to_diaspora_xml
|
||||||
@user.receive( xml )
|
@user.receive( xml )
|
||||||
}
|
}
|
||||||
|
|
@ -45,13 +44,13 @@ describe User do
|
||||||
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
|
||||||
status_message = @user.post :status_message, :message => "hi"
|
status_message = @user.post :status_message, :message => "hi", :to => @group.id
|
||||||
@user.reload
|
@user.reload
|
||||||
@user.raw_visible_posts.include?(status_message).should be true
|
@user.raw_visible_posts.include?(status_message).should be true
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should be removed on unfriending' do
|
it 'should be removed on unfriending' do
|
||||||
status_message = @user2.post :status_message, :message => "hi"
|
status_message = @user2.post :status_message, :message => "hi", :to => @group2.id
|
||||||
@user.receive status_message.to_diaspora_xml
|
@user.receive status_message.to_diaspora_xml
|
||||||
@user.reload
|
@user.reload
|
||||||
|
|
||||||
|
|
@ -66,7 +65,7 @@ describe User do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should be remove a post if the noone links to it' do
|
it 'should be remove a post if the noone links to it' do
|
||||||
status_message = @user2.post :status_message, :message => "hi"
|
status_message = @user2.post :status_message, :message => "hi", :to => @group2.id
|
||||||
@user.receive status_message.to_diaspora_xml
|
@user.receive status_message.to_diaspora_xml
|
||||||
@user.reload
|
@user.reload
|
||||||
|
|
||||||
|
|
@ -83,7 +82,7 @@ describe User do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should keep track of user references for one person ' do
|
it 'should keep track of user references for one person ' do
|
||||||
status_message = @user2.post :status_message, :message => "hi"
|
status_message = @user2.post :status_message, :message => "hi", :to => @group2.id
|
||||||
@user.receive status_message.to_diaspora_xml
|
@user.receive status_message.to_diaspora_xml
|
||||||
@user.reload
|
@user.reload
|
||||||
|
|
||||||
|
|
@ -107,7 +106,7 @@ describe User do
|
||||||
it 'should not override userrefs on receive by another person' do
|
it 'should not override userrefs on receive by another person' do
|
||||||
@user3.activate_friend(@user2.person, @group3)
|
@user3.activate_friend(@user2.person, @group3)
|
||||||
|
|
||||||
status_message = @user2.post :status_message, :message => "hi"
|
status_message = @user2.post :status_message, :message => "hi", :to => @group2.id
|
||||||
@user.receive status_message.to_diaspora_xml
|
@user.receive status_message.to_diaspora_xml
|
||||||
|
|
||||||
@user3.receive status_message.to_diaspora_xml
|
@user3.receive status_message.to_diaspora_xml
|
||||||
|
|
|
||||||
|
|
@ -21,9 +21,9 @@ describe User do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should generate a valid stream for a group of people' do
|
it 'should generate a valid stream for a group of people' do
|
||||||
status_message1 = @user2.post :status_message, :message => "hi"
|
status_message1 = @user2.post :status_message, :message => "hi", :to => @user2_group.id
|
||||||
status_message2 = @user3.post :status_message, :message => "heyyyy"
|
status_message2 = @user3.post :status_message, :message => "heyyyy", :to => @user3_group.id
|
||||||
status_message3 = @user4.post :status_message, :message => "yooo"
|
status_message3 = @user4.post :status_message, :message => "yooo", :to => @user4_group.id
|
||||||
|
|
||||||
@user.receive status_message1.to_diaspora_xml
|
@user.receive status_message1.to_diaspora_xml
|
||||||
@user.receive status_message2.to_diaspora_xml
|
@user.receive status_message2.to_diaspora_xml
|
||||||
|
|
|
||||||
|
|
@ -62,14 +62,14 @@ describe 'user encryption' do
|
||||||
describe 'signing and verifying' do
|
describe 'signing and verifying' do
|
||||||
|
|
||||||
it 'should sign a message on create' do
|
it 'should sign a message on create' do
|
||||||
message = @user.post :status_message, :message => "hi"
|
message = @user.post :status_message, :message => "hi", :to => @group.id
|
||||||
message.signature_valid?.should be true
|
message.signature_valid?.should be true
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should sign a retraction on create' do
|
it 'should sign a retraction on create' do
|
||||||
|
|
||||||
unstub_mocha_stubs
|
unstub_mocha_stubs
|
||||||
message = @user.post :status_message, :message => "hi"
|
message = @user.post :status_message, :message => "hi", :to => @group.id
|
||||||
|
|
||||||
|
|
||||||
retraction = @user.retract(message)
|
retraction = @user.retract(message)
|
||||||
|
|
@ -110,7 +110,7 @@ describe 'user encryption' do
|
||||||
|
|
||||||
describe 'sending and recieving signatures' do
|
describe 'sending and recieving signatures' do
|
||||||
it 'should contain the signature in the xml' do
|
it 'should contain the signature in the xml' do
|
||||||
message = @user.post :status_message, :message => "hi"
|
message = @user.post :status_message, :message => "hi", :to => @group.id
|
||||||
xml = message.to_xml.to_s
|
xml = message.to_xml.to_s
|
||||||
xml.include?(message.creator_signature).should be true
|
xml.include?(message.creator_signature).should be true
|
||||||
end
|
end
|
||||||
|
|
@ -118,7 +118,7 @@ describe 'user encryption' do
|
||||||
it 'A message with an invalid signature should be rejected' do
|
it 'A message with an invalid signature should be rejected' do
|
||||||
@user2 = Factory.create :user
|
@user2 = Factory.create :user
|
||||||
|
|
||||||
message = @user2.post :status_message, :message => "hey"
|
message = @user2.post :status_message, :message => "hey", :to => @user2.group(:name => "bruisers").id
|
||||||
message.creator_signature = "totally valid"
|
message.creator_signature = "totally valid"
|
||||||
message.save(:validate => false)
|
message.save(:validate => false)
|
||||||
|
|
||||||
|
|
@ -135,7 +135,7 @@ describe 'user encryption' do
|
||||||
@remote_message = Factory.build(:status_message, :person => @person)
|
@remote_message = Factory.build(:status_message, :person => @person)
|
||||||
@remote_message.creator_signature = @remote_message.send(:sign_with_key,@person.encryption_key)
|
@remote_message.creator_signature = @remote_message.send(:sign_with_key,@person.encryption_key)
|
||||||
@remote_message.save
|
@remote_message.save
|
||||||
@message = @user.post :status_message, :message => "hi"
|
@message = @user.post :status_message, :message => "hi", :to => @group.id
|
||||||
end
|
end
|
||||||
it 'should attach the creator signature if the user is commenting' do
|
it 'should attach the creator signature if the user is commenting' do
|
||||||
@user.comment "Yeah, it was great", :on => @remote_message
|
@user.comment "Yeah, it was great", :on => @remote_message
|
||||||
|
|
@ -143,7 +143,7 @@ describe 'user encryption' do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should sign the comment if the user is the post creator' do
|
it 'should sign the comment if the user is the post creator' do
|
||||||
message = @user.post :status_message, :message => "hi"
|
message = @user.post :status_message, :message => "hi", :to => @group.id
|
||||||
@user.comment "Yeah, it was great", :on => message
|
@user.comment "Yeah, it was great", :on => message
|
||||||
message.comments.first.signature_valid?.should be true
|
message.comments.first.signature_valid?.should be true
|
||||||
message.comments.first.verify_post_creator_signature.should be true
|
message.comments.first.verify_post_creator_signature.should be true
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue