From 469d5b99a2b04b7d2bc4c7eaa2be4c11bea7a67f Mon Sep 17 00:00:00 2001
From: zhitomirskiyi <ilya@joindiaspora.com>
Date: Mon, 9 May 2011 16:55:22 -0700
Subject: [PATCH] WIP added a share view, tests are red

---
 app/controllers/contacts_controller.rb       |  4 +++
 app/views/aspects/_aspect_listings.haml      |  4 +--
 app/views/contacts/sharing.haml              | 28 ++++++++++++++++++++
 config/locales/diaspora/en.yml               |  5 ++--
 config/routes.rb                             |  1 +
 spec/controllers/contacts_controller_spec.rb | 12 +++++++++
 6 files changed, 50 insertions(+), 4 deletions(-)
 create mode 100644 app/views/contacts/sharing.haml

diff --git a/app/controllers/contacts_controller.rb b/app/controllers/contacts_controller.rb
index d7ab53155a..ce464b53e5 100644
--- a/app/controllers/contacts_controller.rb
+++ b/app/controllers/contacts_controller.rb
@@ -37,4 +37,8 @@ class ContactsController < ApplicationController
     redirect_to contact.person
   end
 
+  def sharing
+    @contacts = current_user.contacts.sharing
+    #render :nothing => true
+  end
 end
diff --git a/app/views/aspects/_aspect_listings.haml b/app/views/aspects/_aspect_listings.haml
index 7081b1c9fc..8a08fa7ccd 100644
--- a/app/views/aspects/_aspect_listings.haml
+++ b/app/views/aspects/_aspect_listings.haml
@@ -16,9 +16,9 @@
     %li{:class => ("dull" if @contacts_sharing_with.size == 0)}
       .right
         %b
-          = link_to t('contacts', :count => @contacts_sharing_with.size), edit_aspect_path(aspect), :rel => 'facebox', :class => 'contact-count'
+          = link_to t('contacts', :count => @contacts_sharing_with.size), contacts_sharing_path, :rel => 'facebox', :class => 'contact-count'
       %b
-        People sharing with you
+        = t('aspects.index.people_sharing_with_you')
       %br
 
       - if @contacts_sharing_with.size > 0
diff --git a/app/views/contacts/sharing.haml b/app/views/contacts/sharing.haml
new file mode 100644
index 0000000000..1d5d79597b
--- /dev/null
+++ b/app/views/contacts/sharing.haml
@@ -0,0 +1,28 @@
+-#   Copyright (c) 2010, Diaspora Inc.  This file is
+-#   licensed under the Affero General Public License version 3 or later.  See
+-#   the COPYRIGHT file.
+
+%h4
+  .right
+    = link_to t('contacts', :count => @contact_count), manage_aspects_path, :title => t('aspects.manage.manage_aspects')
+
+  = t('aspects', :count => aspects.count)
+
+%ul
+
+/ - for aspect in aspects
+/   = render 'aspects/aspect', :aspect => aspect, :contacts => aspect.contacts
+
+/ - if @contacts_sharing_with
+/   %li{:class => ("dull" if @contacts_sharing_with.size == 0)}
+/     .right
+/       %b
+/         = link_to t('contacts', :count => @contacts_sharing_with.size), edit_aspect_path("followers"), :rel => 'facebox', :class => 'contact-count'
+/     %b
+/       = t('aspects.index.people_sharing_with_you')
+/     %br
+
+/     - if @contacts_sharing_with.size > 0
+/       .contacts
+/         - for contact in @contacts_sharing_with[0..15]
+/           = person_image_link(contact.person)
diff --git a/config/locales/diaspora/en.yml b/config/locales/diaspora/en.yml
index 0711255634..4722bdd6d7 100644
--- a/config/locales/diaspora/en.yml
+++ b/config/locales/diaspora/en.yml
@@ -140,6 +140,7 @@ en:
       handle_explanation: "This is your diaspora handle. Like an email address, you can give this to people to reach you."
       no_contacts: "No contacts"
       post_a_message: "post a message >>"
+      people_sharing_with_you: "People sharing with you"
 
   aspect_memberships:
     destroy:
@@ -547,9 +548,9 @@ en:
       invitations_left: "(%{count} left)"
       dont_have_now: "You don't have any right now, but more invites are coming soon!"
       invites_closed: "Invites are currently closed on this Diaspora pod"
-      invite_your_friends: "Find your friends"
+      invite_your_friends: "Invite your friends"
       from_facebook: "From Facebook"
-      by_email: "by Email"
+      by_email: "via Email"
     reshare:
       reshare: "Reshare"
     public_explain:
diff --git a/config/routes.rb b/config/routes.rb
index 3160ab45a6..c97396ac54 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -69,6 +69,7 @@ Diaspora::Application.routes.draw do
 
   resource :profile
 
+  get 'contacts/sharing' => 'contacts#sharing'
   resources :contacts,           :except => [:index, :update, :create]
   resources :aspect_memberships, :only   => [:destroy, :create, :update]
   resources :post_visibilities,  :only   => [:update]
diff --git a/spec/controllers/contacts_controller_spec.rb b/spec/controllers/contacts_controller_spec.rb
index 22b9ba6caa..ddd3cf66a6 100644
--- a/spec/controllers/contacts_controller_spec.rb
+++ b/spec/controllers/contacts_controller_spec.rb
@@ -63,4 +63,16 @@ describe ContactsController do
       response.should redirect_to(@contact.person)
     end
   end
+
+  describe '#sharing' do
+    it "succeeds" do
+      get :sharing
+      response.should be_success
+    end
+
+    it "assigns only the people sharing with you with 'share_with' flag" do
+      get :sharing, :id => 'share_with'
+      assigns[:contacts].to_set.should == alice.contacts.sharing.to_set
+    end
+  end
 end
-- 
GitLab