-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix proposal presenter
#author
method for private user proposals
- Loading branch information
Showing
4 changed files
with
41 additions
and
0 deletions.
There are no files selected for viewing
20 changes: 20 additions & 0 deletions
20
app/presenters/concerns/decidim/privacy/proposal_presenter_extensions.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# frozen_string_literal: true | ||
|
||
module Decidim | ||
module Privacy | ||
module ProposalPresenterExtensions | ||
extend ActiveSupport::Concern | ||
|
||
included do | ||
def author | ||
@author ||= if official? | ||
Decidim::Proposals::OfficialAuthorPresenter.new | ||
else | ||
coauthorship = coauthorships.includes(:author, :user_group).first | ||
coauthorship.user_group&.presenter || coauthorship.author&.presenter | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
spec/presenters/decidim/proposals/proposal_presenter_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# frozen_string_literal: true | ||
|
||
require "spec_helper" | ||
|
||
describe Decidim::Proposals::ProposalPresenter, type: :helper do | ||
let(:component) { create(:proposal_component) } | ||
let(:proposal) { create(:proposal, component: component, users: [author]) } | ||
let(:author) { create(:user, :confirmed, organization: component.organization) } | ||
let(:presenter) { described_class.new(proposal) } | ||
|
||
describe "#author" do | ||
subject { presenter.author } | ||
|
||
context "when the author is private (default)" do | ||
it { is_expected.to be_nil } | ||
end | ||
end | ||
end |
File renamed without changes.