Skip to content
Permalink
Browse files

Merge branch 'make-test-coverage-available-for-smart-answer-flows-2'

This converts all smart answer flows into subclasses of `SmartAnswer::Flow`,
except for the following which are currently being worked on by @tadast or
@BenJanecke.

* calculate-employee-redundancy-pay
* calculate-your-redundancy-pay
* calculate-statutory-sick-pay
* marriage-abroad

Note that the vast majority of "changes" in these commits are indentation
changes.
  • Loading branch information...
floehopper committed May 18, 2015
2 parents 4eea66d + c65ff2e commit 2910747663879e0b8d42fc32ff9fa41649ab49bf
Showing with 8,097 additions and 7,780 deletions.
  1. +56 −4 lib/smart_answer/flow_registry.rb
  2. +195 −187 lib/smart_answer_flows/additional-commodity-code.rb
  3. +11 −3 lib/smart_answer_flows/am-i-getting-minimum-wage.rb
  4. +153 −145 lib/smart_answer_flows/appeal-a-benefits-decision.rb
  5. +63 −55 lib/smart_answer_flows/apply-tier-4-visa.rb
  6. +383 −376 lib/smart_answer_flows/benefit-cap-calculator.rb
  7. +354 −346 lib/smart_answer_flows/benefits-abroad.rb
  8. +280 −273 lib/smart_answer_flows/benefits-if-you-are-abroad.rb
  9. +84 −77 lib/smart_answer_flows/calculate-agricultural-holiday-entitlement.rb
  10. +134 −126 lib/smart_answer_flows/calculate-married-couples-allowance.rb
  11. +498 −491 lib/smart_answer_flows/calculate-state-pension.rb
  12. +177 −170 lib/smart_answer_flows/calculate-your-child-maintenance.rb
  13. +277 −270 lib/smart_answer_flows/calculate-your-holiday-entitlement.rb
  14. +204 −197 lib/smart_answer_flows/check-uk-visa-v2.rb
  15. +204 −197 lib/smart_answer_flows/check-uk-visa.rb
  16. +228 −221 lib/smart_answer_flows/childcare-costs-for-tax-credits.rb
  17. +533 −526 lib/smart_answer_flows/energy-grants-calculator.rb
  18. +151 −144 lib/smart_answer_flows/estimate-self-assessment-penalties.rb
  19. +126 −119 lib/smart_answer_flows/help-if-you-are-arrested-abroad.rb
  20. +298 −291 lib/smart_answer_flows/inherits-someone-dies-without-will.rb
  21. +102 −95 lib/smart_answer_flows/legalisation-document-checker.rb
  22. +19 −12 lib/smart_answer_flows/maternity-paternity-calculator.rb
  23. +10 −3 lib/smart_answer_flows/minimum-wage-calculator-employers.rb
  24. +491 −484 lib/smart_answer_flows/overseas-passports.rb
  25. +59 −52 lib/smart_answer_flows/pip-checker.rb
  26. +59 −52 lib/smart_answer_flows/plan-adoption-leave.rb
  27. +408 −401 lib/smart_answer_flows/register-a-birth.rb
  28. +298 −291 lib/smart_answer_flows/register-a-death.rb
  29. +44 −37 lib/smart_answer_flows/report-a-lost-or-stolen-passport.rb
  30. +321 −314 lib/smart_answer_flows/simplified-expenses-checker-v2.rb
  31. +321 −314 lib/smart_answer_flows/simplified-expenses-checker.rb
  32. +136 −129 lib/smart_answer_flows/state-pension-through-partner.rb
  33. +78 −71 lib/smart_answer_flows/state-pension-topup.rb
  34. +244 −237 lib/smart_answer_flows/student-finance-calculator.rb
  35. +147 −140 lib/smart_answer_flows/towing-rules.rb
  36. +453 −446 lib/smart_answer_flows/uk-benefits-abroad-v2.rb
  37. +450 −443 lib/smart_answer_flows/uk-benefits-abroad.rb
  38. +48 −41 lib/smart_answer_flows/vat-payment-deadlines.rb
@@ -1,3 +1,47 @@
SMART_ANSWER_FLOW_NAMES = %w(
additional-commodity-code
am-i-getting-minimum-wage
appeal-a-benefits-decision
apply-tier-4-visa
benefit-cap-calculator
benefits-abroad
benefits-if-you-are-abroad
calculate-agricultural-holiday-entitlement
calculate-married-couples-allowance
calculate-state-pension
calculate-your-child-maintenance
calculate-your-holiday-entitlement
check-uk-visa-v2
check-uk-visa
childcare-costs-for-tax-credits
energy-grants-calculator
estimate-self-assessment-penalties
help-if-you-are-arrested-abroad
inherits-someone-dies-without-will
legalisation-document-checker
maternity-paternity-calculator
minimum-wage-calculator-employers
overseas-passports
pip-checker
plan-adoption-leave
register-a-birth
register-a-death
report-a-lost-or-stolen-passport
simplified-expenses-checker-v2
simplified-expenses-checker
state-pension-through-partner
state-pension-topup
student-finance-calculator
towing-rules
uk-benefits-abroad-v2
uk-benefits-abroad
vat-payment-deadlines
)

SMART_ANSWER_FLOW_NAMES.each do |name|
require "smart_answer_flows/#{name}"
end

module SmartAnswer
class FlowRegistry
class NotFound < StandardError; end
@@ -51,10 +95,18 @@ def available?(name)
end

def build_flow(name)
absolute_path = @load_path.join("#{name}.rb").to_s
Flow.new do
eval(File.read(absolute_path), binding, absolute_path)
name(name)
if SMART_ANSWER_FLOW_NAMES.include?(name)
class_prefix = name.gsub("-", "_").camelize
namespaced_class = "SmartAnswer::#{class_prefix}Flow".constantize
flow = namespaced_class.new
flow.define
flow
else
absolute_path = @load_path.join("#{name}.rb").to_s
Flow.new do
eval(File.read(absolute_path), binding, absolute_path)
name(name)
end
end
end

2 comments on commit 2910747

@tadast

This comment has been minimized.

Copy link
Contributor

replied May 19, 2015

@floehopper I was wondering if you have plans to change the way we pick up the flows. If I understand correctly, now a new flow would need to be added to SMART_ANSWER_FLOW_NAMES. Once we're done migrating all flows we could just pick all the files from the dir and iterate through them perhaps?

We could also infer the flow names from class names, but I'm not sure about the cost to benefit ratio, as this could cause some confusion unless we have good error messages :)

Also, if anyone else is reviewing this, adding ?w=1 to the URL helps a lot

@floehopper

This comment has been minimized.

Copy link
Contributor Author

replied May 19, 2015

The SMART_ANSWER_FLOW_NAMES constant is just a temporary measure so I could gradually convert a flow at a time. I was planning to switch back to finding all the flow names from the files in the directory as before once all of the flows have been converted.

Please sign in to comment.
You can’t perform that action at this time.