link a user to featured users if user has zero contacts

This commit is contained in:
danielgrippi 2011-08-01 14:42:25 -07:00
parent 3d88095ba2
commit 756a20ecd4
7 changed files with 56 additions and 8 deletions

View file

@ -3,9 +3,6 @@
# the COPYRIGHT file. # the COPYRIGHT file.
module ApplicationHelper module ApplicationHelper
def how_long_ago(obj) def how_long_ago(obj)
timeago(obj.created_at) timeago(obj.created_at)
end end
@ -122,4 +119,12 @@ module ApplicationHelper
t('aspects.index.your_aspects') t('aspects.index.your_aspects')
end end
end end
def contacts_link
if current_user.contacts.size > 0
contacts_path
else
featured_users_path
end
end
end end

View file

@ -8,6 +8,6 @@
%br %br
%br %br
= t('.try_adding_some_more_contacts') = t('.try_adding_some_more_contacts')
!= t('.or_featured', :link => link_to(t(".featured_users") , featured_path)) != t('.or_featured', :link => link_to(t(".featured_users") , featured_users_path))

View file

@ -13,11 +13,11 @@
= person_image_link person = person_image_link person
- if all_aspects_selected? || @aspect_ids.size > 1 - if all_aspects_selected? || @aspect_ids.size > 1
= link_to t('.view_all_contacts'), contacts_path, :id => "view_all_contacts_link" = link_to t('.view_all_contacts'), contacts_link, :id => "view_all_contacts_link"
- else - else
= link_to t('.view_all_contacts'), contacts_path(:a_id => @aspect.id), :id => "view_all_contacts_link" = link_to t('.view_all_contacts'), contacts_path(:a_id => @aspect.id), :id => "view_all_contacts_link"
- else - else
= t('.no_contacts') = t('.no_contacts')
= link_to t('.manage_your_aspects'), contacts_path = link_to t('.manage_your_aspects'), contacts_link

View file

@ -28,7 +28,7 @@
= image_tag 'icons/home_grey.svg', :height => 16 = image_tag 'icons/home_grey.svg', :height => 16
#contacts_badge.badge #contacts_badge.badge
= link_to contacts_path, :title => t('_contacts') do = link_to contacts_link, :title => t('_contacts') do
= image_tag 'icons/contacts_grey.svg', :height => 16 = image_tag 'icons/contacts_grey.svg', :height => 16
#notification_badge.badge #notification_badge.badge

View file

@ -101,7 +101,7 @@ Diaspora::Application.routes.draw do
resources :aspect_memberships, :only => [:destroy, :create, :update] resources :aspect_memberships, :only => [:destroy, :create, :update]
resources :post_visibilities, :only => [:update] resources :post_visibilities, :only => [:update]
get 'featured' => "contacts#featured" get 'featured' => "contacts#featured", :as => 'featured_users'
resources :people, :except => [:edit, :update] do resources :people, :except => [:edit, :update] do
resources :status_messages resources :status_messages
resources :photos resources :photos

View file

@ -46,3 +46,28 @@ Feature: User manages contacts
When I scroll down When I scroll down
Then I should see 60 contacts Then I should see 60 contacts
Scenario: clicking on the contacts link in the header with zero contacts directs a user to the featured users page
Given I am signed in
And I have 0 contacts
And I am on the home page
When I follow "Contacts"
Then I should see "Featured Users" within ".span-18"
Scenario: clicking on the manage aspects link in the right nav with zero contacts directs a user to the featured users page
Given I am signed in
And I have 0 contacts
And I am on the home page
When I follow "Manage your aspects."
Then I should see "Featured Users" within ".span-18"
Scenario: clicking on the contacts link in the header with contacts does not send a user to the featured users page
Given I am signed in
And I have 2 contacts
And I am on the home page
When I follow "Contacts"
Then I should not see "Featured Users" within "#section_header"

View file

@ -59,4 +59,22 @@ describe ApplicationHelper do
person_link(@person).should_not include("<h1>") person_link(@person).should_not include("<h1>")
end end
end end
describe "#contacts_link" do
before do
def current_user
@current_user
end
end
it 'links to featured users' do
@current_user = Factory(:user)
contacts_link.should == featured_users_path
end
it 'links to contacts#index' do
@current_user = alice
contacts_link.should == contacts_path
end
end
end end