Skip to content

Commit

Permalink
Merge branch 'ignore-nil-monetary-nodes'
Browse files Browse the repository at this point in the history
  • Loading branch information
Harry Mills committed Nov 5, 2014
2 parents b50ec53 + 978d78b commit 65189e8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/hermod/xml_section_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ def monetary_node(name, options={})
end

create_method(name, [], validators, options) do |value, attributes|
value = value.to_i
if options[:optional] && value == 0
[nil, attributes]
else
Expand Down
8 changes: 8 additions & 0 deletions spec/hermod/xml_section_builder/monetary_node_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,14 @@ module Hermod
ex = proc { subject.student_loan 0 }.must_raise Hermod::InvalidInputError
ex.message.must_equal "student_loan cannot be zero"
end

it "should treat blank nodes as zero nodes" do
subject.ni nil
value_of_node("NI").must_equal "0.00"

subject.tax nil
nodes("Tax").must_be_empty
end
end
end
end

0 comments on commit 65189e8

Please sign in to comment.