diff --git a/app/controllers/albums_controller.rb b/app/controllers/albums_controller.rb index d4b0b79bc..094f7e469 100644 --- a/app/controllers/albums_controller.rb +++ b/app/controllers/albums_controller.rb @@ -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 diff --git a/app/controllers/photos_controller.rb b/app/controllers/photos_controller.rb index a82b4e799..7df4fe55a 100644 --- a/app/controllers/photos_controller.rb +++ b/app/controllers/photos_controller.rb @@ -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 diff --git a/app/models/person.rb b/app/models/person.rb index 83fa6bee0..f7d2cc556 100644 --- a/app/models/person.rb +++ b/app/models/person.rb @@ -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 diff --git a/app/views/albums/edit.html.haml b/app/views/albums/edit.html.haml index cf2d41115..6eb5c1f97 100644 --- a/app/views/albums/edit.html.haml +++ b/app/views/albums/edit.html.haml @@ -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 diff --git a/app/views/aspects/show.html.haml b/app/views/aspects/show.html.haml index 21794b788..ab4fdfd06 100644 --- a/app/views/aspects/show.html.haml +++ b/app/views/aspects/show.html.haml @@ -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 diff --git a/app/views/photos/show.html.haml b/app/views/photos/show.html.haml index 5393621e5..bbd1ec21f 100644 --- a/app/views/photos/show.html.haml +++ b/app/views/photos/show.html.haml @@ -40,7 +40,8 @@ = @photo.image .right - = link_to 'Edit Photo', edit_photo_path(@photo), :class => "button" + -if current_user.owns? @album + = link_to 'Edit Photo', edit_photo_path(@photo), :class => "button" .sub_header = link_to "<< prev", url_to_prev(@photo, @album) diff --git a/app/views/publics/webfinger.erb b/app/views/publics/webfinger.erb index 75a2e9fe8..ab3e35087 100644 --- a/app/views/publics/webfinger.erb +++ b/app/views/publics/webfinger.erb @@ -3,7 +3,6 @@ acct:<%=@person.email%> "<%= @person.url %>" - diff --git a/lib/diaspora/user/friending.rb b/lib/diaspora/user/friending.rb index fca5bca2b..1ef431c06 100644 --- a/lib/diaspora/user/friending.rb +++ b/lib/diaspora/user/friending.rb @@ -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 diff --git a/spec/controllers/requests_controller_spec.rb b/spec/controllers/requests_controller_spec.rb index fe419f341..348916334 100644 --- a/spec/controllers/requests_controller_spec.rb +++ b/spec/controllers/requests_controller_spec.rb @@ -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 diff --git a/spec/controllers/sockets_controller_spec.rb b/spec/controllers/sockets_controller_spec.rb index f66701289..369b203a5 100644 --- a/spec/controllers/sockets_controller_spec.rb +++ b/spec/controllers/sockets_controller_spec.rb @@ -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}) diff --git a/spec/lib/diaspora_parser_spec.rb b/spec/lib/diaspora_parser_spec.rb index ef033221c..5cc106fed 100644 --- a/spec/lib/diaspora_parser_spec.rb +++ b/spec/lib/diaspora_parser_spec.rb @@ -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 diff --git a/spec/models/person_spec.rb b/spec/models/person_spec.rb index d423986be..be6b536bb 100644 --- a/spec/models/person_spec.rb +++ b/spec/models/person_spec.rb @@ -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 diff --git a/spec/models/photo_spec.rb b/spec/models/photo_spec.rb index 948648d78..85208067d 100644 --- a/spec/models/photo_spec.rb +++ b/spec/models/photo_spec.rb @@ -35,7 +35,8 @@ describe Photo do end it 'should have a constructor' do - image = File.open(@fixture_name) + 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 photo.image.read.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 diff --git a/spec/models/user/user_friending_spec.rb b/spec/models/user/user_friending_spec.rb index 76071f53a..ad31042f1 100644 --- a/spec/models/user/user_friending_spec.rb +++ b/spec/models/user/user_friending_spec.rb @@ -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 diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 2e19f242b..abc3ce1b5 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -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)