From 3c82af49bfd38c9fc9d5c10e86d643833a7f3385 Mon Sep 17 00:00:00 2001
From: danielgrippi <danielgrippi@gmail.com>
Date: Thu, 12 May 2011 14:11:52 -0700
Subject: [PATCH] fixed cucumber with an exception of one step.  added
 dropdowns to tag pages

---
 app/controllers/aspects_controller.rb         |  4 +-
 app/controllers/photos_controller.rb          |  2 +-
 app/controllers/tags_controller.rb            |  2 +-
 app/views/contacts/_aspect_dropdown.html.haml |  4 +-
 app/views/contacts/sharing.haml               |  2 +-
 app/views/people/_profile_sidebar.html.haml   |  2 +-
 app/views/tags/show.haml                      |  6 ++-
 features/connects_users.feature               | 45 +++++++------------
 features/disconnects_users.feature            |  4 +-
 features/step_definitions/custom_web_steps.rb | 20 +++++++--
 features/tags.feature                         | 10 ++---
 11 files changed, 50 insertions(+), 51 deletions(-)

diff --git a/app/controllers/aspects_controller.rb b/app/controllers/aspects_controller.rb
index 5f94e07f90..c26e20c4ce 100644
--- a/app/controllers/aspects_controller.rb
+++ b/app/controllers/aspects_controller.rb
@@ -156,8 +156,7 @@ class AspectsController < ApplicationController
     params[:max_time] ||= Time.now + 1
   end
 
-  protected
-
+  private
   def save_sort_order
     if params[:sort_order].present?
       session[:sort_order] = (params[:sort_order] == 'created_at') ? 'created_at' : 'updated_at'
@@ -167,4 +166,5 @@ class AspectsController < ApplicationController
       session[:sort_order] = (session[:sort_order] == 'created_at') ? 'created_at' : 'updated_at'
     end
   end
+
 end
diff --git a/app/controllers/photos_controller.rb b/app/controllers/photos_controller.rb
index b7eaeaf60b..49adb50779 100644
--- a/app/controllers/photos_controller.rb
+++ b/app/controllers/photos_controller.rb
@@ -3,7 +3,7 @@
 #   the COPYRIGHT file.
 
 class PhotosController < ApplicationController
-  helper :comments
+  helper :comments, :aspects
   before_filter :authenticate_user!
 
   respond_to :html, :json
diff --git a/app/controllers/tags_controller.rb b/app/controllers/tags_controller.rb
index a867e41e95..dbf1bb32a2 100644
--- a/app/controllers/tags_controller.rb
+++ b/app/controllers/tags_controller.rb
@@ -3,7 +3,7 @@
 #   the COPYRIGHT file.
 
 class TagsController < ApplicationController
-  helper :comments
+  helper :comments, :aspects
   skip_before_filter :set_invites
   skip_before_filter :which_action_and_user
   skip_before_filter :set_grammatical_gender
diff --git a/app/views/contacts/_aspect_dropdown.html.haml b/app/views/contacts/_aspect_dropdown.html.haml
index 6358a119f0..799bf50d21 100644
--- a/app/views/contacts/_aspect_dropdown.html.haml
+++ b/app/views/contacts/_aspect_dropdown.html.haml
@@ -11,9 +11,9 @@
     %ul.dropdown_list{:unSelectable => 'on'}
       - for aspect in @all_aspects
         %li{:data => {:aspect_id => aspect.id}}
-          = check_box_tag "in_aspect", "in_aspect", aspect.contacts.include?(contact)
+          = check_box_tag "in_aspect", "in_aspect", (contact.persisted? && aspect.contacts.include?(contact))
           = aspect.name
 
           .hidden
-            = aspect_membership_button(aspect, contact, contact.person)
+            = aspect_membership_button(aspect, contact, person)
 
diff --git a/app/views/contacts/sharing.haml b/app/views/contacts/sharing.haml
index 1522d1300a..89f5c5d73f 100644
--- a/app/views/contacts/sharing.haml
+++ b/app/views/contacts/sharing.haml
@@ -26,7 +26,7 @@
                 = contact.person.diaspora_handle
 
             .right
-              = render 'aspect_dropdown', :contact => contact, :hang => 'right'
+              = render 'aspect_dropdown', :contact => contact, :person => contact.person, :hang => 'right'
 
   %br
   %div{:style => "text-align:right;"}
diff --git a/app/views/people/_profile_sidebar.html.haml b/app/views/people/_profile_sidebar.html.haml
index f22bc62389..3b97e232e5 100644
--- a/app/views/people/_profile_sidebar.html.haml
+++ b/app/views/people/_profile_sidebar.html.haml
@@ -26,7 +26,7 @@
       %hr{:style=>"width:300px;"}
 
     %br
-    = render 'contacts/aspect_dropdown', :contact => @contact, :hang => 'left'
+    = render 'contacts/aspect_dropdown', :contact => @contact, :person => @person, :hang => 'left'
       
     -if contact.sharing? || person == current_user.person
       %br
diff --git a/app/views/tags/show.haml b/app/views/tags/show.haml
index fd6777f23a..8802710162 100644
--- a/app/views/tags/show.haml
+++ b/app/views/tags/show.haml
@@ -36,8 +36,10 @@
       .stream_element{:id => person.id}
         = person_image_link(person)
         - if current_user
-          = render :partial => 'people/add_contact_small',
-                   :locals => { :person => person }
+          - contact = current_user.contacts.find_by_person_id(person.id)
+          - contact ||= Contact.new(:person => person)
+          = render 'contacts/aspect_dropdown', :contact => contact, :person => person, :hang => 'left'
+
         .content
           %span.from
             =person_link(person)
diff --git a/features/connects_users.feature b/features/connects_users.feature
index de1cfad1d6..03b3cb2516 100644
--- a/features/connects_users.feature
+++ b/features/connects_users.feature
@@ -7,9 +7,7 @@ Feature: sending and receiving requests
     When I sign in as "bob@bob.bob"
     And I am on "alice@alice.alice"'s page
 
-    And I press the first ".share_with.button"
-    And I wait for the ajax to finish
-    And I add the person to my first aspect
+    And I add the person to my 1st aspect
 
     And I am on the home page
     Given I expand the publisher
@@ -45,11 +43,9 @@ Feature: sending and receiving requests
   Scenario: mutual following the original follower should see private posts on their stream
     When I sign in as "alice@alice.alice"
     And I am on "bob@bob.bob"'s page
-    And I press the 1st ".share_with.button" within "#author_info"
-    And I press the 1st ".add.button" within "#facebox #aspects_list ul > li:first-child"
-    And I wait for the ajax to finish
-    And I press the 1st ".add.button" within "#facebox #aspects_list ul > li:nth-child(2)"
-    And I wait for the ajax to finish
+
+    And I add the person to my 1st aspect
+    And I add the person to my 2nd aspect
 
     When I go to the home page
     Then I go to the manage aspects page
@@ -73,7 +69,9 @@ Feature: sending and receiving requests
   Scenario: following a contact request into a new aspect
     When I sign in as "alice@alice.alice"
     And I am on "bob@bob.bob"'s page
+
     And I press the first ".share_with.button" within "#author_info"
+    
     And I fill in "Name" with "Super People" in the modal window
     And I press "aspect_submit" in the modal window
     And I wait for the ajax to finish
@@ -87,41 +85,32 @@ Feature: sending and receiving requests
    And I am on the manage aspects page
    Then I should see 1 contact in "Besties"
 
-  Scenario: should not see start sharing and see mention if already a follower
+  Scenario: should not see "Add to aspect" and see mention if already a follower
     When I sign in as "bob@bob.bob"
     And I am on "alice@alice.alice"'s page
 
-    Then I should not see "start sharing"
-    Then I should see "edit aspect membership"
+    Then I should see "In 1 aspect"
     Then I should see "Mention"
     Then I should not see "Message"
 
-    Then I should not see "is sharing with you."
-
-  Scenario: should see start sharing and not see mention if on a follower's page
+  Scenario: should see "Add to aspect" and not see mention if on a follower's page
     When I sign in as "alice@alice.alice"
     And I am on "bob@bob.bob"'s page
 
-    Then I should see "start sharing"
-    Then I should not see "edit aspect membership"
+    Then I should not see /^In \d aspects?$/
     Then I should not see "Mention"
     Then I should not see "Message"
 
-    Then I should see "is sharing with you."
-
-  Scenario: should see start sharing & mention & message on mutual contacts
+  Scenario: should see "Add to aspect" & mention & message on mutual contacts
     When I sign in as "alice@alice.alice"
     And I am on "bob@bob.bob"'s page
-    And I press the 1st ".share_with.button" within "#author_info"
-    And I press the 1st ".add.button" within "#facebox #aspects_list ul > li:first-child"
-    And I wait for the ajax to finish
-    And I press the 1st ".add.button" within "#facebox #aspects_list ul > li:nth-child(2)"
-    And I wait for the ajax to finish
+
+    And I add the person to my 1st aspect
+    And I add the person to my 2nd aspect
+
     And I am on "bob@bob.bob"'s page
 
-    Then I should not see "start sharing"
-    Then I should see "edit aspect membership"
+    Then I should not see "Add to aspect"
+    Then I should see "In 2 aspects"
     Then I should see "Mention"
     Then I should see "Message"
-
-    Then I should see "is sharing with you."
diff --git a/features/disconnects_users.feature b/features/disconnects_users.feature
index a8fb4e074c..c76de8afc3 100644
--- a/features/disconnects_users.feature
+++ b/features/disconnects_users.feature
@@ -10,9 +10,7 @@ Feature: disconnecting users
     When I sign in as "bob@bob.bob"
     And I am on "alice@alice.alice"'s page
 
-    And I press the first ".share_with.button"
-    And I wait for the ajax to finish
-    And I add the person to my first aspect
+    And I add the person to my 1st aspect
 
   Scenario Outline: remove non-mutual contact from the contact show page
    When I am on "alice@alice.alice"'s page
diff --git a/features/step_definitions/custom_web_steps.rb b/features/step_definitions/custom_web_steps.rb
index 7a8377a34b..794977890e 100644
--- a/features/step_definitions/custom_web_steps.rb
+++ b/features/step_definitions/custom_web_steps.rb
@@ -159,11 +159,25 @@ Then /^I should( not)? see the contact dialog$/ do |not_see|
   end
 end
 
-When /^I add the person to my first aspect$/ do
+When /^I add the person to my ([\d])(nd|rd|st|th) aspect$/ do |aspect_number, nd|
   steps %Q{
-    And I press the first ".add.button" within "#facebox #aspects_list ul > li:first-child"
+    And I press the first ".toggle.button"
+    And I press the #{aspect_number}#{nd} "li" within ".dropdown.active .dropdown_list"
     And I wait for the ajax to finish
-    Then I should see a ".added.button" within "#facebox #aspects_list ul > li:first-child"
+    And I press the first ".toggle.button"
+  }
+end
+
+When /^I add the person to a new aspect called "([^\"]*)"$/ do |aspect_name|
+  steps %Q{
+    And I press the first ".toggle.button"
+
+    And I press click ".new_aspect" within ".dropdown.active"
+    And I fill in "#aspect_name" with "#{aspect_name}"
+    And I submit the form
+
+    And I wait for the ajax to finish
+    And I press the first ".toggle.button"
   }
 end
 
diff --git a/features/tags.feature b/features/tags.feature
index ba9bebf27a..cd0f23d4f8 100644
--- a/features/tags.feature
+++ b/features/tags.feature
@@ -13,13 +13,9 @@ Feature: Interacting with tags
 
   Scenario: adding a contact from a tag page
     When I search for "#rockstar"
-    Then I should see an add contact button
+    Then I should see "Add to aspect"
 
-    When I click on the add contact button
-    Then I should see the contact dialog
-    When I add the person to my first aspect
-    And I follow "done editing"
-    Then I should not see the contact dialog
+    When I add the person to my 1st aspect
 
     When I search for "#rockstar"
-    Then I should not see an add contact button
+    Then I should see "In 1 aspect"
-- 
GitLab