Commit ad596d8d authored by cmrd Senya's avatar cmrd Senya Committed by Steffen van Bergerem

Fix tags URLs in hovercards

fixes #7074

closes #7075
parent e27af6ee
......@@ -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)
......
......@@ -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 $("<a/>", {href: "/tags/" + tag.substring(1)}).text(tag)[0];
return $("<a/>", {href: Routes.tag(tag)}).text("#" + tag)[0];
})));
}
},
......
......@@ -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
......@@ -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
......
......@@ -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)
......
......@@ -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"));
});
});
});
});
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment