Skip to content

Fix attachments when called from Cells#9136

Merged
ahukkanen merged 2 commits intodevelopfrom
fix/voting-attachments-cell
Apr 6, 2022
Merged

Fix attachments when called from Cells#9136
ahukkanen merged 2 commits intodevelopfrom
fix/voting-attachments-cell

Conversation

@andreslucena
Copy link
Copy Markdown
Member

🎩 What? Why?

While working on Votings, it was detected an edge case on Cells and Attachments.

Basically the problem is that after Rails 6.1 upgrade (see #8610) we dropped the extension from the partial calls at

<%= render partial: "decidim/application/documents", locals: { documents: attached_to.documents } %>
.

Most of the times it isn't a problem, but in votings we have the AttachmentsAndFoldersCell calling attachments from a cell, and as cells don't have the HTML extension in their file it doesn't find the partial giving an exception:

Click for traceback

ActionView::Template::Error (Template missing: view: _attachments.erb prefixes: ["/home/apereira/Work/decidim/decidim/development_app/app/cells/decidim/application", "/home/apereira/Work/decidim/decidim/decidim-assemblies/app/cells/decidim/application", "/home/apereira/Work/decidim/decidim/decidim-assemblies/app/views/decidim/application", "/home/apereira/Work/decidim/decidim/decidim-conferences/app/cells/decidim/application", "/home/apereira/Work/decidim/decidim/decidim-conferences/app/views/decidim/application", "/home/apereira/Work/decidim/decidim/decidim-core/app/cells/decidim/application", "/home/apereira/Work/decidim/decidim/decidim-core/app/cells/amendable/decidim/application", "/home/apereira/Work/decidim/decidim/decidim-core/app/views/decidim/application", "/home/apereira/Work/decidim/decidim/decidim-admin/app/cells/decidim/application", "/home/apereira/Work/decidim/decidim/decidim-admin/app/views/decidim/application", "/home/apereira/Work/decidim/decidim/decidim-forms/app/cells/decidim/application", "/home/apereira/Work/decidim/decidim/decidim-verifications/app/cells/decidim/application", "/home/apereira/Work/decidim/decidim/decidim-participatory_processes/app/cells/decidim/application", "/home/apereira/Work/decidim/decidim/decidim-participatory_processes/app/views/decidim/application", "/home/apereira/Work/decidim/decidim/decidim-comments/app/cells/decidim/application", "/home/apereira/Work/decidim/decidim/decidim-comments/app/views/decidim/application", "/home/apereira/Work/decidim/decidim/decidim-proposals/app/cells/decidim/application", "/home/apereira/Work/decidim/decidim/decidim-proposals/app/views/decidim/application", "/home/apereira/Work/decidim/decidim/decidim-meetings/app/cells/decidim/application", "/home/apereira/Work/decidim/decidim/decidim-meetings/app/views/decidim/application", "/home/apereira/Work/decidim/decidim/decidim-debates/app/cells/decidim/application", "/home/apereira/Work/decidim/decidim/decidim-debates/app/views/decidim/application", "/home/apereira/Work/decidim/decidim/decidim-budgets/app/cells/decidim/application", "/home/apereira/Work/decidim/decidim/decidim-budgets/app/views/decidim/application", "/home/apereira/Work/decidim/decidim/decidim-accountability/app/cells/decidim/application", "/home/apereira/Work/decidim/decidim/decidim-accountability/app/views/decidim/application", "/home/apereira/Work/decidim/decidim/decidim-sortitions/app/cells/decidim/application", "/home/apereira/Work/decidim/decidim/decidim-sortitions/app/views/decidim/application", "/home/apereira/Work/decidim/decidim/decidim-blogs/app/cells/decidim/application", "/home/apereira/Work/decidim/decidim/decidim-blogs/app/views/decidim/application", "/home/apereira/Work/decidim/decidim/decidim-consultations/app/cells/decidim/application", "/home/apereira/Work/decidim/decidim/decidim-consultations/app/views/decidim/application", "/home/apereira/Work/decidim/decidim/decidim-elections/app/cells/decidim/application", "/home/apereira/Work/decidim/decidim/decidim-elections/app/views/decidim/application", "/home/apereira/Work/decidim/decidim/decidim-elections/app/cells/decidim/application", "/home/apereira/Work/decidim/decidim/decidim-elections/app/views/decidim/application", "/home/apereira/Work/decidim/decidim/decidim-initiatives/app/cells/decidim/application", "/home/apereira/Work/decidim/decidim/decidim-initiatives/app/views/decidim/application"]):
10: %>
11:
12: <% landing_content_blocks.each do |content_block| %>
13: <%= cell content_block.manifest.cell, content_block %>
14: <% end %>
15:
16: <% if landing_content_blocks.empty? %>

cells (4.1.7) lib/cell/view_model.rb:167:in find_template' cells (4.1.7) lib/cell/view_model.rb:109:in render_to_string'
cells (4.1.7) lib/cell/layout.rb:23:in render_to_string' cells (4.1.7) lib/cell/view_model.rb:104:in render'
/home/apereira/Work/decidim/decidim/decidim-core/app/helpers/decidim/attachments_helper.rb:13:in attachments_for' /home/apereira/Work/decidim/decidim/decidim-elections/app/cells/decidim/votings/content_blocks/landing_page/attachments_and_folders_cell.rb:16:in show'
cells (4.1.7) lib/cell/view_model.rb:114:in render_state' cells (4.1.7) lib/cell/caching.rb:46:in render_state'
cells (4.1.7) lib/cell/view_model.rb:92:in call' cells-rails (0.1.4) lib/cell/rails.rb:55:in call'
/home/apereira/Work/decidim/decidim/decidim-core/lib/decidim/view_model.rb:33:in block in call' /home/apereira/Work/decidim/decidim/decidim-core/lib/decidim/view_model.rb:51:in block in instrument'
activesupport (6.1.4.7) lib/active_support/notifications.rb:203:in block in instrument' activesupport (6.1.4.7) lib/active_support/notifications/instrumenter.rb:24:in instrument'
activesupport (6.1.4.7) lib/active_support/notifications.rb:203:in instrument' /home/apereira/Work/decidim/decidim/decidim-core/lib/decidim/view_model.rb:50:in instrument'
/home/apereira/Work/decidim/decidim/decidim-core/lib/decidim/view_model.rb:32:in call' cells (4.1.7) lib/cell/view_model.rb:125:in to_s'
actionview (6.1.4.7) lib/action_view/buffers.rb:29:in <<' /home/apereira/Work/decidim/decidim/decidim-elections/app/views/decidim/votings/votings/show.html.erb:13 /home/apereira/Work/decidim/decidim/decidim-elections/app/views/decidim/votings/votings/show.html.erb:12:in each'
/home/apereira/Work/decidim/decidim/decidim-elections/app/views/decidim/votings/votings/show.html.erb:12

The fix is just some renaming in these files. I've also added a regressions spec for this particular cell.

📌 Related Issues

Testing

  1. Run the spec before and after this PR

or

  1. Seed the database
  2. Go to a voting
  3. See the exception

♥️ Thank you!

@ahukkanen ahukkanen merged commit 80edb84 into develop Apr 6, 2022
@ahukkanen ahukkanen deleted the fix/voting-attachments-cell branch April 6, 2022 08:22
entantoencuanto added a commit to PopulateTools/decidim that referenced this pull request Apr 6, 2022
…into pwa-staging

* chore/cache_highligted_resources_for_components_cells:
  Define expiry_time on highlighted_results_for_component cell
  Refactor expiration time of cells cache
  Cache cells used view hooks defined for participatory processes
  Do not send upcoming meeting notification for hidden or withdrawn meetings (decidim#9134)
  Fix processes count in processes group title cell (decidim#9087)
  Fix attachments when called from Cells (decidim#9136)
  Clarify message to user when checking census (decidim#9112)
entantoencuanto added a commit that referenced this pull request Apr 7, 2022
* develop:
  Compile SCSS through sass-embedded (#9081)
  Prevent race condition between prevenTimeout and show modal (#9092)
  Bump elections dependencies to 0.23.0 (#9140)
  Reduce d3 bundle size (#9034)
  Improve wording when casting your vote (#9098)
  Do not send upcoming meeting notification for hidden or withdrawn meetings (#9134)
  Fix processes count in processes group title cell (#9087)
  Fix attachments when called from Cells (#9136)
  Clarify message to user when checking census (#9112)
andreslucena added a commit that referenced this pull request May 6, 2022
* Drop .html extension on partials filenames

* Add spec for votings' AttachmentsAndFoldersCell
@alecslupu alecslupu added this to the 0.27.0 milestone Jul 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

module: elections type: fix PRs that implement a fix for a bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants