Skip to content

Commit

Permalink
Merge pull request #517 from mhssmnn/line-item-description-validation
Browse files Browse the repository at this point in the history
Add description validation to line items
  • Loading branch information
CloCkWeRX authored Jan 24, 2021
2 parents 3969a6a + 23a62f8 commit df856d1
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/xeroizer/models/line_item.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
17 changes: 17 additions & 0 deletions test/unit/models/line_item_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit df856d1

Please sign in to comment.