Merge branch 'master' of github.com:diaspora/diaspora

This commit is contained in:
Daniel Vincent Grippi 2010-09-13 14:26:15 -07:00
commit 40ecf176e8
15 changed files with 22 additions and 35 deletions

View file

@ -53,6 +53,7 @@ class AlbumsController < ApplicationController
def edit
@album = Album.find_by_id params[:id]
redirect_to @album unless current_user.owns? @album
end
def update

View file

@ -90,6 +90,8 @@ class PhotosController < ApplicationController
def edit
@photo = Photo.find_by_id params[:id]
@album = @photo.album
redirect_to @photo unless current_user.owns? @album
end
def update

View file

@ -35,7 +35,6 @@ class Person
key :serialized_key, String
key :owner_id, ObjectId
key :user_refs, Integer, :default => 0
one :profile, :class_name => 'Profile'
many :albums, :class_name => 'Album', :foreign_key => :person_id

View file

@ -28,11 +28,11 @@
- form_for @album do |a|
= a.error_messages
%p
%b album name:
= a.text_field :name
%ul
- for photo in @album.photos
%li.photo_edit_block= image_tag photo.url(:thumb_large)
.photo_edit_block= image_tag photo.url(:thumb_medium)
#submit_block
= link_to "Cancel", root_path

View file

@ -25,7 +25,7 @@
%ul#stream
- for post in @posts
= render type_partial(post), :post => post
= render type_partial(post), :post => post unless post.class == Album
#pagination
= will_paginate @posts

View file

@ -40,6 +40,7 @@
= @photo.image
.right
-if current_user.owns? @album
= link_to 'Edit Photo', edit_photo_path(@photo), :class => "button"
.sub_header

View file

@ -3,7 +3,6 @@
<Subject>acct:<%=@person.email%></Subject>
<Alias>"<%= @person.url %>"</Alias>
<Link rel="http://microformats.org/profile/hcard" type="text/html" href="<%=@person.url%>/hcard/users/<%=@person.id%>"/>
<Link rel="http://schemas.google.com/g/2010#updates-from" type="application/atom+xml" href="<%=@person.url%>status_messages.atom"/>
<Link rel="http://joindiaspora.com/seed_location" type = 'text/html' href="<%=@person.url%>"/>
<Link rel="http://joindiaspora.com/guid" type = 'text/html' href="<%=@person.id%>"/>
<Link rel="diaspora-public-key" type = 'RSA' href="<%=Base64.encode64(@person.exported_key)%>"/>

View file

@ -66,12 +66,10 @@ module Diaspora
request = Request.find_by_id(friend_request_id)
person = request.person
person.user_refs -= 1
self.pending_requests.delete(request)
self.save
(person.user_refs > 0 || person.owner.nil? == false) ? person.save : person.destroy
person.save
request.destroy
end
@ -86,9 +84,6 @@ module Diaspora
friend_request.destroy
else
friend_request.person.reload
friend_request.person.user_refs += 1
friend_request.person.save
self.pending_requests << friend_request
self.save
Rails.logger.info("#{self.real_name} has received a friend request")
@ -115,8 +110,7 @@ module Diaspora
}
self.save
bad_friend.user_refs -= 1
(bad_friend.user_refs > 0 || bad_friend.owner.nil? == false) ? bad_friend.save : bad_friend.destroy
bad_friend.save
end
def unfriended_by(bad_friend)
@ -125,11 +119,9 @@ module Diaspora
end
def activate_friend(person, aspect)
person.user_refs += 1
aspect.people << person
friends << person
save
person.save
aspect.save
end

View file

@ -29,8 +29,9 @@ describe RequestsController do
@evan = Redfinger.finger('evan@status.net')
@max = Redfinger.finger('mbs348@gmail.com')
sign_in :user, @user
stub!(:current_user).and_return @user
end
it 'should return the correct tag and url for a given address' do
relationship_flow('tom@tom.joindiaspora.com')[:friend].include?("receive/user").should == true
relationship_flow('tom@tom.joindiaspora.com')[:friend].receive_url.include?("receive/user").should == true
end
end

View file

@ -46,6 +46,7 @@ describe SocketsController do
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)
photo = @user.post(:photo, :album_id => @album.id, :user_file => [File.open(@fixture_name)])
json = @controller.action_hash(@user.id, photo, :aspect_ids => @user.aspects_with_post(@album.id).map{|g| g.id})

View file

@ -156,7 +156,6 @@ describe Diaspora::Parser do
Person.count.should == person_count
@user.receive retraction_xml
Person.count.should == person_count-1
@aspect.reload
@aspect.people.size.should == aspect_people_count -1

View file

@ -79,7 +79,7 @@ describe Person do
end
describe "unfriending" do
it 'should delete an orphaned friend' do
it 'should not delete an orphaned friend' do
request = @user.send_friend_request_to @person, @aspect
@user.activate_friend(@person, @aspect)
@ -90,7 +90,7 @@ describe Person do
@user.unfriend(@person)
@user.reload
@user.friends.count.should == 0
Person.all.count.should == 2
Person.all.count.should == 3
end
it 'should not delete an un-orphaned friend' do

View file

@ -35,6 +35,7 @@ describe Photo do
end
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])
photo.created_at.nil?.should be false
@ -107,6 +108,7 @@ describe Photo do
end
it 'should save a signed photo' do
pending "Figure out how to make the photo posting api work in specs, it needs a file type"
photo = @user.post(:photo, :album_id => @album.id, :user_file => [File.open(@fixture_name)])
photo.save.should == true
photo.signature_valid?.should be true

View file

@ -58,7 +58,7 @@ describe User do
@user.ignore_friend_request(r.id)
Person.count.should == 1
Person.count.should == 2
Request.count.should == 0
end
@ -145,7 +145,7 @@ describe User do
Person.all.count.should be 3
end
it 'should not keep the person around if the users ignores them' do
it 'should keep the person around if the users ignores them' do
@user.receive @req_xml
@user.pending_requests.size.should be 1
@user.ignore_friend_request @user.pending_requests.first.id
@ -155,7 +155,7 @@ describe User do
@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
Person.all.count.should be 2
Person.all.count.should be 3
end
@ -216,21 +216,11 @@ describe User do
@user.friends.count.should == 1
@user2.friends.count.should == 1
@user.person.user_refs.should == 1
@user2.person.user_refs.should == 1
@user2.unfriend @user.person
@user2.friends.count.should be 0
@user.person.reload
@user.person.user_refs.should == 0
@user.unfriended_by @user2.person
@user2.person.reload
@user2.person.user_refs.should == 0
@aspect.reload
@aspect2.reload
@aspect.people.count.should == 0

View file

@ -78,7 +78,7 @@ end
end
def message_queue
Post.send(:class_variable_get, :@@queue)
User::QUEUE
end
def friend_users(user1, aspect1, user2, aspect2)