Make the document a required field in spaces import#15980
Conversation
📝 WalkthroughWalkthroughAdds document presence validation to two import form classes, introduces matching RSpec test suites, and removes the Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
Important Action Needed: IP Allowlist UpdateIf your organization protects your Git platform with IP whitelisting, please add the new CodeRabbit IP address to your allowlist:
Failure to add the new IP will result in interrupted reviews. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Pull request overview
This PR prevents a 500 error during participatory space imports when the admin submits the import form without uploading a document, by making the uploaded JSON document required at the form-validation level.
Changes:
- Add
presence: truevalidation for thedocumentattribute in participatory process and assembly import forms. - Add new form specs covering valid input, missing document, invalid document content type, and slug/title validation cases for both imports.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| decidim-participatory_processes/app/forms/decidim/participatory_processes/admin/participatory_process_import_form.rb | Requires an import document to be present, preventing imports from proceeding with a missing file. |
| decidim-participatory_processes/spec/forms/decidim/participatory_processes/admin/participatory_process_import_form_spec.rb | Adds form-level regression coverage for missing/invalid documents and slug/title validation. |
| decidim-assemblies/app/forms/decidim/assemblies/admin/assembly_import_form.rb | Requires an import document to be present, preventing imports from proceeding with a missing file. |
| decidim-assemblies/spec/forms/decidim/assemblies/admin/assembly_import_form_spec.rb | Adds form-level regression coverage for missing/invalid documents and slug/title validation. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
🎩 What? Why?
While working with #15895, I'm trying to make the import assembly feature work but I'm finding too many bugs in the process.
This PR is the first of a series to make this feature work with a bit lower number of bugs.
The first two that I found are related to the document upload field itself.
on proceses, if an admin goes to this form and doesn't actually uploads the document, then it doesn't show any error. The fix is to remove the required HTML5 attribute from this form, as it doesn't play nice with the upload that we have.this is actually related to another change that I'm doing, you can ignore this for nowTesting
For assemblies:
Stacktrace
📷 Screenshots
Before
After
Summary by CodeRabbit
Bug Fixes
Tests