From ad596d8df16b6355d40c23a38a0ecd8ea57f5c72 Mon Sep 17 00:00:00 2001 From: cmrd Senya Date: Wed, 7 Sep 2016 18:15:59 +0300 Subject: [PATCH] Fix tags URLs in hovercards fixes #7074 closes #7075 --- Changelog.md | 2 ++ .../javascripts/app/views/hovercard_view.js | 2 +- features/desktop/hovercards.feature | 10 +++++++++ features/step_definitions/hovercard_steps.rb | 5 +++++ features/step_definitions/user_steps.rb | 7 +++++++ .../app/views/hovercard_view_spec.js | 21 +++++++++++++++++-- 6 files changed, 44 insertions(+), 3 deletions(-) diff --git a/Changelog.md b/Changelog.md index 50732375d..258696f32 100644 --- a/Changelog.md +++ b/Changelog.md @@ -12,6 +12,8 @@ * Closed accounts will no longer show up in the account search [#7042](https://github.com/diaspora/diaspora/pull/7042) * Code blocks in conversations no longer overflow the content [#7055](https://github.com/diaspora/diaspora/pull/7055) * More buttons in mobile streams are fixed [#7036](https://github.com/diaspora/diaspora/pull/7036) +* Fixed missing sidebar background in the contacts tab [#7064](https://github.com/diaspora/diaspora/pull/7064) +* Fix tags URLs in hovercards [#7075](https://github.com/diaspora/diaspora/pull/7075) ## Features * Deleted comments will be removed when loading more comments [#7045](https://github.com/diaspora/diaspora/pull/7045) diff --git a/app/assets/javascripts/app/views/hovercard_view.js b/app/assets/javascripts/app/views/hovercard_view.js index 93f9ffa62..1013225ba 100644 --- a/app/assets/javascripts/app/views/hovercard_view.js +++ b/app/assets/javascripts/app/views/hovercard_view.js @@ -130,7 +130,7 @@ app.views.Hovercard = app.views.Base.extend({ // set hashtags this.hashtags.empty(); this.hashtags.html($(_.map(person.profile.tags, function(tag) { - return $("", {href: "/tags/" + tag.substring(1)}).text(tag)[0]; + return $("", {href: Routes.tag(tag)}).text("#" + tag)[0]; }))); } }, diff --git a/features/desktop/hovercards.feature b/features/desktop/hovercards.feature index 9c510ab0d..a1061ea4f 100644 --- a/features/desktop/hovercards.feature +++ b/features/desktop/hovercards.feature @@ -39,3 +39,13 @@ Feature: Hovercards Then I should see a hovercard When I deactivate the first hovercard Then I should not see a hovercard + + Scenario: Hovercards contain profile tags + Given a user with email "bob@bob.bob" is tagged "#first #second" + And 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 + And I should see "#first" hashtag in the hovercard + And I should see "#second" hashtag in the hovercard diff --git a/features/step_definitions/hovercard_steps.rb b/features/step_definitions/hovercard_steps.rb index c76e481e7..cfe38cecf 100644 --- a/features/step_definitions/hovercard_steps.rb +++ b/features/step_definitions/hovercard_steps.rb @@ -6,6 +6,11 @@ Then(/^I should see a hovercard$/) do page.should have_css('#hovercard', visible: true) end +Then(/^I should see "([^"]*)" hashtag in the hovercard$/) do |tag| + element = find("#hovercard .hashtags a", text: tag) + expect(element["href"]).to include("/tags/#{tag.slice(1, tag.length)}") +end + When(/^I deactivate the first hovercard$/) do page.execute_script("$('.hovercardable').first().trigger('mouseleave');") end diff --git a/features/step_definitions/user_steps.rb b/features/step_definitions/user_steps.rb index ed1abe5f1..0bad1d618 100644 --- a/features/step_definitions/user_steps.rb +++ b/features/step_definitions/user_steps.rb @@ -100,6 +100,13 @@ Given /^there is a user "([^\"]*)" who's tagged "([^\"]*)"$/ do |full_name, tag| user.profile.save! end +Given /^a user with email "([^\"]*)" is tagged "([^\"]*)"$/ do |email, tags| + user = User.find_by_email(email) + user.profile.tag_string = tags + user.profile.build_tags + user.profile.save! +end + Given /^many posts from alice for bob$/ do alice = FactoryGirl.create(:user_with_aspect, :username => 'alice', :email => 'alice@alice.alice', :password => 'password', :getting_started => false) bob = FactoryGirl.create(:user_with_aspect, :username => 'bob', :email => 'bob@bob.bob', :password => 'password', :getting_started => false) diff --git a/spec/javascripts/app/views/hovercard_view_spec.js b/spec/javascripts/app/views/hovercard_view_spec.js index 1bcbe8444..c307ebcee 100644 --- a/spec/javascripts/app/views/hovercard_view_spec.js +++ b/spec/javascripts/app/views/hovercard_view_spec.js @@ -42,15 +42,17 @@ describe("app.views.Hovercard", function() { }); describe("_populateHovercard", function() { + beforeEach(function() { + this.view.parent = spec.content(); + }); + it("prevents global error handling for the ajax call", function() { spyOn(jQuery, "ajax").and.callThrough(); - this.view.parent = spec.content(); this.view._populateHovercard(); expect(jQuery.ajax).toHaveBeenCalledWith("undefined/hovercard.json", {preventGlobalErrorHandling: true}); }); it("creates the aspect dropdown", function() { - this.view.parent = spec.content(); this.view._populateHovercard(); jasmine.Ajax.requests.mostRecent().respondWith({ status: 200, @@ -58,6 +60,21 @@ describe("app.views.Hovercard", function() { }); expect(this.view.aspectMembershipDropdown).not.toEqual(undefined); }); + + it("renders tags properly", function() { + this.view._populateHovercard(); + jasmine.Ajax.requests.mostRecent().respondWith({ + status: 200, + responseText: JSON.stringify({id: 1337, profile: {tags: ["first", "second"]}}) + }); + + var first = this.view.hashtags.find("a:contains('#first')"); + var second = this.view.hashtags.find("a:contains('#second')"); + expect(first.length).toEqual(1); + expect(second.length).toEqual(1); + expect(first.first()[0].href).toContain(Routes.tag("first")); + expect(second.first()[0].href).toContain(Routes.tag("second")); + }); }); }); });