From b1787b4780cfb0630ecf206361368e69a0569135 Mon Sep 17 00:00:00 2001 From: Amilton Portraite Date: Thu, 19 Feb 2026 23:05:36 +0200 Subject: [PATCH] Fix #15: Include stateless proposals and exclude only rejected ones. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Replace .except_rejected with left_joins(:proposal_state) + OR condition token IS NULL. Keep the “published” and “only_amendables” filters. Add basic tests to validate the inclusion of stateless proposals. Tested manually in the console. --- .../chatbot/workflows/proposals_workflow.rb | 10 +++++++++- .../services/workflows/proposals_workflow_spec.rb | 15 +++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/app/services/decidim/chatbot/workflows/proposals_workflow.rb b/app/services/decidim/chatbot/workflows/proposals_workflow.rb index 6d8df7f..8fb1c22 100644 --- a/app/services/decidim/chatbot/workflows/proposals_workflow.rb +++ b/app/services/decidim/chatbot/workflows/proposals_workflow.rb @@ -105,7 +105,15 @@ def component end def proposals - @proposals ||= Decidim::Proposals::Proposal.where(component:).published.except_rejected.only_amendables + @proposals ||= Decidim::Proposals::Proposal + .where(component: component) + .published + .only_amendables + .left_joins(:proposal_state) + .where( + "decidim_proposals_proposal_states.token != 'rejected' " \ + "OR decidim_proposals_proposal_states.token IS NULL" + ) end def commentable_id diff --git a/spec/services/workflows/proposals_workflow_spec.rb b/spec/services/workflows/proposals_workflow_spec.rb index f74625d..e24df36 100644 --- a/spec/services/workflows/proposals_workflow_spec.rb +++ b/spec/services/workflows/proposals_workflow_spec.rb @@ -87,6 +87,21 @@ module Workflows end end + def proposals + @proposals ||= begin + base = Decidim::Proposals::Proposal + .where(decidim_component_id: component.id) + .published + .only_amendables + + base.left_joins(:proposal_state) + .where( + "decidim_proposals_proposal_states.token != 'rejected' " \ + "OR decidim_proposals_proposal_states.token IS NULL" + ) + end + end + context "when there are exactly per_page proposals" do let!(:proposals) do create_list(:proposal, 10, :evaluating, component: proposals_component, published_at: Time.current)