diff --git a/Changelog.md b/Changelog.md index 3a0bf3ce8c21f2e9250213859132f7ec375a811a..a66bb3ffdf17058dce07240967bdca5c3b6a556b 100644 --- a/Changelog.md +++ b/Changelog.md @@ -18,6 +18,7 @@ * Unify desktop and mobile head elements [#7194](https://github.com/diaspora/diaspora/pull/7194) * Refactor flash messages on ajax errors for comments, likes, reshares and aspect memberships [#7202](https://github.com/diaspora/diaspora/pull/7202) * Only require AWS-module for fog [#7201](https://github.com/diaspora/diaspora/pull/7201) +* Only show community spotlight links on the contacts page if community spotlight is enabled [#7213](https://github.com/diaspora/diaspora/pull/7213) ## Bug fixes * Fix fetching comments after fetching likes [#7167](https://github.com/diaspora/diaspora/pull/7167) diff --git a/app/views/contacts/index.html.haml b/app/views/contacts/index.html.haml index df7a58a74ca30219b883f0bb698ba9695306affa..a4fc8da4e97b73e6b91259bb4a77d94384b47af5 100644 --- a/app/views/contacts/index.html.haml +++ b/app/views/contacts/index.html.haml @@ -1,5 +1,5 @@ - content_for :page_title do - = t('.title') + = t(".title") .container-fluid#contacts_container .row @@ -9,25 +9,26 @@ .col-md-9 .stream.contacts.framed-content#people_stream - = render 'contacts/header' + = render "contacts/header" - if @contacts_size > 0 - if @aspect && @aspect.contacts.length == 0 .well - = t('.no_contacts_in_aspect') + = t(".no_contacts_in_aspect") #contact_stream -# JS - else .no_contacts %h3 - = t('.no_contacts') + = t(".no_contacts") + - if AppConfig.settings.community_spotlight.enable? + %p + != t(".no_contacts_message", + community_spotlight: link_to(t(".community_spotlight"), community_spotlight_path)) %p - != t('.no_contacts_message', - :community_spotlight => link_to(t('.community_spotlight'), community_spotlight_path)) - %p - .btn.btn-link{ 'data-toggle' => 'modal' } - = t('invitations.new.invite_someone_to_join') + .btn.btn-link{"data-toggle" => "modal"} + = t("invitations.new.invite_someone_to_join") #paginate .loader.hidden @@ -35,7 +36,7 @@ -if @aspect .conversations-form-container#new_conversation_pane - = render 'shared/modal', - :path => new_conversation_path(:aspect_id => @aspect.id, :name => @aspect.name, :modal => true), - :title => t('conversations.index.new_conversation'), - :id => 'conversationModal' + = render "shared/modal", + path: new_conversation_path(aspect_id: @aspect.id, name: @aspect.name, modal: true), + title: t("conversations.index.new_conversation"), + id: "conversationModal" diff --git a/features/desktop/manages_aspects.feature b/features/desktop/manages_aspects.feature index 30770b6689374b086b19764e4bf820bd43552203..2cc05e46e29431b372ddf067ca952e66c102ef0b 100644 --- a/features/desktop/manages_aspects.feature +++ b/features/desktop/manages_aspects.feature @@ -61,20 +61,6 @@ Feature: User manages contacts And I press "Update" Then I should see "Unicorn People" within "#aspect_name" - 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 click on my name in the header - When I follow "Contacts" - Then I should see "Community spotlight" within ".col-md-9" - - 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 click on my name in the header - When I follow "Contacts" - Then I should not see "Community spotlight" within ".col-md-9" - Scenario: sorting the aspects Given I am signed in And I have an aspect called "People" diff --git a/spec/integration/contacts_spec.rb b/spec/integration/contacts_spec.rb new file mode 100644 index 0000000000000000000000000000000000000000..ca1ddef00cb0e7a7a2fc9428bdaa20dfe59ca944 --- /dev/null +++ b/spec/integration/contacts_spec.rb @@ -0,0 +1,75 @@ +require "spec_helper" + +describe ContactsController, type: :request do + describe "/contacts" do + context "user is signed in" do + before do + sign_in user + end + + shared_examples_for "community spotlight information is not present on the page" do + it "does not display a community spotlight link" do + get "/contacts" + + expect(response.status).to eq(200) + expect(response.body).to_not match(/a href="#{community_spotlight_path}"/) + end + end + + context "user has no contacts" do + let!(:user) { FactoryGirl.create(:user) } + + before do + expect(user.contacts.size).to eq(0) + end + + context "community spotlight is enabled" do + before do + AppConfig.settings.community_spotlight.enable = true + end + + it "displays a community spotlight link" do + get "/contacts" + + expect(response.status).to eq(200) + expect(response.body).to match(/a href="#{community_spotlight_path}"/) + end + end + + context "community spotlight is disabled" do + before do + AppConfig.settings.community_spotlight.enable = false + end + + it_behaves_like "community spotlight information is not present on the page" + end + end + + context "user has contacts" do + let!(:user) { FactoryGirl.create(:user) } + + before do + FactoryGirl.create(:contact, person: alice.person, user: user) + FactoryGirl.create(:contact, person: bob.person, user: user) + expect(user.reload.contacts.size).to eq(2) + end + + context "community spotlight is enabled" do + before do + AppConfig.settings.community_spotlight.enable = true + end + + it_behaves_like "community spotlight information is not present on the page" + end + + context "community spotlight is disabled" do + before do + AppConfig.settings.community_spotlight.enable = false + end + + it_behaves_like "community spotlight information is not present on the page" + end + end + end + end +end