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

Use automatic next node detection in existing flows (with feedback addressed) #2368

Conversation

Projects
None yet
2 participants
@floehopper
Copy link
Contributor

commented Mar 15, 2016

This PR incorporates the feedback on #2362.

Changes

This PR changes all the existing flows (and shared logic) to use the mechanism to automatically detect permitted next nodes which was introduced in #2343. This was all relatively straightforward, if a little tedious. The only things worthy of note are:

  • The benefit-cap-calculator flow uses "dynamic" return values in many of its next_node blocks. I couldn't see a quick way to use the auto-detect mechanism, so I've left them be for the moment. I'll think about addressing this in a separate PR.
  • The plan-adoption-leave flow doesn't use next_node with a block for any of its questions and so I didn't need to make any changes to it.
  • Since there's currently no automatic check that question or outcome methods are called with the correct node types, there's a danger that some of them are called with the wrong node types. However, since I plan to add such a check in the future and calling with the wrong node type won't do any harm, I think it's more readable to use question & outcome rather than some kind of generic node method.

Testing

I added a script to generate a YAML representation of the possible next nodes for all the flows. I ran this script before and after the changes to double-check that using the automatic detection hadn't changed anything. However, the fact that the existing tests (including the regression tests) all pass also give me a lot of confidence.

Note

If I can find a way to use the automatic detection mechanism in benefit-cap-calculator, I plan to remove the code which allows the manual specification of permitted next nodes, but this will be in a separate PR.

Expected changes

None. However it might be worth checking that a couple of flow visualisation URLs work OK (not forgetting that the visualisation is currently broken in Chrome for other reasons):

@chrisroos

This comment has been minimized.

Copy link
Contributor

commented Mar 15, 2016

Does this need to be reviewed again, @floehopper? Or have you opened this ready to merge it to master given that PR #2362 is good to merge?

@floehopper

This comment has been minimized.

Copy link
Contributor Author

commented Mar 15, 2016

I think it's basically ready to merge as long as you're happy that I've addressed all your feedback.

@floehopper

This comment has been minimized.

Copy link
Contributor Author

commented Mar 16, 2016

Rebasing against master and force-pushing in preparation for merging.

floehopper added some commits Mar 10, 2016

Automatic next_node detection in benefit-cap-calculator
I couldn't use `:auto` for all the `next_node` blocks, because some of them have
dynamic results which can't be auto-detected.

floehopper added some commits Mar 14, 2016

Add script to generate permitted next nodes for all flows
I'm about to change all the flows to use the  mechanism for automatically
detecting permitted next nodes. Although the existing tests, particularly
the regression tests should give a lot of confidence that nothing gets
broken, I'm hoping to compare the results of this script before and after
the changes as a double-check.
Generate permitted next node YAML for all flows
I ran the following command:

    $ rails r script/generate-permitted-next-nodes-for-all-flows.rb
Remove permitted next node YAML - no longer needed
I ran the following command again:

    $ rails r script/generate-permitted-next-nodes-for-all-flows.rb

And the generated YAML was identical to the original version generated before
all the flows were changed to use the mechanism to automatically detect
permitted next nodes. So this file has served its purpose and can be removed.
Remove script to generate permitted next nodes for all flows
This script has served its purpose and can be removed.

@floehopper floehopper force-pushed the use-automatic-next-node-detection-in-existing-flows-with-feedback-addressed branch from 5e0b896 to e381356 Mar 16, 2016

floehopper added a commit that referenced this pull request Mar 16, 2016

Merge pull request #2368 from alphagov/use-automatic-next-node-detect…
…ion-in-existing-flows-with-feedback-addressed

Use automatic next node detection in existing flows (with feedback addressed)

@floehopper floehopper merged commit 926a856 into master Mar 16, 2016

1 check passed

default "Build #4462 succeeded on Jenkins"
Details

@floehopper floehopper deleted the use-automatic-next-node-detection-in-existing-flows-with-feedback-addressed branch Mar 16, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.