2016-02-12 23:52:43 +08:00
|
|
|
require 'test_helper'
|
|
|
|
|
|
|
|
class SampleMyModuleTest < ActiveSupport::TestCase
|
|
|
|
def setup
|
|
|
|
@sample_module = sample_my_modules(:one)
|
|
|
|
end
|
|
|
|
|
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_module.valid?
|
|
|
|
end
|
|
|
|
|
2017-01-25 20:56:43 +08:00
|
|
|
test 'should not validate with non existent sample' do
|
2016-02-12 23:52:43 +08:00
|
|
|
@sample_module.sample_id = 123123213
|
|
|
|
assert_not @sample_module.valid?
|
|
|
|
@sample_module.sample = nil
|
|
|
|
assert_not @sample_module.valid?
|
|
|
|
end
|
|
|
|
|
2017-01-25 20:56:43 +08:00
|
|
|
test 'should not validate with non existent my_module' do
|
2016-02-12 23:52:43 +08:00
|
|
|
@sample_module.my_module_id = 12312312
|
|
|
|
assert_not @sample_module.valid?
|
|
|
|
@sample_module.my_module = nil
|
|
|
|
assert_not @sample_module.valid?
|
|
|
|
end
|
|
|
|
|
2017-01-25 20:56:43 +08:00
|
|
|
test 'should have association my_module <-> sample' do
|
|
|
|
sample = Sample.create(name: 'test sample',
|
|
|
|
user: users(:jlaw),
|
|
|
|
team: teams(:biosistemika))
|
2016-02-12 23:52:43 +08:00
|
|
|
my_module = MyModule.create(
|
2017-01-25 20:56:43 +08:00
|
|
|
name: 'test module',
|
2016-07-27 16:49:13 +08:00
|
|
|
experiment: experiments(:philadelphia),
|
2016-02-12 23:52:43 +08:00
|
|
|
my_module_group: my_module_groups(:wf1)
|
|
|
|
)
|
|
|
|
|
|
|
|
assert_empty sample.my_modules
|
|
|
|
assert_empty my_module.samples
|
|
|
|
|
|
|
|
my_module.samples << sample
|
|
|
|
assert_equal sample, MyModule.find(my_module.id).samples.first
|
|
|
|
end
|
|
|
|
end
|