scinote-web/test/models/sample_group_test.rb

23 lines
600 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)
2017-01-25 20:56:43 +08:00
should validate_presence_of(:team)
2016-10-11 14:25:32 +08:00
2017-01-25 20:56:43 +08:00
test 'should validate with correct data' do
2016-02-12 23:52:43 +08:00
assert @sample_group.valid?
end
2017-01-25 20:56:43 +08:00
test 'should not validate without team' do
@sample_group.team = nil
2016-02-12 23:52:43 +08:00
assert_not @sample_group.valid?
end
end