From 05ec235ea32cc8e30673ddb3d5521c104895418c Mon Sep 17 00:00:00 2001 From: Steffen van Bergerem Date: Thu, 7 May 2015 23:22:54 +0200 Subject: [PATCH] Pass along current_user in ContactPresenter#full_hash_with_person closes #5936 --- Changelog.md | 1 + app/presenters/contact_presenter.rb | 2 +- spec/presenters/contact_presenter_spec.rb | 21 ++++++++++++--------- 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/Changelog.md b/Changelog.md index a5a4a4964..2ee9e9005 100644 --- a/Changelog.md +++ b/Changelog.md @@ -22,6 +22,7 @@ * Allow using common custom template for desktop & mobile landing page [#5915](https://github.com/diaspora/diaspora/pull/5915) * Use correct branding in Atom feed [#5929](https://github.com/diaspora/diaspora/pull/5929) * Update the configurate gem to avoid issues by missed missing settings keys [#5934](https://github.com/diaspora/diaspora/pull/5934) +* ContactPresenter#full_hash_with_person did not contain relationship information [#5936](https://github.com/diaspora/diaspora/pull/5936) ## Features * Hide post title of limited post in comment notification email [#5843](https://github.com/diaspora/diaspora/pull/5843) diff --git a/app/presenters/contact_presenter.rb b/app/presenters/contact_presenter.rb index 9ab8b2d26..6c3463a9d 100644 --- a/app/presenters/contact_presenter.rb +++ b/app/presenters/contact_presenter.rb @@ -12,6 +12,6 @@ class ContactPresenter < BasePresenter end def full_hash_with_person - full_hash.merge({person: PersonPresenter.new(person).full_hash_with_profile}) + full_hash.merge(person: PersonPresenter.new(person, current_user).full_hash_with_profile) end end diff --git a/spec/presenters/contact_presenter_spec.rb b/spec/presenters/contact_presenter_spec.rb index 2a1e0cefa..9f2d27245 100644 --- a/spec/presenters/contact_presenter_spec.rb +++ b/spec/presenters/contact_presenter_spec.rb @@ -1,26 +1,29 @@ -require 'spec_helper' +require "spec_helper" describe ContactPresenter do before do - @presenter = ContactPresenter.new(alice.contact_for(bob.person)) + @presenter = ContactPresenter.new(alice.contact_for(bob.person), alice) end - describe '#base_hash' do - it 'works' do + describe "#base_hash" do + it "works" do expect(@presenter.base_hash).to be_present end end - describe '#full_hash' do - it 'works' do + describe "#full_hash" do + it "works" do expect(@presenter.full_hash).to be_present end end - describe '#full_hash_with_person' do - it 'works' do + describe "#full_hash_with_person" do + it "works" do expect(@presenter.full_hash_with_person).to be_present end - end + it "has relationship information" do + expect(@presenter.full_hash_with_person[:person][:relationship]).to be(:mutual) + end + end end