mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2024-11-12 20:24:43 +08:00
38 lines
1.1 KiB
Ruby
38 lines
1.1 KiB
Ruby
|
require 'test_helper'
|
||
|
|
||
|
class SampleCustomFieldTest < ActiveSupport::TestCase
|
||
|
def setup
|
||
|
@sample_custom_field = sample_custom_fields(:one)
|
||
|
end
|
||
|
|
||
|
test "should validate with correct data" do
|
||
|
assert @sample_custom_field.valid?
|
||
|
end
|
||
|
|
||
|
test "should not validate without value" do
|
||
|
@sample_custom_field.value = ""
|
||
|
assert_not @sample_custom_field.valid?
|
||
|
@sample_custom_field.value = nil
|
||
|
assert_not @sample_custom_field.valid?
|
||
|
end
|
||
|
|
||
|
test "should validate to long value length" do
|
||
|
@sample_custom_field.value *= 100
|
||
|
assert_not @sample_custom_field.valid?
|
||
|
end
|
||
|
|
||
|
test "should not validate with non existent custom field" do
|
||
|
@sample_custom_field.custom_field_id = 123421321
|
||
|
assert_not @sample_custom_field.valid?
|
||
|
@sample_custom_field.custom_field = nil
|
||
|
assert_not @sample_custom_field.valid?
|
||
|
end
|
||
|
|
||
|
test "should not validate with non existent sample" do
|
||
|
@sample_custom_field.sample_id = 12313213
|
||
|
assert_not @sample_custom_field.valid?
|
||
|
@sample_custom_field.sample = nil
|
||
|
assert_not @sample_custom_field.valid?
|
||
|
end
|
||
|
end
|