diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 8c362c384..ab99b20a7 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -3,9 +3,6 @@ # the COPYRIGHT file. module ApplicationHelper - - - def how_long_ago(obj) timeago(obj.created_at) end @@ -122,4 +119,12 @@ module ApplicationHelper t('aspects.index.your_aspects') end end + + def contacts_link + if current_user.contacts.size > 0 + contacts_path + else + featured_users_path + end + end end diff --git a/app/views/aspects/_no_posts_message.haml b/app/views/aspects/_no_posts_message.haml index 66e89231b..c31e6a7cc 100644 --- a/app/views/aspects/_no_posts_message.haml +++ b/app/views/aspects/_no_posts_message.haml @@ -8,6 +8,6 @@ %br %br = 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)) diff --git a/app/views/aspects/_selected_contacts.html.haml b/app/views/aspects/_selected_contacts.html.haml index 621dc1fb5..83af077cb 100644 --- a/app/views/aspects/_selected_contacts.html.haml +++ b/app/views/aspects/_selected_contacts.html.haml @@ -13,11 +13,11 @@ = person_image_link person - 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 = link_to t('.view_all_contacts'), contacts_path(:a_id => @aspect.id), :id => "view_all_contacts_link" - else = t('.no_contacts') - = link_to t('.manage_your_aspects'), contacts_path + = link_to t('.manage_your_aspects'), contacts_link diff --git a/app/views/layouts/_header.html.haml b/app/views/layouts/_header.html.haml index 069caa9d6..2d8cdd5e9 100644 --- a/app/views/layouts/_header.html.haml +++ b/app/views/layouts/_header.html.haml @@ -28,7 +28,7 @@ = image_tag 'icons/home_grey.svg', :height => 16 #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 #notification_badge.badge diff --git a/config/routes.rb b/config/routes.rb index 6f16d6967..48ed744b7 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -101,7 +101,7 @@ Diaspora::Application.routes.draw do resources :aspect_memberships, :only => [:destroy, :create, :update] resources :post_visibilities, :only => [:update] - get 'featured' => "contacts#featured" + get 'featured' => "contacts#featured", :as => 'featured_users' resources :people, :except => [:edit, :update] do resources :status_messages resources :photos diff --git a/features/manages_aspects.feature b/features/manages_aspects.feature index aaec94827..f5d028254 100644 --- a/features/manages_aspects.feature +++ b/features/manages_aspects.feature @@ -46,3 +46,28 @@ Feature: User manages contacts When I scroll down 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" diff --git a/spec/helpers/application_helper_spec.rb b/spec/helpers/application_helper_spec.rb index 4901f09d6..fd05d3631 100644 --- a/spec/helpers/application_helper_spec.rb +++ b/spec/helpers/application_helper_spec.rb @@ -59,4 +59,22 @@ describe ApplicationHelper do person_link(@person).should_not include("

") 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