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

Specify permitted next nodes for all flows #2010

Merged
merged 28 commits into from
Oct 14, 2015

Conversation

chrisroos
Copy link
Contributor

This supersedes PR #2002.

Trello card - https://trello.com/c/jtjRNOW9/97-update-all-flows-to-use-permitted-next-nodes

Based on feedback from @floehopper, I've added the permitted named option to Question::Base#next_node.

I've updated all flows that use next_node with a block to additionally supply the permitted next nodes.

I've updated Question::Base#next_node to raise an exception if it's called with a block but the permitted next nodes aren't specified.

I've updated Question::Base#next_node_for to raise an exception if the next_node isn't found in the list of permitted_next_nodes.

NOTE. Using next_node :symbol or next_node_if automatically add the nodes to permitted_next_nodes so I've only updated the flows/questions that use next_node with a block.

The advantage of using permitted_next_nodes is that it allows us to visualise the flows.

Expected user-visible changes

Visualisation should now be working for the following Smart Answers.

Example: Visualising additional-commodity-code

Before

permitted-next-nodes-before

After

permitted-next-nodes-after

This allows us to define the permitted next nodes by passing an option to
next_node, rather than having to use `permitted_next_nodes`.
@floehopper
Copy link
Contributor

Looks good to me. Maybe we should run all the regression tests before deploying these changes.

Move the `widow_pension_amount?` question before `widowed_mother_amount?`.

Responses to `multiple_choice` questions are always ordered alphabetically. This
flow iterates over the responses to the `:receiving_non_exemption_benefits?`
question and uses that to decide which node to display next. The alphabetical
ordering of responses means that `widow_pension_amount?` will always be asked
before `widowed_mother_amount?`.
I've also removed the unused `response` block argument to avoid the following
Rubocop warning: "Unused block argument - response".
I've also removed the unused `response` block argument to avoid the following
Rubocop warning: "Unused block argument - response".
We no longer have any graphs that can not be visualised
When calling `next_node` with a block.

This isn't foolproof as it only checks that we pass something as the `permitted`
option, and not that the permitted options actually make sense. It's probably
good enough to prevent people accidentally forgetting to specify the `permitted`
option.
This should help ensure that we supply the correct set of permitted next nodes
when calling `next_node` with a block.
@chrisroos chrisroos force-pushed the specify-permitted-next-nodes-for-all-flows branch from cee30eb to 8c785e4 Compare October 14, 2015 15:46
@chrisroos
Copy link
Contributor Author

Maybe we should run all the regression tests before deploying these changes.

Good shout! This caught some problems in my changes to benefit-cap-calculator. I've fixed the changes and force pushed.

@chrisroos
Copy link
Contributor Author

The regression tests have all passed locally so I'm going to get this merged to master!

chrisroos added a commit that referenced this pull request Oct 14, 2015
…or-all-flows

Specify permitted next nodes for all flows
@chrisroos chrisroos merged commit dc2ea2b into master Oct 14, 2015
@chrisroos chrisroos deleted the specify-permitted-next-nodes-for-all-flows branch October 14, 2015 16:25
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.

2 participants