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

Remove rectify weirdness on surveys #3055

Merged
merged 3 commits into from
Mar 22, 2018

Conversation

deivid-rodriguez
Copy link
Contributor

@deivid-rodriguez deivid-rodriguez commented Mar 20, 2018

🎩 What? Why?

Yesterday I almost went crazy figuring out why things were not working for our nested survey forms. I ended up adding two hacks to the answer form model to make it work:

  • Override the setter for the answer options.
  • Renaming the answer_options attribute to something that doesn't match attributes in the underlying model, so that rectify magic does not get in the middle.

However, these hacks are biting me now since I'm adding more attributes to this form, and I cannot easily unit test them, because the form is now instantiated wierdly.

I digged in a little deeper and it seems like a bug / missing feature in rectify to me: it only supports one-level nested forms. I added a fix for it in andypike/rectify#45, but I'm opening this PR monkeypatching it to see how the patch plays against the whole of decidim's test suite.

With this, I can remove both hacks mentioned before.

📌 Related Issues

📋 Subtasks

None.

📷 Screenshots (optional)

None.

@ghost ghost added the status: WIP label Mar 20, 2018
@codecov
Copy link

codecov bot commented Mar 20, 2018

Codecov Report

Merging #3055 into master will increase coverage by <.01%.
The diff coverage is 100%.

@@            Coverage Diff             @@
##           master    #3055      +/-   ##
==========================================
+ Coverage   98.59%   98.59%   +<.01%     
==========================================
  Files        1716     1717       +1     
  Lines       40967    40980      +13     
==========================================
+ Hits        40393    40406      +13     
  Misses        574      574

@mrcasals
Copy link
Contributor

@deivid-rodriguez this hotfix has the test suite passing! 🎉

Should we wait until the rectify PR is merged, or do you want to merge this and take care to update rectify once the new version is released?

@deivid-rodriguez deivid-rodriguez force-pushed the remove_rectify_weirdness_on_surveys branch from b07406c to bf5abae Compare March 21, 2018 10:58
@deivid-rodriguez
Copy link
Contributor Author

I think it's better to ship the monkeypatch for now so I can keep working under sanity, and also because rectify seems inactive these days so the PR might take long to get reviewed... I've added a comment explaining the situation.

mrcasals
mrcasals previously approved these changes Mar 21, 2018
The way surveys are structured made me introduce a nasty hack in the
survey question form. However, now I'm adding new attributes to the form
and I'm having trouble unit testing them since this form is now
instantiated very weirdly. I discovered that this is actually something
rectify just can't handle and I figured it's better to add support for
it upstream.

For now I'm adding the monkey patch here until the upstream PR is
attended.
@deivid-rodriguez
Copy link
Contributor Author

I simplified the patch to rectify and bit and updated the monkeypatch here. Should be ready now!

@mrcasals
Copy link
Contributor

OK then, going in!

@mrcasals mrcasals merged commit 8846fc2 into master Mar 22, 2018
@mrcasals mrcasals deleted the remove_rectify_weirdness_on_surveys branch March 22, 2018 08:35
@deivid-rodriguez deivid-rodriguez mentioned this pull request Oct 17, 2018
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants