Skip to content

Commit

Permalink
Fix issue with linked proposals not displaying for private authors
Browse files Browse the repository at this point in the history
  • Loading branch information
ahukkanen committed Sep 21, 2023
1 parent 2e367e5 commit 17acc35
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 0 deletions.
37 changes: 37 additions & 0 deletions app/views/decidim/proposals/proposals/_linked_proposals.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<div class="card card--action card--list">
<% resources.each do |proposal| %>
<div class="card--list__item">
<div class="card--list__text">
<%= link_to resource_locator(proposal).path do %>
<%= icon "proposals", class: "card--list__icon", remove_icon_class: true %>
<% end %>
<div>
<%= link_to resource_locator(proposal).path, class: "card__link" do %>
<h5 class="card--list__heading"><%== decidim_html_escape(present(proposal).title) %></h5>
<% end %>
<% present(proposal) do |proposal| %>
<% if proposal.author %>
<div class="author">
<span class="author__avatar">
<%= image_tag proposal.author.avatar_url %>
</span>
<span class="author__name">
<strong><%= proposal.author.name %></strong>
<%= proposal.author.nickname %>
</span>
</div>
<% end %>
<% end %>
</div>
</div>
<% if !current_settings.try(:votes_hidden?) && !proposal.component.current_settings.votes_hidden? &&
proposal.component.current_settings.votes_enabled? %>
<div class="card--list__data">
<span class="card--list__data__number">
<%= proposal.votes.size %>
</span> <%= t(".proposal_votes", count: proposal.votes.size) %>
</div>
<% end %>
</div>
<% end %>
</div>
1 change: 1 addition & 0 deletions spec/factories.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
require "decidim/privacy/test/factories"
require "decidim/core/test/factories"
require "decidim/participatory_processes/test/factories"
require "decidim/accountability/test/factories"
require "decidim/proposals/test/factories"
require "decidim/meetings/test/factories"
require "decidim/debates/test/factories"
Expand Down
33 changes: 33 additions & 0 deletions spec/system/accountability_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# frozen_string_literal: true

require "spec_helper"

describe "Accountability", type: :system do
include_context "with a component"

let(:manifest_name) { "accountability" }

describe "show" do
let!(:result) { create(:result, component: component) }
let(:path) { decidim_participatory_process_accountability.result_path(id: result.id, participatory_process_slug: participatory_process.slug, component_id: component.id) }

context "when a result has linked proposals with private authors" do
let(:proposals_component) { create(:proposal_component, participatory_space: participatory_process) }
let(:proposal) { create(:proposal, :accepted, component: proposals_component, users: [proposal_author]) }
let(:proposal_author) { create(:user, :confirmed, organization: organization) }

before do
result.link_resources([proposal], "included_proposals")
end

it "renders the linked proposals without the author" do
visit path
expect(page).to have_content(translated(result.title))
page.scroll_to(find(".section-heading", text: "Proposals included in this result".upcase))

expect(page).to have_css(".card--list__item", text: translated(proposal.title))
expect(page).not_to have_css(".card--list__item .author")
end
end
end
end

0 comments on commit 17acc35

Please sign in to comment.