Skip to content
Extraits de code Groupes Projets
Valider 2025fae4 rédigé par Steffen van Bergerem's avatar Steffen van Bergerem Validation de Jonne Haß
Parcourir les fichiers

Disable hovercards for logged out users and prevent redirect to sign in page

closes #6587
parent f0fc62e9
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -6,7 +6,8 @@
## Bug fixes
* Fix mention autocomplete when pasting the username [#6510](https://github.com/diaspora/diaspora/pull/6510)
* Use and update updated\_at for notifications [#6573](https://github.com/diaspora/diaspora/pull/6573)
* Ensure the author signature is checked when receiving a relayable [#6539](https://github.com/diaspora/diaspora/pull/6539)
* Ensure the author signature is checked when receiving a relayable [#6539](https://github.com/diaspora/diaspora/pull/6539)
* Do not try to display hovercards when logged out [#6587](https://github.com/diaspora/diaspora/pull/6587)
## Features
......
......@@ -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 = true;
this.active = app.currentUser.authenticated();
},
postRenderTemplate: function() {
......@@ -97,7 +97,7 @@ app.views.Hovercard = app.views.Base.extend({
href += "/hovercard.json";
var self = this;
$.get(href, function(person){
$.ajax(href, {preventGlobalErrorHandling: true}).done(function(person){
if( !person || person.length === 0 ) {
throw new Error("received data is not a person object");
}
......@@ -130,7 +130,7 @@ app.views.Hovercard = app.views.Base.extend({
// TODO render me client side!!!
var href = this.href();
href += "/aspect_membership_button";
$.get(href, function(response) {
$.ajax(href, {preventGlobalErrorHandling: true}).done(function(response){
self.dropdown_container.html(response);
});
new app.views.AspectMembership({el: self.dropdown_container});
......
describe("app.views.Hovercard", function() {
beforeEach(function() {
this.view = new app.views.Hovercard();
context("user not signed in", function() {
beforeEach(function() {
logout();
this.view = new app.views.Hovercard();
});
describe("initialize", function() {
it("deactivates hovercards", function() {
expect(this.view.active).toBeFalsy();
});
});
});
describe("mouseIsOverElement", function() {
it("returns false if the element is undefined", function() {
expect(this.view.mouseIsOverElement(undefined, $.Event())).toBeFalsy();
context("user signed in", function() {
beforeEach(function() {
loginAs(factory.userAttrs());
this.view = new app.views.Hovercard();
});
describe("initialize", function() {
it("activates hovercards", function() {
expect(this.view.active).toBeTruthy();
});
});
describe("mouseIsOverElement", function() {
it("returns false if the element is undefined", function() {
expect(this.view.mouseIsOverElement(undefined, $.Event())).toBeFalsy();
});
});
describe("_populateHovercard", function() {
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});
});
});
describe("_populateHovercardWith", function() {
it("prevents global error handling for the ajax call", function() {
spyOn(jQuery, "ajax").and.callThrough();
this.view.parent = spec.content();
this.view._populateHovercardWith({});
expect(jQuery.ajax).toHaveBeenCalledWith(
"undefined/aspect_membership_button",
{preventGlobalErrorHandling: true}
);
});
});
});
});
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter