From 34b21e75439b76b5cb01ec8c944c6504161e82b4 Mon Sep 17 00:00:00 2001 From: maelsoucaze Date: Sat, 16 Oct 2010 17:19:19 +0200 Subject: [PATCH 01/12] French localization updates. --- config/locales/diaspora/fr-informal.yml | 12 ++++++++---- config/locales/diaspora/fr.yml | 12 ++++++++---- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/config/locales/diaspora/fr-informal.yml b/config/locales/diaspora/fr-informal.yml index d8944f81e..f5c4d53bf 100644 --- a/config/locales/diaspora/fr-informal.yml +++ b/config/locales/diaspora/fr-informal.yml @@ -38,6 +38,7 @@ fr-informal: share: "Partager" aspect_friends: add_friends: "ajouter des amis" + photos: "photos" albums: album: you: "toi" @@ -69,10 +70,13 @@ fr-informal: friends_albums: "Albums d’amis" your_albums: "Tes albums" aspects: - index: - photos: "photos" - show: - photos: "photos" + empty_messages: + start_talking: "Personne n’a encore rien dit. Commence dès à présent la conversation !" + nobody: "Tu as forcément des amis, n’hésite pas à les ramener sur Diaspora !" + nobody_in_aspect: "Ton aspect '%{aspect_name}' est vide." + add_friend: "Ajouter un ami" + add_friend_to: "Ajouter quelqu’un à %{aspect_name}" + invite: "Inviter quelqu’un à rejoindre Diaspora !" manage: add_a_new_aspect: "Ajouter un nouvel aspect" add_a_new_friend: "Ajouter un nouvel ami" diff --git a/config/locales/diaspora/fr.yml b/config/locales/diaspora/fr.yml index c372ee57e..d4bc903c1 100644 --- a/config/locales/diaspora/fr.yml +++ b/config/locales/diaspora/fr.yml @@ -38,6 +38,7 @@ fr: share: "Partager" aspect_friends: add_friends: "ajouter des amis" + photos: "photos" albums: album: you: "vous" @@ -69,10 +70,13 @@ fr: friends_albums: "Albums d’amis" your_albums: "Vos albums" aspects: - index: - photos: "photos" - show: - photos: "photos" + empty_messages: + start_talking: "Personne n’a encore rien dit. Commencez dès à présent la conversation !" + nobody: "Vous avez forcément des amis, n’hésitez pas à les ramener sur Diaspora !" + nobody_in_aspect: "Votre aspect '%{aspect_name}' est vide." + add_friend: "Ajouter un ami" + add_friend_to: "Ajouter quelqu’un à %{aspect_name}" + invite: "Inviter quelqu’un à rejoindre Diaspora !" manage: add_a_new_aspect: "Ajouter un nouvel aspect" add_a_new_friend: "Ajouter un nouvel ami" From 14ac908c3d26ea44713f3abb6814948ca10d21bf Mon Sep 17 00:00:00 2001 From: maelsoucaze Date: Mon, 25 Oct 2010 00:06:05 +0200 Subject: [PATCH 02/12] French localizations updates. --- config/locales/diaspora/fr-informal.yml | 31 +++++++++++++++++++------ config/locales/diaspora/fr.yml | 31 +++++++++++++++++++------ 2 files changed, 48 insertions(+), 14 deletions(-) diff --git a/config/locales/diaspora/fr-informal.yml b/config/locales/diaspora/fr-informal.yml index f5c4d53bf..42267d796 100644 --- a/config/locales/diaspora/fr-informal.yml +++ b/config/locales/diaspora/fr-informal.yml @@ -6,6 +6,15 @@ # See http://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points. fr-informal: + activemodel: + errors: + models: + user: + attributes: + username: + taken: "est déjà pris" + email: + taken: "est déjà pris" hello: "Bonjour tout le monde" application: helper: @@ -70,13 +79,14 @@ fr-informal: friends_albums: "Albums d’amis" your_albums: "Tes albums" aspects: - empty_messages: - start_talking: "Personne n’a encore rien dit. Commence dès à présent la conversation !" + no_friends_message: nobody: "Tu as forcément des amis, n’hésite pas à les ramener sur Diaspora !" nobody_in_aspect: "Ton aspect '%{aspect_name}' est vide." add_friend: "Ajouter un ami" add_friend_to: "Ajouter quelqu’un à %{aspect_name}" invite: "Inviter quelqu’un à rejoindre Diaspora !" + no_posts_message: + start_talking: "Personne n’a encore rien dit. Commence dès à présent la conversation !" manage: add_a_new_aspect: "Ajouter un nouvel aspect" add_a_new_friend: "Ajouter un nouvel ami" @@ -94,12 +104,12 @@ fr-informal: success: "%{name} a été supprimé avec succès." update: success: "Ton aspect, %{name}, a été édité avec succès." - move_friends: - failure: "L’édition de l’aspect concernant ton ami %{real_name} a échoué." - success: "Les aspects ont été édités avec succès." move_friend: failure: "ne fonctionne pas %{inspect}" - success: "Tu montres à présent à ton ami un aspect différent au tiens." + success: "Personne déplacée vers le nouvel aspect" + add_to_aspect: + failure: "L’ajout de l’ami vers l’aspect a échoué." + success: "Tu as ajouté l’ami à l’aspect avec succès." helper: remove: "supprimer" aspect_not_empty: "L’aspect n’est pas vide" @@ -140,6 +150,8 @@ fr-informal: photo: show_comments: "afficher les commentaires" posted_a_new_photo_to: "a publié une nouvelle photo dans" + delete: "Supprimer" + are_you_sure: "Es-tu sûr(e) ?" new: new_photo: "Nouvelle photo" back_to_list: "Retourner à la liste" @@ -163,6 +175,7 @@ fr-informal: sent: 'Ton invitation a été envoyée.' no_more: 'Tu n’as plus d’invitation.' already_sent: 'Tu as déjà invité cette personne.' + already_friends: 'Tu es déjà ami avec cette personne' invitation_token_invalid: 'Le jeton d’invitation fourni n’est pas valide !' updated: 'Ton mot de passe a été réglé avec succès. Tu es à présent connecté.' @@ -204,6 +217,7 @@ fr-informal: save: "sauver" are_you_sure: "Es-tu sûr(e) ?" remove_friend: "supprimer de mes amis" + no_posts: "aucun message à afficher !" requests: new_request: add_a_new_friend_to: "Ajouter un nouvel ami à" @@ -216,6 +230,9 @@ fr-informal: ignore: "Requête d’ami ignorée." create: error: "Aucun résultat Diaspora n’a été trouvé avec cette adresse e-mail !" - already_friends: "Vous êtes déjà amis avec %{destination_url}!" + invalid_identity: "Cette identité n’est pas proprement formatée" + error_server: "Un problème est survenu avec l’autre serveur. Il n’existe peut-être pas ?" + yourself: "Tu ne peux pas être ami avec toi-même !" + already_friends: "Tu es déjà ami avec %{destination_url}!" success: "Une requête d’ami a été envoyée à %{destination_url}." horribly_wrong: "Quelque chose d’horrible s’est produit." diff --git a/config/locales/diaspora/fr.yml b/config/locales/diaspora/fr.yml index d4bc903c1..baf9d1b82 100644 --- a/config/locales/diaspora/fr.yml +++ b/config/locales/diaspora/fr.yml @@ -6,6 +6,15 @@ # See http://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points. fr: + activemodel: + errors: + models: + user: + attributes: + username: + taken: "est déjà pris" + email: + taken: "est déjà pris" hello: "Bonjour tout le monde" application: helper: @@ -70,13 +79,14 @@ fr: friends_albums: "Albums d’amis" your_albums: "Vos albums" aspects: - empty_messages: - start_talking: "Personne n’a encore rien dit. Commencez dès à présent la conversation !" + no_friends_message: nobody: "Vous avez forcément des amis, n’hésitez pas à les ramener sur Diaspora !" nobody_in_aspect: "Votre aspect '%{aspect_name}' est vide." add_friend: "Ajouter un ami" add_friend_to: "Ajouter quelqu’un à %{aspect_name}" invite: "Inviter quelqu’un à rejoindre Diaspora !" + no_posts_message: + start_talking: "Personne n’a encore rien dit. Commencez dès à présent la conversation !" manage: add_a_new_aspect: "Ajouter un nouvel aspect" add_a_new_friend: "Ajouter un nouvel ami" @@ -94,12 +104,12 @@ fr: success: "%{name} a été supprimé avec succès." update: success: "Votre aspect, %{name}, a été édité avec succès." - move_friends: - failure: "L’édition de l’aspect concernant votre ami %{real_name} a échoué." - success: "Les aspects ont été édités avec succès." move_friend: failure: "ne fonctionne pas %{inspect}" - success: "Vous montrez à présent à votre ami un aspect différent au vôtre." + success: "Personne déplacée vers le nouvel aspect" + add_to_aspect: + failure: "L’ajout de l’ami vers l’aspect a échoué." + success: "Vous avez ajouté l’ami vers l’aspect avec succès." helper: remove: "supprimer" aspect_not_empty: "L’aspect n’est pas vide" @@ -140,6 +150,8 @@ fr: photo: show_comments: "afficher les commentaires" posted_a_new_photo_to: "a publié une nouvelle photo dans" + delete: "Supprimer" + are_you_sure: "Êtes-vous sûr(e) ?" new: new_photo: "Nouvelle photo" back_to_list: "Retourner à la liste" @@ -163,6 +175,7 @@ fr: sent: 'Votre invitation a été envoyée.' no_more: 'Vous n’avez plus d’invitation.' already_sent: 'Vous avez déjà invité cette personne.' + already_friends: 'Vous êtes déjà ami avec cette personne' invitation_token_invalid: 'Le jeton d’invitation fourni n’est pas valide !' updated: 'Votre mot de passe a été réglé avec succès. Vous êtes à présent connecté.' @@ -204,6 +217,7 @@ fr: save: "sauver" are_you_sure: "Êtes-vous sûr(e) ?" remove_friend: "supprimer de mes amis" + no_posts: "aucun message à afficher !" requests: new_request: add_a_new_friend_to: "Ajouter un nouvel ami à" @@ -216,6 +230,9 @@ fr: ignore: "Requête d’ami ignorée." create: error: "Aucun résultat Diaspora n’a été trouvé avec cette adresse e-mail !" - already_friends: "Vous êtes déjà amis avec %{destination_url}!" + invalid_identity: "Cette identité n’est pas proprement formatée" + error_server: "Un problème est survenu avec l’autre serveur. Il n’existe peut-être pas ?" + yourself: "Vous ne pouvez pas être ami avec vous-même !" + already_friends: "Vous êtes déjà ami avec %{destination_url}!" success: "Une requête d’ami a été envoyée à %{destination_url}." horribly_wrong: "Quelque chose d’horrible s’est produit." From c8663b45e2d46a3c45f08b8d6ed8139eeaad6054 Mon Sep 17 00:00:00 2001 From: ilya Date: Sun, 24 Oct 2010 15:17:15 -0700 Subject: [PATCH 03/12] readme added link to our convention --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 5a512f74d..8215e6c16 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ You can find an introduction to the source code [here](http://github.com/diaspor Bugs and pending features are on our [issue tracker](http://bugs.joindiaspora.com). Here are a few good places to start: - Run "rake spec" to run our [Rspec](http://blog.davidchelimsky.net/2007/05/14/an-introduction-to-rspec-part-i/) -unit test suite. Take a look at the pending specs, make one pass! +unit test suite. [Here](http://github.com/diaspora/diaspora/wiki/Introduction-to-Our-Rspec-Convention) is an introduction to our Rspec convention. Take a look at the pending specs, make one pass! - Run "rake cucumber" to run our [Cucumber](http://rubylearning.com/blog/2010/10/05/outside-in-development/) integration test suite. As you can see, we need more integration tests. Pick a feature and write one! From ed99f29a09dea11b637ad01883f321acdd6255b2 Mon Sep 17 00:00:00 2001 From: maxwell Date: Mon, 25 Oct 2010 22:03:36 -0700 Subject: [PATCH 04/12] dont show service if you dont have the keys for it. also, update deploy script --- app/views/services/index.html.haml | 4 ++-- config/deploy.rb | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/views/services/index.html.haml b/app/views/services/index.html.haml index ea375e9ac..5bec55933 100644 --- a/app/views/services/index.html.haml +++ b/app/views/services/index.html.haml @@ -23,6 +23,6 @@ = service.nickname = link_to "disconnect", service, :confirm => "disconnect #{service.provider}?", :method => :delete - %h4= link_to "Connect to twitter", "/auth/twitter" - %h4= link_to "Connect to facebook", "/auth/facebook" + %h4= link_to "Connect to twitter", "/auth/twitter" if SERVICES['twitter']['consumer_key']!= "" + %h4= link_to "Connect to facebook", "/auth/facebook" if SERVICES['facebook']['app_id'] !="" diff --git a/config/deploy.rb b/config/deploy.rb index b4893ec93..91fab2f85 100644 --- a/config/deploy.rb +++ b/config/deploy.rb @@ -56,9 +56,9 @@ namespace :deploy do run "ln -s -f #{shared_path}/app_config.yml #{current_path}/config/app_config.yml" end - task :symlink_fb_config do - run "touch #{shared_path}/fb_config.yml" - run "ln -s -f #{shared_path}/fb_config.yml #{current_path}/config/fb_config.yml" + task :symlink_oauth_keys_config do + run "touch #{shared_path}/oauth_keys.yml" + run "ln -s -f #{shared_path}/oauth_keys.yml #{current_path}/config/oauth_keys.yml" end task :start do From a992c5fbc218ed8c813240e75b153fed92ef53be Mon Sep 17 00:00:00 2001 From: maxwell Date: Mon, 25 Oct 2010 22:03:36 -0700 Subject: [PATCH 05/12] dont show service if you dont have the keys for it. also, update deploy script --- app/views/services/index.html.haml | 4 ++-- config/deploy.rb | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/app/views/services/index.html.haml b/app/views/services/index.html.haml index ea375e9ac..5bec55933 100644 --- a/app/views/services/index.html.haml +++ b/app/views/services/index.html.haml @@ -23,6 +23,6 @@ = service.nickname = link_to "disconnect", service, :confirm => "disconnect #{service.provider}?", :method => :delete - %h4= link_to "Connect to twitter", "/auth/twitter" - %h4= link_to "Connect to facebook", "/auth/facebook" + %h4= link_to "Connect to twitter", "/auth/twitter" if SERVICES['twitter']['consumer_key']!= "" + %h4= link_to "Connect to facebook", "/auth/facebook" if SERVICES['facebook']['app_id'] !="" diff --git a/config/deploy.rb b/config/deploy.rb index b4893ec93..09d8c0bc3 100644 --- a/config/deploy.rb +++ b/config/deploy.rb @@ -56,9 +56,9 @@ namespace :deploy do run "ln -s -f #{shared_path}/app_config.yml #{current_path}/config/app_config.yml" end - task :symlink_fb_config do - run "touch #{shared_path}/fb_config.yml" - run "ln -s -f #{shared_path}/fb_config.yml #{current_path}/config/fb_config.yml" + task :symlink_oauth_keys_config do + run "touch #{shared_path}/oauth_keys.yml" + run "ln -s -f #{shared_path}/oauth_keys.yml #{current_path}/config/oauth_keys.yml" end task :start do @@ -157,4 +157,4 @@ namespace :db do end -after "deploy:symlink", "deploy:symlink_images", "deploy:symlink_bundle", 'deploy:symlink_config', 'deploy:symlink_fb_config' +after "deploy:symlink", "deploy:symlink_images", "deploy:symlink_bundle", 'deploy:symlink_config', 'deploy:symlink_oauth_keys_config' From af917557f601a06f7056f5edea92a683bd5b54b1 Mon Sep 17 00:00:00 2001 From: maxwell Date: Mon, 25 Oct 2010 22:56:50 -0700 Subject: [PATCH 06/12] can't call match on nil --- app/controllers/status_messages_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/status_messages_controller.rb b/app/controllers/status_messages_controller.rb index cf6625839..a5c018af2 100644 --- a/app/controllers/status_messages_controller.rb +++ b/app/controllers/status_messages_controller.rb @@ -10,7 +10,7 @@ class StatusMessagesController < ApplicationController def create public_flag = params[:status_message][:public] - public_flag.match(/(true)/) ? public_flag = true : public_flag = false + public_flag.to_s.match(/(true)/) ? public_flag = true : public_flag = false params[:status_message][:public] = public_flag data = clean_hash params[:status_message] From ff13cad116edc5875bfd9147ecf697392400008b Mon Sep 17 00:00:00 2001 From: danielvincent Date: Tue, 26 Oct 2010 12:19:32 -0700 Subject: [PATCH 07/12] names of people display immediately on aspect#manage page --- public/javascripts/aspect-edit.js | 4 ++++ public/javascripts/view.js | 1 + 2 files changed, 5 insertions(+) diff --git a/public/javascripts/aspect-edit.js b/public/javascripts/aspect-edit.js index 9e565e4b2..4b6f1c421 100644 --- a/public/javascripts/aspect-edit.js +++ b/public/javascripts/aspect-edit.js @@ -25,8 +25,12 @@ $(function() { revert: true, start: function(event,ui){ $(this).children("img").animate({'height':80, 'width':80, 'opacity':0.8},200); + $(this).children("img").tipsy("hide"); $(".draggable_info").fadeIn(100); }, + drag: function(event,ui){ + $(this).children("img").tipsy("hide"); //ensure this is hidden + }, stop: function(event,ui){ $(this).children("img").animate({'height':70, 'width':70, 'opacity':1},200); $(".draggable_info").fadeOut(100); diff --git a/public/javascripts/view.js b/public/javascripts/view.js index 0b3987d53..26b3fea55 100644 --- a/public/javascripts/view.js +++ b/public/javascripts/view.js @@ -76,6 +76,7 @@ $(document).ready(function(){ $("img", "#left_pane").tipsy({live:true}); $(".add_aspect_button", "#aspect_nav").tipsy({gravity:'w'}); + $(".person img", ".dropzone").tipsy({live:true}); });//end document ready From 7f1d87f4241206ccaf3e6626e4e2d2110c2e92b8 Mon Sep 17 00:00:00 2001 From: danielvincent Date: Tue, 26 Oct 2010 12:57:43 -0700 Subject: [PATCH 08/12] fixed pagination bug on aspect#show (re: #445) --- app/controllers/aspects_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/aspects_controller.rb b/app/controllers/aspects_controller.rb index 0129c0abf..985fb68a9 100644 --- a/app/controllers/aspects_controller.rb +++ b/app/controllers/aspects_controller.rb @@ -48,7 +48,7 @@ class AspectsController < ApplicationController render :file => "#{Rails.root}/public/404.html", :layout => false, :status => 404 else @friends = @aspect.people - @posts = current_user.visible_posts( :by_members_of => @aspect ).paginate :per_page => 15, :order => 'created_at DESC' + @posts = current_user.visible_posts( :by_members_of => @aspect ).paginate :page => params[:page], :per_page => 15, :order => 'created_at DESC' respond_with @aspect end end From d8ca91769fbe1068b3a5c3ea06bd127065e98b94 Mon Sep 17 00:00:00 2001 From: danielvincent Date: Tue, 26 Oct 2010 13:03:45 -0700 Subject: [PATCH 09/12] dragging a person to Remove from Aspect on aspect#manage fades person correctly (re: #442) --- public/javascripts/aspect-edit.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/javascripts/aspect-edit.js b/public/javascripts/aspect-edit.js index 4b6f1c421..e4a581d57 100644 --- a/public/javascripts/aspect-edit.js +++ b/public/javascripts/aspect-edit.js @@ -92,7 +92,7 @@ $(function() { 'aspect_id' : person.attr('data-aspect_id') } }); } - person.fadeOut('slow', $(this).remove()); + person.fadeOut(400, function(){person.remove();}); } } }); From 8acdf212345e9c73d221a8d024d19b9b4af2a833 Mon Sep 17 00:00:00 2001 From: zhitomirskiyi Date: Tue, 26 Oct 2010 14:49:37 -0700 Subject: [PATCH 10/12] MS IZ got rid of the requests for me scope in the user --- app/models/request.rb | 2 - app/models/user.rb | 10 ++--- lib/diaspora/user/friending.rb | 11 +++-- spec/models/request_spec.rb | 11 ----- spec/models/user/user_friending_spec.rb | 53 +++++++++++++++++-------- spec/spec_helper.rb | 1 + 6 files changed, 48 insertions(+), 40 deletions(-) diff --git a/app/models/request.rb b/app/models/request.rb index a6efdc987..2226a7b45 100644 --- a/app/models/request.rb +++ b/app/models/request.rb @@ -26,8 +26,6 @@ class Request validates_presence_of :destination_url, :callback_url before_validation :clean_link - scope :for_user, lambda{ |user| where(:destination_url => user.person.receive_url) } - def self.instantiate(options = {}) person = options[:from] self.new(:destination_url => options[:to], diff --git a/app/models/user.rb b/app/models/user.rb index 6a184b156..850a2bb66 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -32,11 +32,11 @@ class User key :invites, Integer, :default => 5 key :invitation_token, String key :invitation_sent_at, DateTime - key :inviter_ids, Array - key :friend_ids, Array - key :pending_request_ids, Array - key :visible_post_ids, Array - key :visible_person_ids, Array + key :inviter_ids, Array, :typecast => 'ObjectId' + key :friend_ids, Array, :typecast => 'ObjectId' + key :pending_request_ids, Array, :typecast => 'ObjectId' + key :visible_post_ids, Array, :typecast => 'ObjectId' + key :visible_person_ids, Array, :typecast => 'ObjectId' key :invite_messages, Hash diff --git a/lib/diaspora/user/friending.rb b/lib/diaspora/user/friending.rb index 4a19ffd68..131b5b96a 100644 --- a/lib/diaspora/user/friending.rb +++ b/lib/diaspora/user/friending.rb @@ -29,9 +29,8 @@ module Diaspora end def accept_friend_request(friend_request_id, aspect_id) - request = Request.find_by_id(friend_request_id) - pending_requests.delete(request) - + request = pending_requests.find!(friend_request_id) + pending_request_ids.delete(request.id.to_id) activate_friend(request.person, aspect_by_id(aspect_id)) request.reverse_for(self) @@ -45,16 +44,16 @@ module Diaspora end def accept_and_respond(friend_request_id, aspect_id) - requester = Request.find_by_id(friend_request_id).person + requester = pending_requests.find!(friend_request_id).person reversed_request = accept_friend_request(friend_request_id, aspect_id) dispatch_friend_acceptance reversed_request, requester end def ignore_friend_request(friend_request_id) - request = Request.find_by_id(friend_request_id) + request = pending_requests.find!(friend_request_id) person = request.person - self.pending_requests.delete(request) + self.pending_request_ids.delete(request.id) self.save person.save diff --git a/spec/models/request_spec.rb b/spec/models/request_spec.rb index 6483c45fa..6e5dfbf57 100644 --- a/spec/models/request_spec.rb +++ b/spec/models/request_spec.rb @@ -31,17 +31,6 @@ describe Request do xml.should include user.exported_key end - 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 - it 'should strip the destination url' do person_request = Request.new person_request.destination_url = " http://google.com/ " diff --git a/spec/models/user/user_friending_spec.rb b/spec/models/user/user_friending_spec.rb index 63a472031..8a4386601 100644 --- a/spec/models/user/user_friending_spec.rb +++ b/spec/models/user/user_friending_spec.rb @@ -25,7 +25,7 @@ describe Diaspora::UserModules::Friending do end context 'friend requesting' do - it "should assign a request to a aspect" do + it "should assign a request to a aspect for the user that sent it out" do aspect.requests.size.should == 0 user.send_friend_request_to(friend, aspect) @@ -34,21 +34,42 @@ describe Diaspora::UserModules::Friending do aspect.requests.size.should == 1 end - it "should be able to accept a pending friend request" do - r = Request.instantiate(:to => user.receive_url, :from => friend) - r.save + describe '#receive_friend_request' do + it 'adds a request to pending if it was not sent by user' do + r = Request.instantiate(:to => user.receive_url, :from => friend) + r.save + user.receive_friend_request(r) + user.reload.pending_requests.should include r + end + + it 'should autoaccept a request the user sent' do + request = user.send_friend_request_to(user2.person, aspect) + request.reverse_for(user2) + proc{user.receive_friend_request(request)}.should change(user.reload.friends, :count).by(1) + end - proc { user.accept_friend_request(r.id, aspect.id) }.should change { - Request.for_user(user).all.count }.by(-1) end - it 'should be able to ignore a pending friend request' do - friend = Factory.create(:person) - r = Request.instantiate(:to => user.receive_url, :from => friend) - r.save + context 'received a friend request' do - proc { user.ignore_friend_request(r.id) }.should change { - Request.for_user(user).count }.by(-1) + let(:request_for_user) {Request.instantiate(:to => user.receive_url, :from => friend)} + let(:request2_for_user) {Request.instantiate(:to => user.receive_url, :from => person_one)} + before do + request_for_user.save + user.receive_friend_request(request_for_user) + user.receive_friend_request(request2_for_user) + user.reload + end + + it "should delete an accepted friend request" do + proc { user.accept_friend_request(request2_for_user.id, aspect.id) }.should change( + user.reload.pending_requests, :count ).by(-1) + end + + it 'should be able to ignore a pending friend request' do + proc { user.ignore_friend_request(request_for_user.id) }.should change ( + user.reload.pending_requests, :count ).by(-1) + end end it 'should not be able to friend request an existing friend' do @@ -168,20 +189,20 @@ describe Diaspora::UserModules::Friending do user.receive_friend_request @request person_two.destroy - user.pending_requests.size.should be 1 + user.reload.pending_requests.size.should be 1 user.friends.size.should be 0 user.receive_friend_request @request_two - user.pending_requests.size.should be 2 + user.reload.pending_requests.size.should be 2 user.friends.size.should be 0 user.accept_friend_request @request.id, aspect.id - user.pending_requests.size.should be 1 + user.reload.pending_requests.size.should be 1 user.friends.size.should be 1 user.friends.include?(person_one).should be true user.ignore_friend_request @request_two.id - user.pending_requests.size.should be 0 + user.reload.pending_requests.size.should be 0 user.friends.size.should be 1 user.friends.include?(person_two).should be false end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 29d731b29..11f18d8d2 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -67,6 +67,7 @@ ImageUploader.enable_processing = false def friend_users(user1, aspect1, user2, aspect2) request = user1.send_friend_request_to(user2.person, aspect1) + user2.receive_friend_request(request) reversed_request = user2.accept_friend_request( request.id, aspect2.id) user1.reload user1.receive reversed_request.to_diaspora_xml, user2.person From 6e015790a79e2ef75ba8d09c5f988abde432c9d7 Mon Sep 17 00:00:00 2001 From: danielvincent Date: Tue, 26 Oct 2010 16:02:53 -0700 Subject: [PATCH 11/12] settings are more restful with account settings submitting to users#update, and profile settings submitting to person#update --- app/controllers/people_controller.rb | 36 ++++++++++- app/controllers/users_controller.rb | 30 +-------- app/views/people/edit.html.haml | 67 ++++++++++++++++++++ app/views/services/index.html.haml | 4 +- app/views/users/_account.haml | 41 ------------ app/views/users/_profile.haml | 58 ----------------- app/views/users/edit.html.haml | 42 +++++++++++-- config/locales/diaspora/en.yml | 24 ++++---- config/routes.rb | 2 +- spec/controllers/people_controller_spec.rb | 33 +++++++--- spec/controllers/users_controller_spec.rb | 72 ++++++---------------- 11 files changed, 200 insertions(+), 209 deletions(-) create mode 100644 app/views/people/edit.html.haml delete mode 100644 app/views/users/_account.haml delete mode 100644 app/views/users/_profile.haml diff --git a/app/controllers/people_controller.rb b/app/controllers/people_controller.rb index 352a39c92..46230f811 100644 --- a/app/controllers/people_controller.rb +++ b/app/controllers/people_controller.rb @@ -23,8 +23,6 @@ class PeopleController < ApplicationController @profile = @person.profile @aspects_with_person = current_user.aspects_with_person(@person) @posts = current_user.visible_posts(:person_id => @person.id).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 end @@ -34,4 +32,38 @@ class PeopleController < ApplicationController respond_with :location => root_url end + def edit + @aspect = :person_edit + @person = current_user.person + @profile = @person.profile + @photos = current_user.visible_posts(:person_id => @person.id, :_type => 'Photo').paginate :page => params[:page], :order => 'created_at DESC' + end + + def update + prep_image_url(params[:person]) + + if current_user.update_profile params[:person][:profile] + flash[:notice] = "Profile updated" + else + flash[:error] = "Failed to update profile" + end + + redirect_to edit_person_path + end + + private + def prep_image_url(params) + url = APP_CONFIG[:pod_url].dup + url.chop! if APP_CONFIG[:pod_url][-1,1] == '/' + if params[:profile][:image_url].empty? + params[:profile].delete(:image_url) + else + if /^http:\/\// =~ params[:profile][:image_url] + params[:profile][:image_url] = params[:profile][:image_url] + else + params[:profile][:image_url] = url + params[:profile][:image_url] + end + end + end + end diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 9c1bb3e9c..1da5a1734 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -14,11 +14,8 @@ class UsersController < ApplicationController respond_to :html def edit - @aspect = :user_edit - @user = current_user - @person = @user.person - @profile = @user.person.profile - @photos = current_user.visible_posts(:person_id => current_user.person.id, :_type => 'Photo').paginate :page => params[:page], :order => 'created_at DESC' + @aspect = :user_edit + @user = current_user end def update @@ -32,16 +29,9 @@ class UsersController < ApplicationController else flash[:error] = "Password Change Failed" end - else - prep_image_url(params[:user]) - if @user.update_profile params[:user][:profile] - flash[:notice] = "Profile updated" - else - flash[:error] = "Failed to update profile" - end end - redirect_to edit_user_path(@user) + redirect_to edit_user_path(@user) end def destroy @@ -100,19 +90,5 @@ class UsersController < ApplicationController end - private - def prep_image_url(params) - url = APP_CONFIG[:pod_url].dup - url.chop! if APP_CONFIG[:pod_url][-1,1] == '/' - if params[:profile][:image_url].empty? - params[:profile].delete(:image_url) - else - if /^http:\/\// =~ params[:profile][:image_url] - params[:profile][:image_url] = params[:profile][:image_url] - else - params[:profile][:image_url] = url + params[:profile][:image_url] - end - end - end end diff --git a/app/views/people/edit.html.haml b/app/views/people/edit.html.haml new file mode 100644 index 000000000..8db35bb3e --- /dev/null +++ b/app/views/people/edit.html.haml @@ -0,0 +1,67 @@ +-# Copyright (c) 2010, Diaspora Inc. This file is +-# licensed under the Affero General Public License version 3 or later. See +-# the COPYRIGHT file. + + +#section_header + %h2 + Settings + %ul#settings_nav + %li=link_to 'Profile', edit_person_path(current_user.person) + %li=link_to 'Account', edit_user_path(current_user) + %li=link_to 'Services', services_path + +.span-19.prepend-5.last + %h2 Profile + = form_for @person do |person| + = person.error_messages + + = person.fields_for :profile do |p| + + %h3="#{t('.picture')}" + %div#image_picker + = p.hidden_field :image_url, :value => (@profile.image_url if @profile.image_url), :id => 'image_url_field' + + - unless @photos.nil? || @photos.empty? + - for photo in @photos + - if @profile.image_url && @profile.image_url.include?(photo.url(:thumb_medium)) + %div.small_photo{:id => photo.url(:thumb_medium), :class=>'selected'} + = check_box_tag 'checked_photo', true, true + = link_to image_tag(photo.url(:thumb_medium)), "#" + - else + %div.small_photo{:id => photo.url(:thumb_medium)} + = check_box_tag 'checked_photo' + = link_to image_tag(photo.url(:thumb_medium)), "#" + + - else + =t('.you_dont_have_any_photos') + = link_to t('.albums'), albums_path(:aspect => 'all') + =t('.page_to_upload_some') + + =will_paginate @photos + + %br + + %h3="#{t('.info')}" + + %p + %b + ="#{t('.diaspora_username')}:" + = @person.diaspora_handle + + %p + = p.label :first_name + = p.text_field :first_name, :value => @profile.first_name + %p + = p.label :last_name + = p.text_field :last_name, :value => @profile.last_name + + .submit_block + = link_to t('.cancel'), edit_user_path(current_user) + = t('.or') + = person.submit t('.update_profile') + + #content_bottom + .back + = link_to "⇧ #{t('.home')}", root_path + diff --git a/app/views/services/index.html.haml b/app/views/services/index.html.haml index 5bec55933..8d00f8eb3 100644 --- a/app/views/services/index.html.haml +++ b/app/views/services/index.html.haml @@ -6,8 +6,8 @@ %h2 Settings %ul#settings_nav - %li=link_to 'Profile', '#', :class => 'profile' - %li=link_to 'Account', '#', :class => 'account' + %li=link_to 'Profile', edit_person_path(current_user.person) + %li=link_to 'Account', edit_user_path(current_user) %li=link_to 'Services', services_path .span-19.prepend-5.last diff --git a/app/views/users/_account.haml b/app/views/users/_account.haml deleted file mode 100644 index e76ae6cc6..000000000 --- a/app/views/users/_account.haml +++ /dev/null @@ -1,41 +0,0 @@ --# Copyright (c) 2010, Diaspora Inc. This file is --# licensed under the Affero General Public License version 3 or later. See --# the COPYRIGHT file. - - -%h2 Account - -= link_to "invite friends", new_user_invitation_path(current_user) - -%br -%br -%br - -%h3 Change Password -= form_for @user do |f| - = f.error_messages - - %p - = f.label :password, "New Password" - = f.password_field :password - %p - = f.label :password_confirmation - = f.password_field :password_confirmation - - .submit_block - = link_to "Cancel", edit_user_path(current_user) - or - = f.submit 'Change password' - -%h3 Export Data -= link_to "download my xml", users_export_path, :class => "button" -= link_to "download my photos", users_export_photos_path, :class => "button" - -%br -%br -%br - -%h3 Close Account -= link_to "Close Account", current_user, - :confirm => "Are you sure?", :method => :delete, - :class => "button" diff --git a/app/views/users/_profile.haml b/app/views/users/_profile.haml deleted file mode 100644 index cbb2b6d6a..000000000 --- a/app/views/users/_profile.haml +++ /dev/null @@ -1,58 +0,0 @@ --# Copyright (c) 2010, Diaspora Inc. This file is --# licensed under the Affero General Public License version 3 or later. See --# the COPYRIGHT file. - - -%h2 Profile -= form_for @user do |f| - = f.error_messages - - = f.fields_for :profile do |p| - - %h3="#{t('.picture')}" - %div#image_picker - = p.hidden_field :image_url, :value => (@profile.image_url if @profile.image_url), :id => 'image_url_field' - - - unless @photos.nil? || @photos.empty? - - for photo in @photos - - if @profile.image_url && @profile.image_url.include?(photo.url(:thumb_medium)) - %div.small_photo{:id => photo.url(:thumb_medium), :class=>'selected'} - = check_box_tag 'checked_photo', true, true - = link_to image_tag(photo.url(:thumb_medium)), "#" - - else - %div.small_photo{:id => photo.url(:thumb_medium)} - = check_box_tag 'checked_photo' - = link_to image_tag(photo.url(:thumb_medium)), "#" - - - else - =t('.you_dont_have_any_photos') - = link_to t('.albums'), albums_path(:aspect => 'all') - =t('.page_to_upload_some') - - =will_paginate @photos - - %br - - %h3="#{t('.info')}" - - %p - %b - ="#{t('.diaspora_username')}:" - = @user.diaspora_handle - - %p - = p.label :first_name - = p.text_field :first_name, :value => @profile.first_name - %p - = p.label :last_name - = p.text_field :last_name, :value => @profile.last_name - - .submit_block - = link_to t('.cancel'), edit_user_path(current_user) - = t('.or') - = f.submit t('.update_profile') - -#content_bottom - .back - = link_to "⇧ #{t('.home')}", root_path - diff --git a/app/views/users/edit.html.haml b/app/views/users/edit.html.haml index 104a9e8fd..5317a5095 100644 --- a/app/views/users/edit.html.haml +++ b/app/views/users/edit.html.haml @@ -16,14 +16,44 @@ %h2 Settings %ul#settings_nav - %li=link_to 'Profile', '#', :class => 'profile' - %li=link_to 'Account', '#', :class => 'account' + %li=link_to 'Profile', edit_person_path(current_user.person) + %li=link_to 'Account', edit_user_path(current_user) %li=link_to 'Services', services_path .span-19.prepend-5.last - #profile.settings_pane{:style=>"display:block;"} - = render 'users/profile' + %h2 Account - #account.settings_pane - = render 'users/account' + = link_to "invite friends", new_user_invitation_path(current_user) + %br + %br + %br + + %h3 Change Password + = form_for @user do |f| + = f.error_messages + + %p + = f.label :password, "New Password" + = f.password_field :password + %p + = f.label :password_confirmation + = f.password_field :password_confirmation + + .submit_block + = link_to "Cancel", edit_user_path(current_user) + or + = f.submit 'Change password' + + %h3 Export Data + = link_to "download my xml", users_export_path, :class => "button" + = link_to "download my photos", users_export_photos_path, :class => "button" + + %br + %br + %br + + %h3 Close Account + = link_to "Close Account", current_user, + :confirm => "Are you sure?", :method => :delete, + :class => "button" diff --git a/config/locales/diaspora/en.yml b/config/locales/diaspora/en.yml index 101080ef8..91b80deab 100644 --- a/config/locales/diaspora/en.yml +++ b/config/locales/diaspora/en.yml @@ -116,18 +116,6 @@ en: users: edit: editing_profile: "Editing profile" - profile: - cancel: "Cancel" - update_profile: "Update Profile" - home: "Home" - diaspora_username: "DIASPORA USERNAME" - info: "Info" - picture: "Picture" - editing_profile: "Editing profile" - albums: "Albums" - you_dont_have_any_photos: "You don't have any photos! Go to the" - page_to_upload_some: "page to upload some." - or: "or" destroy: "Account successfully closed." comments: comment: @@ -218,6 +206,18 @@ en: are_you_sure: "Are you sure?" remove_friend: "remove friend" no_posts: "no posts to display!" + edit: + cancel: "Cancel" + update_profile: "Update Profile" + home: "Home" + diaspora_username: "DIASPORA USERNAME" + info: "Info" + picture: "Picture" + editing_profile: "Editing profile" + albums: "Albums" + you_dont_have_any_photos: "You don't have any photos! Go to the" + page_to_upload_some: "page to upload some." + or: "or" requests: new_request: add_a_new_friend_to: "Add a new friend to" diff --git a/config/routes.rb b/config/routes.rb index b9b05ca65..e46a65b0a 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -3,7 +3,7 @@ # the COPYRIGHT file. Diaspora::Application.routes.draw do - resources :people, :only => [:index, :show, :destroy] + resources :people resources :status_messages, :only => [:create, :destroy, :show] resources :comments, :except => [:index] resources :requests, :except => [:edit, :update] diff --git a/spec/controllers/people_controller_spec.rb b/spec/controllers/people_controller_spec.rb index 26bf2a804..64e10b94e 100644 --- a/spec/controllers/people_controller_spec.rb +++ b/spec/controllers/people_controller_spec.rb @@ -6,22 +6,22 @@ require 'spec_helper' describe PeopleController do render_views - before do - @user = Factory.create(:user) - sign_in :user, @user - @user.aspect(:name => "lame-os") + let(:user) { Factory(:user) } + let!(:aspect) { user.aspect(:name => "lame-os") } + + before do + sign_in :user, user end it "index should yield search results for substring of person name" do - eugene = Factory.create(:person, :profile => {:first_name => "Eugene", :last_name => "w"}) get :index, :q => "Eu" assigns[:people].should include eugene end it 'should go to the current_user show page' do - get :show, :id => @user.person.id + get :show, :id => user.person.id end it "doesn't error out on an invalid id" do @@ -29,6 +29,25 @@ describe PeopleController do end it "doesn't error out on a nonexistent person" do - get :show, :id => @user.id + get :show, :id => user.id + end + + describe '#update' do + context 'with a profile photo set' do + it "doesn't overwrite the profile photo when an empty string is passed in" do + user.person.profile.image_url = "http://tom.joindiaspora.com/images/user/tom.jpg" + user.person.profile.save + + params = {"profile"=> + {"image_url" => "", + "last_name" => user.person.profile.last_name, + "first_name" => user.person.profile.first_name}} + + image_url = user.person.profile.image_url + put("update", :id => user.person.id, "person" => params) + + user.person.profile.image_url.should == image_url + end + end end end diff --git a/spec/controllers/users_controller_spec.rb b/spec/controllers/users_controller_spec.rb index f00a519db..93790c681 100644 --- a/spec/controllers/users_controller_spec.rb +++ b/spec/controllers/users_controller_spec.rb @@ -5,10 +5,14 @@ require 'spec_helper' describe UsersController do + + let(:user) { Factory(:user) } + let!(:aspect) { user.aspect(:name => "lame-os") } + + let!(:old_password) { user.encrypted_password } + before do - @user = Factory.create(:user) - sign_in :user, @user - @user.aspect(:name => "lame-os") + sign_in :user, user end describe '#export' do @@ -18,67 +22,29 @@ describe UsersController do end end - describe '#update' do - context 'with a profile photo set' do - before do - @user.person.profile.image_url = "http://tom.joindiaspora.com/images/user/tom.jpg" - @user.person.profile.save - - @params = {"profile"=> - {"image_url" => "", - "last_name" => @user.person.profile.last_name, - "first_name" => @user.person.profile.first_name}} - end - - it "doesn't overwrite the profile photo when an empty string is passed in" do - image_url = @user.person.profile.image_url - put("update", :id => @user.id, "user" => @params) - - @user.person.profile.image_url.should == image_url - end - it "doesn't overwrite random attributes" do - new_user = Factory.create(:user) - @params[:owner_id] = new_user.id - person = @user.person - put('update', :id => @user.id, "user" => @params) - Person.find(person.id).owner_id.should == @user.id - end + it "doesn't overwrite random attributes" do + params = {:diaspora_handle => "notreal@stuff.com"} + proc{ put 'update', :id => user.id, "user" => params }.should_not change(user, :diaspora_handle) end context 'should allow the user to update their password' do it 'should change a users password ' do - old_password = @user.encrypted_password - - put("update", :id => @user.id, "user"=> {"password" => "foobaz", 'password_confirmation' => "foobaz","profile"=> - {"image_url" => "", - "last_name" => @user.person.profile.last_name, - "first_name" => @user.person.profile.first_name}}) - - @user.reload - @user.encrypted_password.should_not == old_password + put("update", :id => user.id, "user"=> {"password" => "foobaz", 'password_confirmation' => "foobaz"}) + user.reload + user.encrypted_password.should_not == old_password end it 'should not change a password if they do not match' do - old_password = @user.encrypted_password - put("update", :id => @user.id, "user"=> {"password" => "foobarz", 'password_confirmation' => "not_the_same","profile"=> - {"image_url" => "", - "last_name" => @user.person.profile.last_name, - "first_name" => @user.person.profile.first_name}}) - @user.reload - @user.encrypted_password.should == old_password + put("update", :id => user.id, "user"=> {"password" => "foobarz", 'password_confirmation' => "not_the_same"}) + user.reload + user.encrypted_password.should == old_password end - it 'should not update if the password fields are left blank' do - - old_password = @user.encrypted_password - put("update", :id => @user.id, "user"=> {"password" => "", 'password_confirmation' => "","profile"=> - {"image_url" => "", - "last_name" => @user.person.profile.last_name, - "first_name" => @user.person.profile.first_name}}) - @user.reload - @user.encrypted_password.should == old_password + put("update", :id => user.id, "user"=> {"password" => "", 'password_confirmation' => ""}) + user.reload + user.encrypted_password.should == old_password end end end From e62afae045088b6e9397041688238928a422bf03 Mon Sep 17 00:00:00 2001 From: danielvincent Date: Tue, 26 Oct 2010 16:12:58 -0700 Subject: [PATCH 12/12] deselected tabs in top nav, made user drop down a bit clearer --- app/views/layouts/application.html.haml | 5 +++-- public/stylesheets/sass/application.sass | 3 +++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index 0e21eb7de..7f6cf94cf 100644 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml @@ -55,8 +55,9 @@ .avatar = owner_image_tag = link_to current_user.real_name, '#' - %li= link_to "profile", current_user.person - %li= link_to "settings", edit_user_path(current_user) + %li= link_to "view profile", current_user.person + %li= link_to "edit profile", edit_person_path(current_user.person) + %li= link_to "account settings", edit_user_path(current_user) %li= link_to t('.logout.'), destroy_user_session_path = render "shared/aspect_nav" diff --git a/public/stylesheets/sass/application.sass b/public/stylesheets/sass/application.sass index c4da5d4fc..739a0ffac 100644 --- a/public/stylesheets/sass/application.sass +++ b/public/stylesheets/sass/application.sass @@ -855,6 +855,9 @@ h1.big_text :padding 4px 10px :color #CCC + :background + :color #222 + &:hover :background :color #000