Skip to content

Fix scope validation on initiative's creation #8755

Merged
andreslucena merged 7 commits intodevelopfrom
fix/initiative-select-no-scope
Feb 16, 2022
Merged

Fix scope validation on initiative's creation #8755
andreslucena merged 7 commits intodevelopfrom
fix/initiative-select-no-scope

Conversation

@andreslucena
Copy link
Copy Markdown
Member

🎩 What? Why?

As a participant, when I create a new initiative and I don't select any scope I get an error:

NoMethodError (undefined method `allowed_signature_types_for_initiatives' for nil:NilClass):

/home/apereira/Work/decidim/decidim/decidim-initiatives/app/models/decidim/initiative.rb:454:in `signature_type_allowed'

(There's a video below)

This PR fixes this client side. I think we can improve it, but it's at least a quick fix for this issue.

I don't know if this is compatible with the "Global scope"'s kind of settings that we have in the initiatives' admin settings.

Testing

  1. Sign in as participant
  2. Create a new initiative
  3. Don't select any scope
  4. Click in "Continue"

📷 Screenshots

Before

initiative-type-bug.mp4

After

Selecció_124

♥️ Thank you!

@andreslucena
Copy link
Copy Markdown
Member Author

I wanted to improve the current approach by doing the validation also in the model, but as far as I see this would involve changing the current data model with the InitiativesTypeScope association.

Doing a validates :scope, presence: true or a custom validator with an errors.add(:scope, :blank) if scope.blank? doesn't work in neither case - so I'm leaving the current proposed solution, as at least it catches this bug. I have also added a spec for this.

I've also implemented some small cosmetic changes for a bit more consistency/cleanup of some things that were weird, like some styles in comments, spec's examples descriptions all in lowercase, removing unnecessary "required: true" attributes in forms, etc.

@andreslucena andreslucena added module: initiatives type: fix PRs that implement a fix for a bug labels Feb 14, 2022
@andreslucena andreslucena merged commit 91f4961 into develop Feb 16, 2022
@andreslucena andreslucena deleted the fix/initiative-select-no-scope branch February 16, 2022 15:35
entantoencuanto added a commit that referenced this pull request Feb 18, 2022
* develop: (134 commits)
  Remove Rectify::Presenter references (#8758)
  Clarify the locales on the list of admins (#8838)
  Fix activity cell disappearing author images (#8826)
  Fix notifications when there is a note proposal in other spaces than processes (#8822)
  Fix accountability text search (#8831)
  Fix displaying hidden meetings in show process page (#8823)
  Fix docs for install-decidim.sh permissions (#8839)
  Fix report moderation for all the spaces (#8813)
  Clarify the comment at the resource search class (#8829)
  Fix displaying hidden related resources (#8812)
  Replace Decidim mentions in UI with 'the platform' (#8827)
  Add natively a .keep file to empty directory to include on git committing (#8830)
  Fix scope validation on initiative's creation (#8755)
  Replace `searchlight` with `ransack` which is already a core dependency (#8748)
  Fix characters not encoded in highlighted participatory process group title (#8820)
  Test ensuring the moderated comments are not computed in stats (#8816)
  Update rails to 6.0.4.6 and puma to 5.6.2 (#8817)
  Fix displaying hidden meetings in processes group's "upcoming meetings" content block (#8818)
  Fix displaying hidden meetings in homepage's "upcoming meetings" content block (#8809)
  Improve "Release Candidates" release docs (#8804)
  ...
@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: initiatives type: fix PRs that implement a fix for a bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants