diff --git a/Changelog.md b/Changelog.md index 85e7e0845..8fb0c37ce 100644 --- a/Changelog.md +++ b/Changelog.md @@ -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) diff --git a/app/assets/javascripts/app/models/person.js b/app/assets/javascripts/app/models/person.js index 4d70fada4..0f548798b 100644 --- a/app/assets/javascripts/app/models/person.js +++ b/app/assets/javascripts/app/models/person.js @@ -30,7 +30,7 @@ app.models.Person = Backbone.Model.extend({ }, isBlocked: function() { - return (this.get('relationship') === 'blocked'); + return (this.get("block") !== false); }, block: function() { diff --git a/app/presenters/person_presenter.rb b/app/presenters/person_presenter.rb index 63685cb51..d9cf71c02 100644 --- a/app/presenters/person_presenter.rb +++ b/app/presenters/person_presenter.rb @@ -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 diff --git a/spec/javascripts/app/models/person_spec.js b/spec/javascripts/app/models/person_spec.js index d84afdd8f..c4b873832 100644 --- a/spec/javascripts/app/models/person_spec.js +++ b/spec/javascripts/app/models/person_spec.js @@ -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(); }); }); diff --git a/spec/javascripts/jasmine_helpers/factory.js b/spec/javascripts/jasmine_helpers/factory.js index 7732e8281..551fe87bc 100644 --- a/spec/javascripts/jasmine_helpers/factory.js +++ b/spec/javascripts/jasmine_helpers/factory.js @@ -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); diff --git a/spec/presenters/person_presenter_spec.rb b/spec/presenters/person_presenter_spec.rb index e6c224674..c21965f9b 100644 --- a/spec/presenters/person_presenter_spec.rb +++ b/spec/presenters/person_presenter_spec.rb @@ -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