scinote-web/test/models/custom_field_test.rb

36 lines
943 B
Ruby
Raw Normal View History

2016-02-12 23:52:43 +08:00
require 'test_helper'
class CustomFieldTest < ActiveSupport::TestCase
def setup
@custom_field = custom_fields(:volume)
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_exclusion_of(:name)
.in_array(['Assigned',
'Sample name',
'Sample type',
'Sample group',
'Added on',
'Added by'])
2017-01-25 20:56:43 +08:00
test 'should validate with correct data' do
2016-02-12 23:52:43 +08:00
assert @custom_field.valid?
end
2017-01-25 20:56:43 +08:00
test 'should not validate with non existent user' do
2016-02-12 23:52:43 +08:00
@custom_field.user_id = 11231231
assert_not @custom_field.valid?
@custom_field.user = nil
assert_not @custom_field.valid?
end
2017-01-25 20:56:43 +08:00
test 'should not validate with non existent team' do
@custom_field.team_id = 1231231
2016-02-12 23:52:43 +08:00
assert_not @custom_field.valid?
2017-01-25 20:56:43 +08:00
@custom_field.team = nil
2016-02-12 23:52:43 +08:00
assert_not @custom_field.valid?
end
end