Disable hovercards for logged out users and prevent redirect to sign in page
closes #6587
This commit is contained in:
parent
f0fc62e94d
commit
2025fae420
3 changed files with 53 additions and 9 deletions
|
|
@ -6,7 +6,8 @@
|
||||||
## Bug fixes
|
## Bug fixes
|
||||||
* Fix mention autocomplete when pasting the username [#6510](https://github.com/diaspora/diaspora/pull/6510)
|
* 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)
|
* 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
|
## Features
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@ app.views.Hovercard = app.views.Base.extend({
|
||||||
this.hashtags = this.$('.hashtags');
|
this.hashtags = this.$('.hashtags');
|
||||||
this.person_link = this.$('a.person');
|
this.person_link = this.$('a.person');
|
||||||
this.person_handle = this.$('div.handle');
|
this.person_handle = this.$('div.handle');
|
||||||
this.active = true;
|
this.active = app.currentUser.authenticated();
|
||||||
},
|
},
|
||||||
|
|
||||||
postRenderTemplate: function() {
|
postRenderTemplate: function() {
|
||||||
|
|
@ -97,7 +97,7 @@ app.views.Hovercard = app.views.Base.extend({
|
||||||
href += "/hovercard.json";
|
href += "/hovercard.json";
|
||||||
|
|
||||||
var self = this;
|
var self = this;
|
||||||
$.get(href, function(person){
|
$.ajax(href, {preventGlobalErrorHandling: true}).done(function(person){
|
||||||
if( !person || person.length === 0 ) {
|
if( !person || person.length === 0 ) {
|
||||||
throw new Error("received data is not a person object");
|
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!!!
|
// TODO render me client side!!!
|
||||||
var href = this.href();
|
var href = this.href();
|
||||||
href += "/aspect_membership_button";
|
href += "/aspect_membership_button";
|
||||||
$.get(href, function(response) {
|
$.ajax(href, {preventGlobalErrorHandling: true}).done(function(response){
|
||||||
self.dropdown_container.html(response);
|
self.dropdown_container.html(response);
|
||||||
});
|
});
|
||||||
new app.views.AspectMembership({el: self.dropdown_container});
|
new app.views.AspectMembership({el: self.dropdown_container});
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,54 @@
|
||||||
describe("app.views.Hovercard", function() {
|
describe("app.views.Hovercard", function() {
|
||||||
beforeEach(function() {
|
context("user not signed in", function() {
|
||||||
this.view = new app.views.Hovercard();
|
beforeEach(function() {
|
||||||
|
logout();
|
||||||
|
this.view = new app.views.Hovercard();
|
||||||
|
});
|
||||||
|
|
||||||
|
describe("initialize", function() {
|
||||||
|
it("deactivates hovercards", function() {
|
||||||
|
expect(this.view.active).toBeFalsy();
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("mouseIsOverElement", function() {
|
context("user signed in", function() {
|
||||||
it("returns false if the element is undefined", function() {
|
beforeEach(function() {
|
||||||
expect(this.view.mouseIsOverElement(undefined, $.Event())).toBeFalsy();
|
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}
|
||||||
|
);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue