Skip to content
Permalink
Browse files

Don't include drafts in sortitions (#5434)

* Don't include drafts in sortitions

* Add changelog entry

* Fix rubocop offenses

* Update participatory_space_proposals_spec.rb
  • Loading branch information...
armandfardeau authored and oriolgual committed Oct 21, 2019
1 parent 261605f commit aa14989401d52bb0e949ca7164304e1771017f98
@@ -11,6 +11,8 @@

**Fixed**:

- **decidim-sortitions**: Fix: Don't include drafts in sortitions [\#5434](https://github.com/decidim/decidim/pull/5434)


**Removed**:

@@ -56,6 +56,7 @@ class Proposal < Proposals::ApplicationRecord
scope :except_rejected, -> { where.not(state: "rejected").or(where(state: nil)) }
scope :except_withdrawn, -> { where.not(state: "withdrawn").or(where(state: nil)) }
scope :drafts, -> { where(published_at: nil) }
scope :except_drafts, -> { where.not(published_at: nil) }
scope :published, -> { where.not(published_at: nil) }

acts_as_list scope: :decidim_component_id
@@ -25,6 +25,7 @@ def query
if category.nil?
return Decidim::Proposals::Proposal
.except_withdrawn
.except_drafts
.where("created_at < ?", request_timestamp)
.where(component: sortition.decidim_proposals_component)
.order(id: :asc)
@@ -34,6 +35,7 @@ def query
Decidim::Proposals::Proposal
.joins(:categorization)
.except_withdrawn
.except_drafts
.where(component: sortition.decidim_proposals_component)
.where("decidim_proposals_proposals.created_at < ?", request_timestamp)
.where("decidim_categorizations.decidim_category_id = ?", category.id)
@@ -85,6 +85,16 @@ module Admin
expect(described_class.for(sortition)).not_to include(*proposals)
end
end

context "when filtering drafts proposals" do
let(:proposals) do
create_list(:proposal, 10, :draft, component: proposal_component, created_at: request_timestamp - 10.days)
end

it "do not return draft proposals" do
expect(described_class.for(sortition)).not_to include(*proposals)
end
end
end
end
end

0 comments on commit aa14989

Please sign in to comment.
You can’t perform that action at this time.