From 133dc6dff19862289920657ce2fa0c7e45f34317 Mon Sep 17 00:00:00 2001 From: JCarlos-JC Date: Thu, 19 Feb 2026 13:08:18 +0200 Subject: [PATCH] Proposals workflow to include proposals without state(except_rejected) --- .../chatbot/workflows/proposals_workflow.rb | 9 ++++++++- .../workflows/proposals_workflow_spec.rb | 19 +++++++++++++++++++ 2 files changed, 27 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..cca42ff 100644 --- a/app/services/decidim/chatbot/workflows/proposals_workflow.rb +++ b/app/services/decidim/chatbot/workflows/proposals_workflow.rb @@ -105,9 +105,16 @@ def component end def proposals - @proposals ||= Decidim::Proposals::Proposal.where(component:).published.except_rejected.only_amendables + proposals_seach= Decidim::Proposals::Proposal.where(decidim_component_id: component.id).published.only_amendables + proposals_seach.where(proposal_state: none_rejected).or(proposals_seach.where(proposal_state: nil)) + + end + + def none_rejected + Decidim::Proposals::ProposalState.where.not(decidim_component_id: component.id, token: "rejected") end + def commentable_id @commentable_id ||= received_message.button_id.to_s.start_with?("comment-") && received_message.button_id.to_s.sub("comment-", "") end diff --git a/spec/services/workflows/proposals_workflow_spec.rb b/spec/services/workflows/proposals_workflow_spec.rb index f74625d..8b1118b 100644 --- a/spec/services/workflows/proposals_workflow_spec.rb +++ b/spec/services/workflows/proposals_workflow_spec.rb @@ -87,6 +87,25 @@ module Workflows end end + + + context "when there are proposols without states" do + let!(:proposals) do + create_list(:proposal, 7, :evaluating, component: proposals_component, published_at: Time.current) + end + let!(:proposals_without_states) do + create_list(:proposal, 3, component: proposals_component, published_at: Time.current) + end + let!(:proposals_rejected) do + create_list(:proposal, 5, :rejected, component: proposals_component, published_at: Time.current) + end + it "only the none rejected proposals will be return" do + expect(subject.send(:proposals).count).to eq(10) + 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)