Commit 05e97980 authored by Steffen van Bergerem's avatar Steffen van Bergerem Committed by Benjamin Neff

Fix sharing indicator on profile page for blocked users

closes #7382
parent d3de97b2
......@@ -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)
......
......@@ -30,7 +30,7 @@ app.models.Person = Backbone.Model.extend({
},
isBlocked: function() {
return (this.get('relationship') === 'blocked');
return (this.get("block") !== false);
},
block: function() {
......
......@@ -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
......
......@@ -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();
});
});
......
......@@ -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);
......
......@@ -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
......
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