Fix sharing indicator on profile page for blocked users

closes #7382
This commit is contained in:
Steffen van Bergerem 2017-03-21 16:22:23 +01:00 committed by Benjamin Neff
parent d3de97b244
commit 05e9798027
No known key found for this signature in database
GPG key ID: 971464C3F1A90194
6 changed files with 18 additions and 10 deletions

View file

@ -8,6 +8,7 @@
## Bug fixes
* Don't hide posts when blocking someone from the profile [#7379](https://github.com/diaspora/diaspora/pull/7379)
* Disable autocomplete for the conversation form recipient input [#7375](https://github.com/diaspora/diaspora/pull/7375)
* Fix sharing indicator on profile page for blocked users [#7382](https://github.com/diaspora/diaspora/pull/7382)
## Features
* Add links to liked and commented pages [#5502](https://github.com/diaspora/diaspora/pull/5502)

View file

@ -30,7 +30,7 @@ app.models.Person = Backbone.Model.extend({
},
isBlocked: function() {
return (this.get('relationship') === 'blocked');
return (this.get("block") !== false);
},
block: function() {

View file

@ -48,7 +48,6 @@ class PersonPresenter < BasePresenter
def relationship
return false unless current_user
return :blocked if is_blocked?
contact = current_user_person_contact
return :not_sharing unless contact

View file

@ -4,7 +4,7 @@ describe("app.models.Person", function() {
this.mutualContact = factory.person({relationship: "mutual"});
this.sharingContact = factory.person({relationship: "sharing"});
this.receivingContact = factory.person({relationship: "receiving"});
this.blockedContact = factory.person({relationship: "blocked", block: {id: 1}});
this.blockedContact = factory.person({relationship: "sharing", block: {id: 1}});
});
describe("initialize", function() {
@ -20,9 +20,9 @@ describe("app.models.Person", function() {
it("indicates if the person is sharing", function() {
expect(this.mutualContact.isSharing()).toBeTruthy();
expect(this.sharingContact.isSharing()).toBeTruthy();
expect(this.blockedContact.isSharing()).toBeTruthy();
expect(this.receivingContact.isSharing()).toBeFalsy();
expect(this.blockedContact.isSharing()).toBeFalsy();
});
});

View file

@ -153,6 +153,7 @@ var factory = {
"name": "Bob Grimm",
"diaspora_id": "bob@localhost:3000",
"relationship": "sharing",
"block": false,
"is_own_profile": false
};
return _.extend({}, defaults, overrides);

View file

@ -92,12 +92,6 @@ describe PersonPresenter do
end
context "relationship" do
it "is blocked?" do
allow(current_user).to receive(:block_for) { double(id: 1) }
allow(current_user).to receive(:contact_for) { non_contact }
expect(@p.full_hash[:relationship]).to be(:blocked)
end
it "is mutual?" do
allow(current_user).to receive(:contact_for) { mutual_contact }
expect(@p.full_hash[:relationship]).to be(:mutual)
@ -118,6 +112,19 @@ describe PersonPresenter do
expect(@p.full_hash[:relationship]).to be(:not_sharing)
end
end
describe "block" do
it "contains the block id if it exists" do
allow(current_user).to receive(:contact_for) { non_contact }
allow(current_user).to receive(:block_for) { double(id: 1) }
expect(@p.full_hash[:block][:id]).to be(1)
end
it "is false if no block is present" do
allow(current_user).to receive(:contact_for) { non_contact }
expect(@p.full_hash[:block]).to be(false)
end
end
end
describe "#hovercard" do