diff --git a/lib/xeroizer/models/line_item.rb b/lib/xeroizer/models/line_item.rb index de6f39f6b..01f0a30bb 100644 --- a/lib/xeroizer/models/line_item.rb +++ b/lib/xeroizer/models/line_item.rb @@ -24,6 +24,8 @@ class LineItem < Base has_many :tracking, :model_name => 'TrackingCategoryChild' + validates_presence_of :description + def initialize(parent) super(parent) @line_amount_set = false diff --git a/test/unit/models/line_item_test.rb b/test/unit/models/line_item_test.rb index 602c54695..eab4e469c 100644 --- a/test/unit/models/line_item_test.rb +++ b/test/unit/models/line_item_test.rb @@ -56,4 +56,21 @@ def setup assert_equal 50, line_item.line_amount, "expected line amount to be calculated from coerced values" end + + context "line_item validations" do + + it "is an invalid line_item if there is no description" do + line_item = LineItem.new(nil) + + assert_equal(false, line_item.valid?) + end + + it "is a valid line_item with minimal attributes" do + line_item = LineItem.new(nil) + line_item.description = "Test Description" + + assert_equal(true, line_item.valid?) + end + + end end