From f3e897ab438eae53f2111c6f9bdd3ebd3946f778 Mon Sep 17 00:00:00 2001 From: Steffen van Bergerem <svbergerem@online.de> Date: Mon, 28 Dec 2015 23:29:48 +0100 Subject: [PATCH] Activate hovercards for logged out users closes #6603 --- Changelog.md | 2 ++ .../javascripts/app/views/hovercard_view.js | 3 ++- app/controllers/people_controller.rb | 4 ++-- features/desktop/hovercards.feature | 19 ++++++++++++++----- .../app/views/hovercard_view_spec.js | 9 ++++++--- 5 files changed, 26 insertions(+), 11 deletions(-) diff --git a/Changelog.md b/Changelog.md index f209f66f6e..4caed69b87 100644 --- a/Changelog.md +++ b/Changelog.md @@ -11,6 +11,8 @@ ## Features +Display hovercards without aspect dropdown when logged out [#6603](https://github.com/diaspora/diaspora/pull/6603) + # 0.5.5.1 * Fix XSS on profile pages diff --git a/app/assets/javascripts/app/views/hovercard_view.js b/app/assets/javascripts/app/views/hovercard_view.js index 0829849311..2389521548 100644 --- a/app/assets/javascripts/app/views/hovercard_view.js +++ b/app/assets/javascripts/app/views/hovercard_view.js @@ -25,7 +25,7 @@ app.views.Hovercard = app.views.Base.extend({ this.hashtags = this.$('.hashtags'); this.person_link = this.$('a.person'); this.person_handle = this.$('div.handle'); - this.active = app.currentUser.authenticated(); + this.active = true; }, postRenderTemplate: function() { @@ -126,6 +126,7 @@ app.views.Hovercard = app.views.Base.extend({ return $('<a/>',{href: "/tags/"+tag.substring(1)}).text(tag)[0] ; })) ); + if(!app.currentUser.authenticated()){ return; } // set aspect dropdown // TODO render me client side!!! var href = this.href(); diff --git a/app/controllers/people_controller.rb b/app/controllers/people_controller.rb index b2343d941f..154f433767 100644 --- a/app/controllers/people_controller.rb +++ b/app/controllers/people_controller.rb @@ -3,8 +3,8 @@ # the COPYRIGHT file. class PeopleController < ApplicationController - before_action :authenticate_user!, except: [:show, :stream] - before_action :find_person, only: [:show, :stream, :hovercard] + before_action :authenticate_user!, except: %i(show stream hovercard) + before_action :find_person, only: %i(show stream hovercard) respond_to :html, :except => [:tag_index] respond_to :json, :only => [:index, :show] diff --git a/features/desktop/hovercards.feature b/features/desktop/hovercards.feature index 77c56903ba..9c510ab0dc 100644 --- a/features/desktop/hovercards.feature +++ b/features/desktop/hovercards.feature @@ -6,15 +6,15 @@ Feature: Hovercards Background: Given a user named "Bob Jones" with email "bob@bob.bob" - And "bob@bob.bob" has a public post with text "public stuff" + And "bob@bob.bob" has a public post with text "public stuff #hashtag" And a user named "Alice" with email "alice@alice.alice" And "alice@alice.alice" has a public post with text "alice public stuff" - And the post with text "public stuff" is reshared by "alice@alice.alice" + And the post with text "public stuff #hashtag" is reshared by "alice@alice.alice" And the post with text "alice public stuff" is reshared by "bob@bob.bob" - And I sign in as "alice@alice.alice" Scenario: Hovercards on the main stream - Given I am on "bob@bob.bob"'s page + Given I sign in as "alice@alice.alice" + And I am on "bob@bob.bob"'s page Then I should see "public stuff" within ".stream_element" When I activate the first hovercard Then I should see a hovercard @@ -22,7 +22,8 @@ Feature: Hovercards Then I should not see a hovercard Scenario: Hovercards on the main stream in reshares - Given I am on "bob@bob.bob"'s page + Given I sign in as "alice@alice.alice" + And I am on "bob@bob.bob"'s page Then I should see "Alice" within "#main_stream" When I hover "Alice" within "#main_stream" Then I should not see a hovercard @@ -30,3 +31,11 @@ Feature: Hovercards Then I should see "Bob Jones" within "#main_stream" When I hover "Bob Jones" within "#main_stream" Then I should see a hovercard + + Scenario: Hovercards on the tag stream as a logged out user + Given I am on the tag page for "hashtag" + Then I should see "public stuff" within ".stream_element" + When I activate the first hovercard + Then I should see a hovercard + When I deactivate the first hovercard + Then I should not see a hovercard diff --git a/spec/javascripts/app/views/hovercard_view_spec.js b/spec/javascripts/app/views/hovercard_view_spec.js index 2e8cddee5e..6f7e4c2609 100644 --- a/spec/javascripts/app/views/hovercard_view_spec.js +++ b/spec/javascripts/app/views/hovercard_view_spec.js @@ -5,9 +5,12 @@ describe("app.views.Hovercard", function() { this.view = new app.views.Hovercard(); }); - describe("initialize", function() { - it("deactivates hovercards", function() { - expect(this.view.active).toBeFalsy(); + describe("_populateHovercardWith", function() { + it("doesn't fetch the aspect dropdown", function() { + spyOn(jQuery, "ajax").and.callThrough(); + this.view.parent = spec.content(); + this.view._populateHovercardWith({}); + expect(jQuery.ajax).not.toHaveBeenCalled(); }); }); }); -- GitLab