Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TAN-2224 Co-sponsors side effects #9016

Merged
merged 26 commits into from
Oct 7, 2024
Merged

Conversation

IvaKop
Copy link
Contributor

@IvaKop IvaKop commented Sep 30, 2024

Changelog

@IvaKop IvaKop requested a review from kogre September 30, 2024 13:44
Copy link

💡 Co-sponsorship

@IvaKop
Copy link
Contributor Author

IvaKop commented Sep 30, 2024

@kogre Re-creating the PR as the prev one got closed after I deleted the cosponsorship branch. There are still some relevant comment in there you might want to have a look at. To speed things up a bit main question is about the way the co-sposhorship ids diff is being handled and whether this can be done better.

@IvaKop IvaKop changed the title Tan 2224/co sponsors side effects TAN-2224 Co-sponsors side effects Sep 30, 2024
Copy link
Contributor

@kogre kogre left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! Some small remarks, but nothing major.

You should also still update the ideas_spec acceptance tests. They should include the new cosponsors_ids in the params list for create and update, maybe also cover the case where we update the consponsors, as the controller plays an important role in that with those cosponsorship ids, so currently there's no coverage of the whole thing not breaking.

I think your solution for detecting the cosponsorships changes is sensible, and robust. The alternative would be to depend on ActiveModel::Dirty, which since Rails 7 also supports associations. When the original initiatives code was written, we weren't on Rails 7 yet, I believe. The advantage of that approach is that it's fully controlled in de side fx, instead of leaking into the controller. That being said, I think this is pretty simple and more robust, so I'm okay with it, don't think it's worth changing.

@cl-dev-bot
Copy link
Collaborator

cl-dev-bot commented Oct 1, 2024

Warnings
⚠️

The changelog is empty. What should I put in the changelog?

Messages
📖 Notion issue: TAN-2224
📖

Run the e2e tests

📖 Check translation progress

Generated by 🚫 dangerJS against 8358f9c

@CitizenLabDotCo CitizenLabDotCo deleted a comment from kogre Oct 1, 2024
@IvaKop
Copy link
Contributor Author

IvaKop commented Oct 2, 2024

@kogre I've addressed your comments, thanks for reviewing! I still couldn't figure out how to fix the failing specs.. 🤔
Would be great if you could take a look and let me know what I'm missing 🙌

@kogre
Copy link
Contributor

kogre commented Oct 7, 2024

@IvaKop The reason why the test fails is because the default state of the cosponsor_ids custom_field is set to enabled: false, which means that eventually, it isn't part of the allowed parameters in the controller.

I'm not fully sure what the implcation of the enabled field on the form is wrt to the form builder. Either we should change this boolean, or the failing spec should manually configure the custom field to be enabled.

@IvaKop
Copy link
Contributor Author

IvaKop commented Oct 7, 2024

@kogre I find this confusing because this is overridden and set to true when creating a proposal so I'm not sure how to solve it. Let's maybe take a look together.

@kogre
Copy link
Contributor

kogre commented Oct 7, 2024

@IvaKop It's fixed, we had a factory in place to easily create a custom form with the default fields, so I was able to use that, in the end.

@IvaKop
Copy link
Contributor Author

IvaKop commented Oct 7, 2024

Thanks @kogre! Clean solution in the end 👍 Really appreciate your help on this one 🙌

@IvaKop IvaKop merged commit 8509f59 into master Oct 7, 2024
15 checks passed
@IvaKop IvaKop deleted the TAN-2224/co-sponsors-side-effects branch October 7, 2024 16:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants