Skip to content

Commit

Permalink
Merge pull request #2058 from alphagov/add_test_for_interpolation_in_…
Browse files Browse the repository at this point in the history
…question_titles_for_maternity_paternity_and_adoption

Add missing calculated value in paternity calculator
  • Loading branch information
erkde committed Nov 6, 2015
2 parents 642c4f6 + 7f5c483 commit e1e61e3
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 1 deletion.
4 changes: 4 additions & 0 deletions lib/smart_answer_flows/shared_logic/paternity-calculator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,10 @@
due_date
end

calculate :qualifying_week_start do
calculator.qualifying_week.first
end

calculate :p_notice_leave do
calculator.notice_of_leave_deadline
end
Expand Down
2 changes: 1 addition & 1 deletion test/data/maternity-paternity-calculator-files.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ lib/smart_answer_flows/maternity-paternity-calculator/outcomes/paternity_leave_a
lib/smart_answer_flows/maternity-paternity-calculator/outcomes/paternity_not_entitled_to_leave_or_pay.govspeak.erb: 6909d514cd992d94400407ded6f4a024
lib/smart_answer_flows/shared_logic/adoption-calculator.rb: c166e63f0d4694acc664c789953659ba
lib/smart_answer_flows/shared_logic/maternity-calculator.rb: 5b566b38ef501d2a7c69a5e94ca18c2e
lib/smart_answer_flows/shared_logic/paternity-calculator.rb: 5aa842a23e800ee5575553f17dafbc39
lib/smart_answer_flows/shared_logic/paternity-calculator.rb: b09bdfd9c704ddbe78252173c4ccd0bd
lib/smart_answer/calculators/maternity_paternity_calculator.rb: 24de99189c23e9a7cc048871a817bb3c
lib/data/rates/maternity_paternity_birth.yml: 3eef956f1020576a9343647fec34dd01
lib/data/rates/maternity_paternity_adoption.yml: 453c4d90b6fd9ffe1556782665f313fc
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ class AdoptionCalculatorTest < ActiveSupport::TestCase
assert_state_variable "employee_has_contract_adoption", 'yes'
assert_current_node :adoption_is_the_employee_on_your_payroll?
end
should 'render the question title with an interpolated date' do
nodes = Capybara.string(current_question.to_s)
assert nodes.has_content?('Was the employee (or will they be) on your payroll on')
end
context "answer yes" do
setup { add_response :yes }
## QA6
Expand Down
7 changes: 7 additions & 0 deletions test/integration/smart_answer_flows/flow_test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,13 @@ def current_state
end
end

def current_question
@current_question ||= begin
presenter = QuestionPresenter.new("flow.#{@flow.name}", @flow.node(current_state.current_node), current_state)
presenter.title
end
end

def outcome_body
@outcome_body ||= begin
presenter = OutcomePresenter.new("flow.#{@flow.name}", @flow.node(current_state.current_node), current_state)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,10 @@ class MaternityCalculatorTest < ActiveSupport::TestCase
should "ask if the employee is on your payroll" do
assert_current_node :is_the_employee_on_your_payroll?
end
should 'render the question title with an interpolated date' do
nodes = Capybara.string(current_question.to_s)
assert nodes.has_content?('Was the employee (or will they be) on your payroll on')
end
context "answer yes" do
setup do
add_response :yes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,10 @@ class PaternityCalculatorTest < ActiveSupport::TestCase
assert_current_node :employee_on_payroll_paternity?
end

should 'render the question title with an interpolated date' do
nodes = Capybara.string(current_question.to_s)
assert nodes.has_content?('Was the employee (or will they be) on your payroll on')
end
context "answer yes" do
setup { add_response :yes }

Expand Down Expand Up @@ -332,6 +336,10 @@ class PaternityCalculatorTest < ActiveSupport::TestCase
assert_current_node :employee_on_payroll_paternity?
end

should 'render the question title with an interpolated date' do
nodes = Capybara.string(current_question.to_s)
assert nodes.has_content?('Was the employee (or will they be) on your payroll on')
end
context "answer no" do
setup { add_response :no }

Expand Down

0 comments on commit e1e61e3

Please sign in to comment.