scinote-web/test/models/sample_group_test.rb

23 lines
624 B
Ruby
Raw Normal View History

2016-02-12 23:52:43 +08:00
require 'test_helper'
class SampleGroupTest < ActiveSupport::TestCase
def setup
@sample_group = sample_groups(:blood)
end
2016-10-11 14:25:32 +08:00
should validate_presence_of(:name)
should validate_length_of(:name).is_at_most(Constants::NAME_MAX_LENGTH)
2016-10-11 14:25:32 +08:00
should validate_presence_of(:color)
should validate_length_of(:color).is_at_most(Constants::COLOR_MAX_LENGTH)
2016-10-11 14:25:32 +08:00
should validate_presence_of(:organization)
2016-02-12 23:52:43 +08:00
test "should validate with correct data" do
assert @sample_group.valid?
end
test "should not validate without organization" do
@sample_group.organization = nil
assert_not @sample_group.valid?
end
end