Method: Ccls::FactoryTestHelper#create_home_exposure_with_study_subject

Defined in:
lib/ccls_engine/factory_test_helper.rb

#create_home_exposure_with_study_subject(options = {}) ⇒ Object Also known as: create_hx_study_subject

../ccls_engine/test/unit/ccls/study_subject_test.rb ../homex/test/functional/followup/study_subjects_controller_test.rb ../homex/test/functional/home_exposure_responses_controller_test.rb ../homex/test/functional/interview/study_subjects_controller_test.rb ../homex/test/functional/sample/study_subjects_controller_test.rb ../homex/test/functional/study_subjects_controller_test.rb



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/ccls_engine/factory_test_helper.rb', line 9

def create_home_exposure_with_study_subject(options={})
	study_subject = project = nil
	unless options[:patient].nil?
		options[:study_subject] ||= {}
		options[:study_subject][:subject_type] = SubjectType['Case']
	end
	assert_difference('StudySubject.count',1) {
		study_subject    = Factory(:study_subject,options[:study_subject]||{})
	}
	project = Project.find_or_create_by_key('HomeExposures')
	assert_not_nil project
	assert_difference('StudySubject.count',0) {
	assert_difference('Enrollment.count',1) {
		Factory(:enrollment, (options[:enrollment]||{}).merge(
			:study_subject => study_subject, :project => project ))
	} }
	unless options[:patient].nil?
		assert_difference('StudySubject.count',0) {
		assert_difference('Patient.count',1) {
			Factory(:patient, :study_subject => study_subject )
		} }
	end
	study_subject
end