scinote-web/test/models/sample_my_module_test.rb

44 lines
1.2 KiB
Ruby
Raw Normal View History

2016-02-12 23:52:43 +08:00
require 'test_helper'
class SampleMyModuleTest < ActiveSupport::TestCase
def setup
@sample_module = sample_my_modules(:one)
end
test "should validate with correct data" do
assert @sample_module.valid?
end
test "should not validate with non existent sample" do
@sample_module.sample_id = 123123213
assert_not @sample_module.valid?
@sample_module.sample = nil
assert_not @sample_module.valid?
end
test "should not validate with non existent my_module" do
@sample_module.my_module_id = 12312312
assert_not @sample_module.valid?
@sample_module.my_module = nil
assert_not @sample_module.valid?
end
test "should have association my_module <-> sample" do
sample = Sample.create(
name: "test sample",
user: users(:jlaw),
organization: organizations(:biosistemika))
my_module = MyModule.create(
name: "test module",
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