Skip to content

Commit

Permalink
Disabling specs
Browse files Browse the repository at this point in the history
  • Loading branch information
alecslupu committed Dec 6, 2023
1 parent e5806ec commit 2381f4e
Show file tree
Hide file tree
Showing 76 changed files with 63 additions and 4,112 deletions.
40 changes: 39 additions & 1 deletion lib/decidim/custom_proposal_states/overrides/proposal.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,13 @@ def self.prepended(base)
inverse_of: :proposals,
optional: true,
counter_cache: true

scope :not_status, lambda { |status|
joins(:proposal_state).where.not(decidim_proposals_proposal_states: { token: status })
.where(%(
("decidim_proposals_proposals"."state_published_at" IS NULL AND "decidim_proposals_proposal_states"."answerable" = TRUE) OR
("decidim_proposals_proposals"."state_published_at" IS NOT NULL AND "decidim_proposals_proposal_states"."answerable" = FALSE)
))
}
scope :only_status, lambda { |status|
joins(:proposal_state).where(decidim_proposals_proposal_states: { token: status })
.where(%(
Expand All @@ -24,9 +30,16 @@ def self.prepended(base)
}

scope :accepted, -> { state_published.only_status(:accepted) }
scope :rejected, -> { state_published.only_status(:rejected) }
scope :evaluating, -> { state_published.only_status(:evaluating) }
scope :except_withdrawn, -> { joins(:proposal_state).where.not(decidim_proposals_proposal_states: { token: :withdrawn }) }

scope :gamified, -> { state_published.only_status(:accepted).where(decidim_proposals_proposal_states: { gamified: true }) }

scope :state_published, -> { where.not(state_published_at: nil) }
scope :except_rejected, -> { not_status(:rejected).or(state_not_published) }
scope :withdrawn, -> { joins(:proposal_state).where(decidim_proposals_proposal_states: { token: :withdrawn }) }
scope :except_withdrawn, -> { joins(:proposal_state).where.not(decidim_proposals_proposal_states: { token: :withdrawn }) }

def set_default_state
return if proposal_state.present?
Expand All @@ -38,6 +51,31 @@ def assign_state(token)
proposal_state = Decidim::CustomProposalStates::ProposalState.where(component: component, token: token).first!
self.proposal_state = proposal_state
end

def state
return amendment.state if emendation?
return nil unless published_state? || withdrawn?

raise "aaaa"
proposal_state&.token
end

def internal_state
return amendment.state if emendation?
raise "aaaa"

proposal_state&.token
end

def process_amendment_state_change!
return unless %w(accepted rejected evaluating withdrawn).member?(amendment.state)

raise "aaaa"
PaperTrail.request(enabled: false) do
assign_state(amendment.state)
update!(state_published_at: Time.current)
end
end
end
end
end
Expand Down
6 changes: 5 additions & 1 deletion lib/decidim/custom_proposal_states/test/factories.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,18 @@ def generate_state_title(token)
transient do
state { :not_answered }
end
component { build(:extended_proposal_component) }

after(:build) do |proposal, evaluator|
if proposal.component
existing_states = Decidim::CustomProposalStates::ProposalState.where(component: proposal.component)

Decidim::CustomProposalStates.create_default_states!(proposal.component, nil, with_traceability: false) unless existing_states.any?
end

proposal.assign_state(evaluator.state)

proposal_state = Decidim::CustomProposalStates::ProposalState.where(component: proposal.component, token: evaluator.state).first!
proposal.proposal_state = proposal_state
end

trait :evaluating do
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

Loading

0 comments on commit 2381f4e

Please sign in to comment.