ccls-ccls_engine 3.11.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +182 -0
- data/app/models/abstract.rb +181 -0
- data/app/models/abstract_search.rb +50 -0
- data/app/models/abstract_validations.rb +324 -0
- data/app/models/address.rb +70 -0
- data/app/models/address_type.rb +15 -0
- data/app/models/addressing.rb +147 -0
- data/app/models/aliquot.rb +44 -0
- data/app/models/aliquot_sample_format.rb +13 -0
- data/app/models/analysis.rb +14 -0
- data/app/models/bc_request.rb +20 -0
- data/app/models/candidate_control.rb +101 -0
- data/app/models/context.rb +23 -0
- data/app/models/context_data_source.rb +4 -0
- data/app/models/county.rb +16 -0
- data/app/models/data_source.rb +24 -0
- data/app/models/diagnosis.rb +23 -0
- data/app/models/document_type.rb +16 -0
- data/app/models/document_version.rb +27 -0
- data/app/models/enrollment.rb +78 -0
- data/app/models/enrollment_validations.rb +167 -0
- data/app/models/follow_up.rb +16 -0
- data/app/models/follow_up_type.rb +18 -0
- data/app/models/gift_card.rb +22 -0
- data/app/models/gift_card_search.rb +137 -0
- data/app/models/home_exposure_response.rb +24 -0
- data/app/models/homex_outcome.rb +75 -0
- data/app/models/hospital.rb +22 -0
- data/app/models/icf_master_id.rb +30 -0
- data/app/models/icf_master_tracker.rb +217 -0
- data/app/models/icf_master_tracker_change.rb +9 -0
- data/app/models/icf_master_tracker_update.rb +50 -0
- data/app/models/ineligible_reason.rb +26 -0
- data/app/models/instrument.rb +26 -0
- data/app/models/instrument_type.rb +17 -0
- data/app/models/instrument_version.rb +28 -0
- data/app/models/interview.rb +122 -0
- data/app/models/interview_method.rb +17 -0
- data/app/models/interview_outcome.rb +16 -0
- data/app/models/language.rb +28 -0
- data/app/models/live_birth_data_update.rb +142 -0
- data/app/models/operational_event.rb +99 -0
- data/app/models/operational_event_type.rb +31 -0
- data/app/models/organization.rb +28 -0
- data/app/models/patient.rb +63 -0
- data/app/models/patient_validations.rb +118 -0
- data/app/models/person.rb +28 -0
- data/app/models/phone_number.rb +105 -0
- data/app/models/phone_type.rb +15 -0
- data/app/models/project.rb +39 -0
- data/app/models/project_outcome.rb +19 -0
- data/app/models/race.rb +31 -0
- data/app/models/refusal_reason.rb +23 -0
- data/app/models/sample.rb +168 -0
- data/app/models/sample_kit.rb +14 -0
- data/app/models/sample_outcome.rb +16 -0
- data/app/models/sample_temperature.rb +14 -0
- data/app/models/sample_type.rb +37 -0
- data/app/models/search.rb +195 -0
- data/app/models/section.rb +18 -0
- data/app/models/state.rb +25 -0
- data/app/models/study_subject.rb +237 -0
- data/app/models/study_subject_abstracts.rb +47 -0
- data/app/models/study_subject_addresses.rb +34 -0
- data/app/models/study_subject_associations.rb +38 -0
- data/app/models/study_subject_duplicates.rb +111 -0
- data/app/models/study_subject_enrollments.rb +17 -0
- data/app/models/study_subject_homex_outcome.rb +22 -0
- data/app/models/study_subject_identifier.rb +153 -0
- data/app/models/study_subject_interviews.rb +25 -0
- data/app/models/study_subject_languages.rb +21 -0
- data/app/models/study_subject_operational_events.rb +66 -0
- data/app/models/study_subject_patient.rb +177 -0
- data/app/models/study_subject_pii.rb +74 -0
- data/app/models/study_subject_races.rb +25 -0
- data/app/models/study_subject_search.rb +260 -0
- data/app/models/study_subject_validations.rb +116 -0
- data/app/models/subject_language.rb +11 -0
- data/app/models/subject_race.rb +11 -0
- data/app/models/subject_relationship.rb +21 -0
- data/app/models/subject_type.rb +22 -0
- data/app/models/tracing_status.rb +20 -0
- data/app/models/transfer.rb +40 -0
- data/app/models/unit.rb +14 -0
- data/app/models/vital_status.rb +19 -0
- data/app/models/zip_code.rb +36 -0
- data/config/abstract_fields.yml +1038 -0
- data/config/abstract_sections.yml +77 -0
- data/config/home_exposure_response_fields.yml +583 -0
- data/config/icf_master_tracker_update.yml +56 -0
- data/config/live_birth_data_update.yml +56 -0
- data/config/shared_use_db.yml +4 -0
- data/generators/ccls_engine/USAGE +2 -0
- data/generators/ccls_engine/ccls_engine_generator.rb +123 -0
- data/generators/ccls_engine/templates/autotest_ccls_engine.rb +3 -0
- data/generators/ccls_engine/templates/ccls_engine.rake +12 -0
- data/generators/ccls_engine/templates/fixtures/address_types.yml +30 -0
- data/generators/ccls_engine/templates/fixtures/context_data_sources.yml +54 -0
- data/generators/ccls_engine/templates/fixtures/contexts.yml +19 -0
- data/generators/ccls_engine/templates/fixtures/data_sources.yml +40 -0
- data/generators/ccls_engine/templates/fixtures/diagnoses.yml +40 -0
- data/generators/ccls_engine/templates/fixtures/document_types.yml +65 -0
- data/generators/ccls_engine/templates/fixtures/document_versions.csv +155 -0
- data/generators/ccls_engine/templates/fixtures/follow_up_types.yml +16 -0
- data/generators/ccls_engine/templates/fixtures/hospitals.yml +114 -0
- data/generators/ccls_engine/templates/fixtures/ineligible_reasons.yml +35 -0
- data/generators/ccls_engine/templates/fixtures/instrument_types.yml +26 -0
- data/generators/ccls_engine/templates/fixtures/instrument_versions.yml +22 -0
- data/generators/ccls_engine/templates/fixtures/instruments.yml +22 -0
- data/generators/ccls_engine/templates/fixtures/interview_methods.yml +30 -0
- data/generators/ccls_engine/templates/fixtures/interview_outcomes.yml +31 -0
- data/generators/ccls_engine/templates/fixtures/languages.yml +34 -0
- data/generators/ccls_engine/templates/fixtures/operational_event_types.yml +141 -0
- data/generators/ccls_engine/templates/fixtures/organizations.yml +198 -0
- data/generators/ccls_engine/templates/fixtures/people.yml +130 -0
- data/generators/ccls_engine/templates/fixtures/phone_types.yml +30 -0
- data/generators/ccls_engine/templates/fixtures/project_outcomes.yml +25 -0
- data/generators/ccls_engine/templates/fixtures/projects.yml +59 -0
- data/generators/ccls_engine/templates/fixtures/races.yml +52 -0
- data/generators/ccls_engine/templates/fixtures/refusal_reasons.yml +55 -0
- data/generators/ccls_engine/templates/fixtures/sample_outcomes.yml +36 -0
- data/generators/ccls_engine/templates/fixtures/sample_temperatures.yml +16 -0
- data/generators/ccls_engine/templates/fixtures/sample_types.yml +147 -0
- data/generators/ccls_engine/templates/fixtures/sections.yml +31 -0
- data/generators/ccls_engine/templates/fixtures/states.yml +363 -0
- data/generators/ccls_engine/templates/fixtures/subject_relationships.yml +46 -0
- data/generators/ccls_engine/templates/fixtures/subject_types.yml +30 -0
- data/generators/ccls_engine/templates/fixtures/tracing_statuses.yml +30 -0
- data/generators/ccls_engine/templates/fixtures/units.yml +13 -0
- data/generators/ccls_engine/templates/fixtures/vital_statuses.yml +28 -0
- data/generators/ccls_engine/templates/functional/roles_controller_test.rb +142 -0
- data/generators/ccls_engine/templates/functional/sessions_controller_test.rb +19 -0
- data/generators/ccls_engine/templates/functional/users_controller_test.rb +94 -0
- data/generators/ccls_engine/templates/images/sort_down.png +0 -0
- data/generators/ccls_engine/templates/images/sort_up.png +0 -0
- data/generators/ccls_engine/templates/initializer.rb +28 -0
- data/generators/ccls_engine/templates/javascripts/ccls_engine.js +24 -0
- data/generators/ccls_engine/templates/javascripts/jquery-ui.js +763 -0
- data/generators/ccls_engine/templates/javascripts/jquery.js +154 -0
- data/generators/ccls_engine/templates/javascripts/jrails.js +1 -0
- data/generators/ccls_engine/templates/migrations/create_user_invitations.rb +18 -0
- data/generators/ccls_engine/templates/migrations/create_users.rb +33 -0
- data/generators/ccls_engine/templates/migrations/drop_user_invitations.rb +18 -0
- data/generators/ccls_engine/templates/stylesheets/ccls_engine.css +180 -0
- data/generators/ccls_engine/templates/stylesheets/user.css +35 -0
- data/generators/ccls_engine/templates/stylesheets/users.css +23 -0
- data/generators/ccls_engine/templates/unit/core_extension_test.rb +18 -0
- data/generators/ccls_engine/templates/unit/role_test.rb +30 -0
- data/generators/ccls_engine/templates/unit/user_test.rb +321 -0
- data/lib/ccls-ccls_engine.rb +1 -0
- data/lib/ccls_engine.rb +135 -0
- data/lib/ccls_engine/action_view_extension.rb +3 -0
- data/lib/ccls_engine/action_view_extension/base.rb +53 -0
- data/lib/ccls_engine/action_view_extension/form_builder.rb +39 -0
- data/lib/ccls_engine/active_record_extension.rb +2 -0
- data/lib/ccls_engine/active_record_extension/base.rb +70 -0
- data/lib/ccls_engine/active_record_shared.rb +8 -0
- data/lib/ccls_engine/assertions.rb +69 -0
- data/lib/ccls_engine/autotest.rb +54 -0
- data/lib/ccls_engine/ccls_user.rb +117 -0
- data/lib/ccls_engine/core_extension.rb +14 -0
- data/lib/ccls_engine/date_and_time_formats.rb +30 -0
- data/lib/ccls_engine/factories.rb +880 -0
- data/lib/ccls_engine/factory_test_helper.rb +276 -0
- data/lib/ccls_engine/helper.rb +112 -0
- data/lib/ccls_engine/icf_master_tracker_update_test_helper.rb +121 -0
- data/lib/ccls_engine/live_birth_data_update_test_helper.rb +110 -0
- data/lib/ccls_engine/package_test_helper.rb +49 -0
- data/lib/ccls_engine/shared_database.rb +20 -0
- data/lib/ccls_engine/tasks.rb +1 -0
- data/lib/ccls_engine/test_tasks.rb +52 -0
- data/lib/ccls_engine/translation_table.rb +86 -0
- data/lib/shared_migration.rb +5 -0
- data/lib/surveyor/survey_extensions.rb +125 -0
- data/lib/tasks/application.rake +286 -0
- data/lib/tasks/calnet_authenticated.rake +6 -0
- data/lib/tasks/common_lib.rake +7 -0
- data/lib/tasks/database.rake +288 -0
- data/lib/tasks/documentation.rake +71 -0
- data/lib/tasks/homex_import.rake +723 -0
- data/lib/tasks/odms_import.rake +1116 -0
- data/lib/tasks/simply_authorized.rake +6 -0
- data/lib/tasks/ucb_ccls_engine_tasks.rake +4 -0
- data/lib/tasks/use_db.rake +4 -0
- data/rails/init.rb +4 -0
- data/test/unit/ccls/abstract_search_test.rb +150 -0
- data/test/unit/ccls/abstract_test.rb +674 -0
- data/test/unit/ccls/address_test.rb +155 -0
- data/test/unit/ccls/address_type_test.rb +25 -0
- data/test/unit/ccls/addressing_test.rb +466 -0
- data/test/unit/ccls/aliquot_sample_format_test.rb +20 -0
- data/test/unit/ccls/aliquot_test.rb +156 -0
- data/test/unit/ccls/analysis_test.rb +31 -0
- data/test/unit/ccls/bc_request_test.rb +43 -0
- data/test/unit/ccls/candidate_control_test.rb +712 -0
- data/test/unit/ccls/context_data_source_test.rb +26 -0
- data/test/unit/ccls/context_test.rb +40 -0
- data/test/unit/ccls/core_extension_test.rb +17 -0
- data/test/unit/ccls/county_test.rb +34 -0
- data/test/unit/ccls/data_source_test.rb +41 -0
- data/test/unit/ccls/diagnosis_test.rb +51 -0
- data/test/unit/ccls/document_type_test.rb +35 -0
- data/test/unit/ccls/document_version_test.rb +68 -0
- data/test/unit/ccls/enrollment_test.rb +575 -0
- data/test/unit/ccls/follow_up_test.rb +23 -0
- data/test/unit/ccls/follow_up_type_test.rb +34 -0
- data/test/unit/ccls/gift_card_search_test.rb +153 -0
- data/test/unit/ccls/gift_card_test.rb +40 -0
- data/test/unit/ccls/home_exposure_response_test.rb +83 -0
- data/test/unit/ccls/homex_outcome_test.rb +199 -0
- data/test/unit/ccls/hospital_test.rb +102 -0
- data/test/unit/ccls/icf_master_id_test.rb +30 -0
- data/test/unit/ccls/icf_master_tracker_change_test.rb +14 -0
- data/test/unit/ccls/icf_master_tracker_test.rb +132 -0
- data/test/unit/ccls/icf_master_tracker_update_test.rb +176 -0
- data/test/unit/ccls/ineligible_reason_test.rb +48 -0
- data/test/unit/ccls/instrument_test.rb +62 -0
- data/test/unit/ccls/instrument_type_test.rb +39 -0
- data/test/unit/ccls/instrument_version_test.rb +71 -0
- data/test/unit/ccls/interview_method_test.rb +44 -0
- data/test/unit/ccls/interview_outcome_test.rb +34 -0
- data/test/unit/ccls/interview_test.rb +298 -0
- data/test/unit/ccls/language_test.rb +47 -0
- data/test/unit/ccls/live_birth_data_update_test.rb +358 -0
- data/test/unit/ccls/operational_event_test.rb +187 -0
- data/test/unit/ccls/operational_event_type_test.rb +51 -0
- data/test/unit/ccls/organization_test.rb +64 -0
- data/test/unit/ccls/patient_test.rb +538 -0
- data/test/unit/ccls/person_test.rb +55 -0
- data/test/unit/ccls/phone_number_test.rb +244 -0
- data/test/unit/ccls/phone_type_test.rb +32 -0
- data/test/unit/ccls/project_outcome_test.rb +34 -0
- data/test/unit/ccls/project_test.rb +60 -0
- data/test/unit/ccls/race_test.rb +37 -0
- data/test/unit/ccls/refusal_reason_test.rb +52 -0
- data/test/unit/ccls/role_test.rb +26 -0
- data/test/unit/ccls/sample_kit_test.rb +35 -0
- data/test/unit/ccls/sample_outcome_test.rb +34 -0
- data/test/unit/ccls/sample_temperature_test.rb +25 -0
- data/test/unit/ccls/sample_test.rb +363 -0
- data/test/unit/ccls/sample_type_test.rb +58 -0
- data/test/unit/ccls/section_test.rb +34 -0
- data/test/unit/ccls/state_test.rb +31 -0
- data/test/unit/ccls/study_subject_abstracts_test.rb +115 -0
- data/test/unit/ccls/study_subject_addresses_test.rb +93 -0
- data/test/unit/ccls/study_subject_duplicates_test.rb +407 -0
- data/test/unit/ccls/study_subject_enrollments_test.rb +65 -0
- data/test/unit/ccls/study_subject_homex_outcome_test.rb +64 -0
- data/test/unit/ccls/study_subject_identifier_test.rb +439 -0
- data/test/unit/ccls/study_subject_interviews_test.rb +26 -0
- data/test/unit/ccls/study_subject_languages_test.rb +142 -0
- data/test/unit/ccls/study_subject_operational_events_test.rb +53 -0
- data/test/unit/ccls/study_subject_patient_test.rb +249 -0
- data/test/unit/ccls/study_subject_pii_test.rb +278 -0
- data/test/unit/ccls/study_subject_races_test.rb +203 -0
- data/test/unit/ccls/study_subject_search_test.rb +704 -0
- data/test/unit/ccls/study_subject_test.rb +770 -0
- data/test/unit/ccls/subject_language_test.rb +43 -0
- data/test/unit/ccls/subject_race_test.rb +35 -0
- data/test/unit/ccls/subject_relationship_test.rb +43 -0
- data/test/unit/ccls/subject_type_test.rb +40 -0
- data/test/unit/ccls/tracing_status_test.rb +32 -0
- data/test/unit/ccls/transfer_test.rb +81 -0
- data/test/unit/ccls/translation_table_test.rb +40 -0
- data/test/unit/ccls/unit_test.rb +21 -0
- data/test/unit/ccls/user_test.rb +156 -0
- data/test/unit/ccls/vital_status_test.rb +36 -0
- data/test/unit/ccls/zip_code_test.rb +55 -0
- metadata +633 -0
@@ -0,0 +1,52 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class Ccls::RefusalReasonTest < ActiveSupport::TestCase
|
4
|
+
|
5
|
+
assert_should_behave_like_a_hash
|
6
|
+
|
7
|
+
# Only IF study_subject not consented
|
8
|
+
# assert_should_have_many(:enrollments)
|
9
|
+
|
10
|
+
assert_should_create_default_object
|
11
|
+
assert_should_act_as_list
|
12
|
+
assert_should_not_require_attributes( :position )
|
13
|
+
|
14
|
+
test "explicit Factory refusal_reason test" do
|
15
|
+
assert_difference('RefusalReason.count',1) {
|
16
|
+
refusal_reason = Factory(:refusal_reason)
|
17
|
+
assert_match /Key\d*/, refusal_reason.key
|
18
|
+
assert_match /Desc\d*/, refusal_reason.description
|
19
|
+
}
|
20
|
+
end
|
21
|
+
|
22
|
+
test "should return description as to_s" do
|
23
|
+
refusal_reason = create_refusal_reason
|
24
|
+
assert_equal refusal_reason.description, "#{refusal_reason}"
|
25
|
+
end
|
26
|
+
|
27
|
+
test "should find random" do
|
28
|
+
refusal_reason = RefusalReason.random()
|
29
|
+
assert refusal_reason.is_a?(RefusalReason)
|
30
|
+
end
|
31
|
+
|
32
|
+
test "should return nil on random when no records" do
|
33
|
+
# RefusalReason.destroy_all
|
34
|
+
RefusalReason.stubs(:count).returns(0)
|
35
|
+
refusal_reason = RefusalReason.random()
|
36
|
+
assert_nil refusal_reason
|
37
|
+
end
|
38
|
+
|
39
|
+
test "should return true for is_other if is other" do
|
40
|
+
refusal_reason = RefusalReason['Other']
|
41
|
+
assert refusal_reason.is_other?
|
42
|
+
end
|
43
|
+
|
44
|
+
#protected
|
45
|
+
#
|
46
|
+
# def create_refusal_reason(options={})
|
47
|
+
# refusal_reason = Factory.build(:refusal_reason,options)
|
48
|
+
# refusal_reason.save
|
49
|
+
# refusal_reason
|
50
|
+
# end
|
51
|
+
|
52
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class Ccls::RoleTest < ActiveSupport::TestCase
|
4
|
+
|
5
|
+
assert_should_act_as_list
|
6
|
+
assert_should_require(:name)
|
7
|
+
assert_should_require_unique(:name)
|
8
|
+
assert_should_habtm(:users)
|
9
|
+
|
10
|
+
test "should create role" do
|
11
|
+
assert_difference('Role.count',1) do
|
12
|
+
role = create_role
|
13
|
+
assert !role.new_record?,
|
14
|
+
"#{role.errors.full_messages.to_sentence}"
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
#protected
|
19
|
+
#
|
20
|
+
# def create_role(options = {})
|
21
|
+
# role = Factory.build(:role,options)
|
22
|
+
# role.save
|
23
|
+
# role
|
24
|
+
# end
|
25
|
+
|
26
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class Ccls::SampleKitTest < ActiveSupport::TestCase
|
4
|
+
|
5
|
+
assert_should_create_default_object
|
6
|
+
assert_should_initially_belong_to( :sample )
|
7
|
+
assert_should_require_unique_attribute( :sample_id )
|
8
|
+
|
9
|
+
test "explicit Factory sample_kit test" do
|
10
|
+
assert_difference('Sample.count',1) {
|
11
|
+
assert_difference('SampleKit.count',1) {
|
12
|
+
sample_kit = Factory(:sample_kit)
|
13
|
+
assert_not_nil sample_kit.sample
|
14
|
+
} }
|
15
|
+
end
|
16
|
+
|
17
|
+
test "should require a unique sample" do
|
18
|
+
assert_difference( "SampleKit.count", 1 ) {
|
19
|
+
assert_difference('Sample.count', 1) {
|
20
|
+
sample_kit = create_sample_kit
|
21
|
+
assert_not_nil sample_kit.sample
|
22
|
+
sample_kit = create_sample_kit(:sample_id => sample_kit.sample_id)
|
23
|
+
assert sample_kit.errors.on(:sample_id)
|
24
|
+
} }
|
25
|
+
end
|
26
|
+
|
27
|
+
#protected
|
28
|
+
#
|
29
|
+
# def create_sample_kit(options={})
|
30
|
+
# sample_kit = Factory.build(:sample_kit,options)
|
31
|
+
# sample_kit.save
|
32
|
+
# sample_kit
|
33
|
+
# end
|
34
|
+
|
35
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class Ccls::SampleOutcomeTest < ActiveSupport::TestCase
|
4
|
+
|
5
|
+
assert_should_behave_like_a_hash
|
6
|
+
|
7
|
+
assert_should_create_default_object
|
8
|
+
assert_should_act_as_list
|
9
|
+
assert_should_have_many( :homex_outcomes )
|
10
|
+
assert_should_not_require_attributes( :position )
|
11
|
+
|
12
|
+
test "explicit Factory sample_outcome test" do
|
13
|
+
assert_difference('SampleOutcome.count',1) {
|
14
|
+
sample_outcome = Factory(:sample_outcome)
|
15
|
+
assert_match /Key\d*/, sample_outcome.key
|
16
|
+
assert_match /Desc\d*/, sample_outcome.description
|
17
|
+
}
|
18
|
+
end
|
19
|
+
|
20
|
+
test "should return description as to_s" do
|
21
|
+
sample_outcome = create_sample_outcome(:description => "Description")
|
22
|
+
assert_equal sample_outcome.description,
|
23
|
+
"#{sample_outcome}"
|
24
|
+
end
|
25
|
+
|
26
|
+
#protected
|
27
|
+
#
|
28
|
+
# def create_sample_outcome(options={})
|
29
|
+
# sample_outcome = Factory.build(:sample_outcome,options)
|
30
|
+
# sample_outcome.save
|
31
|
+
# sample_outcome
|
32
|
+
# end
|
33
|
+
|
34
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class Ccls::SampleTemperatureTest < ActiveSupport::TestCase
|
4
|
+
|
5
|
+
assert_should_behave_like_a_hash
|
6
|
+
|
7
|
+
assert_should_create_default_object
|
8
|
+
assert_should_act_as_list
|
9
|
+
assert_should_not_require_attributes( :position )
|
10
|
+
assert_should_have_many(:samples)
|
11
|
+
|
12
|
+
test "explicit Factory sample temperature test" do
|
13
|
+
assert_difference('SampleTemperature.count',1) {
|
14
|
+
sample_temperature = Factory(:sample_temperature)
|
15
|
+
assert_match /Key\d*/, sample_temperature.key
|
16
|
+
assert_match /Desc\d*/, sample_temperature.description
|
17
|
+
}
|
18
|
+
end
|
19
|
+
|
20
|
+
test "should return description as to_s" do
|
21
|
+
sample_temperature = create_sample_temperature
|
22
|
+
assert_equal sample_temperature.description, "#{sample_temperature}"
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
@@ -0,0 +1,363 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class Ccls::SampleTest < ActiveSupport::TestCase
|
4
|
+
|
5
|
+
assert_should_create_default_object
|
6
|
+
assert_should_have_one( :sample_kit )
|
7
|
+
assert_should_have_many( :aliquots )
|
8
|
+
assert_should_belong_to( :aliquot_sample_format, :unit,
|
9
|
+
:organization, :sample_temperature )
|
10
|
+
assert_should_initially_belong_to( :study_subject, :project, :sample_type )
|
11
|
+
|
12
|
+
assert_should_protect(:study_subject_id, :study_subject)
|
13
|
+
|
14
|
+
assert_should_not_require_attributes( :position,
|
15
|
+
:parent_sample_id,
|
16
|
+
:sample_collector_id,
|
17
|
+
:sample_temperature,
|
18
|
+
:sample_temperature_id,
|
19
|
+
:aliquot_sample_format,
|
20
|
+
:aliquot_sample_format_id,
|
21
|
+
:unit,
|
22
|
+
:unit_id,
|
23
|
+
:order_no,
|
24
|
+
:quantity_in_sample,
|
25
|
+
:aliquot_or_sample_on_receipt,
|
26
|
+
:sent_to_subject_on,
|
27
|
+
:collected_at,
|
28
|
+
:received_by_ccls_at,
|
29
|
+
:sent_to_lab_on,
|
30
|
+
:received_by_lab_on,
|
31
|
+
:aliquotted_on,
|
32
|
+
:external_id,
|
33
|
+
:external_id_source,
|
34
|
+
:receipt_confirmed_on,
|
35
|
+
:receipt_confirmed_by,
|
36
|
+
:location_id )
|
37
|
+
|
38
|
+
# TODO These seem to fail for DateTimes. Need to check it out.
|
39
|
+
assert_requires_complete_date( :sent_to_subject_on,
|
40
|
+
# :received_by_ccls_at,
|
41
|
+
:sent_to_lab_on,
|
42
|
+
:received_by_lab_on, :aliquotted_on,
|
43
|
+
# :collected_at,
|
44
|
+
:receipt_confirmed_on )
|
45
|
+
|
46
|
+
assert_requires_past_date( :sent_to_subject_on,
|
47
|
+
:received_by_ccls_at, :sent_to_lab_on,
|
48
|
+
:received_by_lab_on, :aliquotted_on,
|
49
|
+
:receipt_confirmed_on, :collected_at )
|
50
|
+
|
51
|
+
test "explicit Factory sample test" do
|
52
|
+
assert_difference('StudySubject.count',1) {
|
53
|
+
assert_difference('Enrollment.count',1) {
|
54
|
+
assert_difference('SampleType.count',2) { # creates sample_type and a parent sample_type
|
55
|
+
assert_difference('Sample.count',1) {
|
56
|
+
assert_difference('Project.count',1) {
|
57
|
+
sample = Factory(:sample)
|
58
|
+
assert_not_nil sample.sample_type
|
59
|
+
assert_not_nil sample.sample_type.parent
|
60
|
+
assert_not_nil sample.study_subject
|
61
|
+
assert_not_nil sample.project
|
62
|
+
} } } } }
|
63
|
+
end
|
64
|
+
|
65
|
+
test "should require sample_type" do
|
66
|
+
assert_difference( "Sample.count", 0 ) do
|
67
|
+
sample = create_sample( :sample_type => nil)
|
68
|
+
assert !sample.errors.on(:sample_type)
|
69
|
+
assert sample.errors.on_attr_and_type?(:sample_type_id,:blank)
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
test "should require valid sample_type" do
|
74
|
+
assert_difference( "Sample.count", 0 ) do
|
75
|
+
sample = create_sample( :sample_type_id => 0)
|
76
|
+
assert !sample.errors.on(:sample_type_id)
|
77
|
+
assert sample.errors.on_attr_and_type?(:sample_type,:blank)
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
test "should require study_subject" do
|
82
|
+
assert_difference( "Sample.count", 0 ) do
|
83
|
+
sample = create_sample( :study_subject => nil)
|
84
|
+
assert !sample.errors.on(:study_subject)
|
85
|
+
assert sample.errors.on_attr_and_type?(:study_subject_id,:blank)
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
test "should require valid study_subject" do
|
90
|
+
assert_difference( "Sample.count", 0 ) do
|
91
|
+
sample = create_sample( :study_subject_id => 0)
|
92
|
+
assert !sample.errors.on(:study_subject_id)
|
93
|
+
assert sample.errors.on_attr_and_type?(:study_subject,:blank)
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
test "should require project" do
|
98
|
+
assert_difference( "Sample.count", 0 ) do
|
99
|
+
sample = create_sample( :project => nil)
|
100
|
+
assert !sample.errors.on(:project)
|
101
|
+
assert sample.errors.on_attr_and_type?(:project_id,:blank)
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
test "should require valid project" do
|
106
|
+
assert_difference( "Sample.count", 0 ) do
|
107
|
+
sample = create_sample( :project_id => 0)
|
108
|
+
assert !sample.errors.on(:project_id)
|
109
|
+
assert sample.errors.on_attr_and_type?(:project,:blank)
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
test "should default order_no to 1" do
|
114
|
+
sample = create_sample
|
115
|
+
assert_equal 1, sample.order_no
|
116
|
+
end
|
117
|
+
|
118
|
+
test "should default aliquot_or_sample_on_receipt to 'Sample'" do
|
119
|
+
sample = create_sample
|
120
|
+
assert_equal 'Sample', sample.aliquot_or_sample_on_receipt
|
121
|
+
end
|
122
|
+
|
123
|
+
# somehow, through location_id I think
|
124
|
+
|
125
|
+
# TODO haven't really implemented organization samples yet
|
126
|
+
# test "should belong to organization" do
|
127
|
+
# sample = create_sample
|
128
|
+
# assert_nil sample.organization
|
129
|
+
# sample.organization = Factory(:organization)
|
130
|
+
# assert_not_nil sample.organization
|
131
|
+
# # this is not clear in my UML diagram
|
132
|
+
# pending
|
133
|
+
# end
|
134
|
+
|
135
|
+
|
136
|
+
# I get this in the functional tests, but I can't seem
|
137
|
+
# to reproduce it here.
|
138
|
+
# ArgumentError: comparison of Date with ActiveSupport::TimeWithZone failed
|
139
|
+
|
140
|
+
#ArgumentError (comparison of Date with ActiveSupport::TimeWithZone failed):
|
141
|
+
# /Library/Ruby/Gems/1.8/gems/ccls-ccls_engine-3.10.0/app/models/sample.rb:77:in `>'
|
142
|
+
# /Library/Ruby/Gems/1.8/gems/ccls-ccls_engine-3.10.0/app/models/sample.rb:77:in `collected_at_is_before_sent_to_subject_on?'
|
143
|
+
# /Library/Ruby/Gems/1.8/gems/ccls-ccls_engine-3.10.0/app/models/sample.rb:64:in `date_chronology'
|
144
|
+
|
145
|
+
# Even if the *_at field is given a Date value, it will be typecast to ActiveSupport::TimeWithZone so there is no terrible need to update all of the tests to send one.
|
146
|
+
|
147
|
+
|
148
|
+
test "should require sent_to_subject_on if collected_at" do
|
149
|
+
assert_difference( 'Sample.count', 0 ) do
|
150
|
+
sample = create_sample(
|
151
|
+
:sent_to_subject_on => nil,
|
152
|
+
:collected_at => Date.yesterday
|
153
|
+
)
|
154
|
+
assert sample.errors.on(:sent_to_subject_on)
|
155
|
+
assert_match(/be blank/,
|
156
|
+
sample.errors.on(:sent_to_subject_on) )
|
157
|
+
end
|
158
|
+
end
|
159
|
+
|
160
|
+
test "should require collected_at be after sent_to_subject_on" do
|
161
|
+
assert_difference( 'Sample.count', 0 ) do
|
162
|
+
sample = create_sample(
|
163
|
+
:sent_to_subject_on => Date.tomorrow,
|
164
|
+
:collected_at => Date.yesterday
|
165
|
+
)
|
166
|
+
assert sample.errors.on(:collected_at)
|
167
|
+
assert_match(/after sent_to_subject_on/,
|
168
|
+
sample.errors.on(:collected_at) )
|
169
|
+
end
|
170
|
+
end
|
171
|
+
|
172
|
+
test "should require collected_at if received_by_ccls_at" do
|
173
|
+
assert_difference( 'Sample.count', 0 ) do
|
174
|
+
sample = create_sample(
|
175
|
+
:collected_at => nil,
|
176
|
+
:received_by_ccls_at => Date.yesterday
|
177
|
+
)
|
178
|
+
assert sample.errors.on(:collected_at)
|
179
|
+
assert_match(/be blank/,
|
180
|
+
sample.errors.on(:collected_at) )
|
181
|
+
end
|
182
|
+
end
|
183
|
+
|
184
|
+
test "should require received_by_ccls_at be after collected_at" do
|
185
|
+
assert_difference( 'Sample.count', 0 ) do
|
186
|
+
sample = create_sample(
|
187
|
+
:collected_at => Date.tomorrow,
|
188
|
+
:received_by_ccls_at => Date.yesterday
|
189
|
+
)
|
190
|
+
assert sample.errors.on(:received_by_ccls_at)
|
191
|
+
assert_match(/after collected_at/,
|
192
|
+
sample.errors.on(:received_by_ccls_at) )
|
193
|
+
end
|
194
|
+
end
|
195
|
+
|
196
|
+
test "should require received_by_ccls_at if sent_to_lab_on" do
|
197
|
+
assert_difference( 'Sample.count', 0 ) do
|
198
|
+
sample = create_sample(
|
199
|
+
:received_by_ccls_at => nil,
|
200
|
+
:sent_to_lab_on => Date.yesterday
|
201
|
+
)
|
202
|
+
assert sample.errors.on(:received_by_ccls_at)
|
203
|
+
assert_match(/be blank/,
|
204
|
+
sample.errors.on(:received_by_ccls_at) )
|
205
|
+
end
|
206
|
+
end
|
207
|
+
|
208
|
+
test "should require sent_to_lab_on be after received_by_ccls_at" do
|
209
|
+
assert_difference( 'Sample.count', 0 ) do
|
210
|
+
sample = create_sample(
|
211
|
+
:received_by_ccls_at => Date.tomorrow,
|
212
|
+
:received_by_ccls_at => ( DateTime.now + 1.day ),
|
213
|
+
:sent_to_lab_on => Date.yesterday
|
214
|
+
)
|
215
|
+
assert sample.errors.on(:sent_to_lab_on)
|
216
|
+
assert_match(/after received_by_ccls_at/,
|
217
|
+
sample.errors.on(:sent_to_lab_on) )
|
218
|
+
end
|
219
|
+
end
|
220
|
+
|
221
|
+
test "should require sent_to_lab_on if received_by_lab_on" do
|
222
|
+
assert_difference( 'Sample.count', 0 ) do
|
223
|
+
sample = create_sample(
|
224
|
+
:sent_to_lab_on => nil,
|
225
|
+
:received_by_lab_on => Date.yesterday
|
226
|
+
)
|
227
|
+
assert sample.errors.on(:sent_to_lab_on)
|
228
|
+
assert_match(/be blank/,
|
229
|
+
sample.errors.on(:sent_to_lab_on) )
|
230
|
+
end
|
231
|
+
end
|
232
|
+
|
233
|
+
test "should require received_by_lab_on be after sent_to_lab_on" do
|
234
|
+
assert_difference( 'Sample.count', 0 ) do
|
235
|
+
sample = create_sample(
|
236
|
+
:sent_to_lab_on => Date.tomorrow,
|
237
|
+
:received_by_lab_on => Date.yesterday
|
238
|
+
)
|
239
|
+
assert sample.errors.on(:received_by_lab_on)
|
240
|
+
assert_match(/after sent_to_lab_on/,
|
241
|
+
sample.errors.on(:received_by_lab_on) )
|
242
|
+
end
|
243
|
+
end
|
244
|
+
|
245
|
+
test "should require location_id be after sent_to_lab_on" do
|
246
|
+
assert_difference( 'Sample.count', 0 ) do
|
247
|
+
sample = create_sample(
|
248
|
+
:sent_to_lab_on => Date.yesterday
|
249
|
+
)
|
250
|
+
assert sample.errors.on(:location_id)
|
251
|
+
assert_match(/blank/, sample.errors.on(:location_id) )
|
252
|
+
end
|
253
|
+
end
|
254
|
+
|
255
|
+
test "should require received_by_lab_on if aliquotted_on" do
|
256
|
+
assert_difference( 'Sample.count', 0 ) do
|
257
|
+
sample = create_sample(
|
258
|
+
:received_by_lab_on => nil,
|
259
|
+
:aliquotted_on => Date.yesterday
|
260
|
+
)
|
261
|
+
assert sample.errors.on(:received_by_lab_on)
|
262
|
+
assert_match(/be blank/,
|
263
|
+
sample.errors.on(:received_by_lab_on) )
|
264
|
+
end
|
265
|
+
end
|
266
|
+
|
267
|
+
test "should require aliquotted_on be after received_by_lab_on" do
|
268
|
+
assert_difference( 'Sample.count', 0 ) do
|
269
|
+
sample = create_sample(
|
270
|
+
:received_by_lab_on => Date.tomorrow,
|
271
|
+
:aliquotted_on => Date.yesterday
|
272
|
+
)
|
273
|
+
assert sample.errors.on(:aliquotted_on)
|
274
|
+
assert_match(/after received_by_lab_on/,
|
275
|
+
sample.errors.on(:aliquotted_on) )
|
276
|
+
end
|
277
|
+
end
|
278
|
+
|
279
|
+
test "should create homex outcome with sample" do
|
280
|
+
study_subject = create_hx_study_subject
|
281
|
+
assert_difference( 'Sample.count', 1 ) {
|
282
|
+
assert_difference( 'HomexOutcome.count', 1 ) {
|
283
|
+
sample = create_sample(
|
284
|
+
:study_subject => study_subject,
|
285
|
+
:project => Project['HomeExposures'] )
|
286
|
+
} }
|
287
|
+
end
|
288
|
+
|
289
|
+
test "should update homex outcome sample_outcome to sent" do
|
290
|
+
study_subject = create_hx_study_subject
|
291
|
+
assert_difference( 'OperationalEvent.count', 1 ) {
|
292
|
+
assert_difference( 'Sample.count', 1 ) {
|
293
|
+
assert_difference( 'HomexOutcome.count', 1 ) {
|
294
|
+
sample = create_sample(
|
295
|
+
:study_subject => study_subject,
|
296
|
+
:project => Project['HomeExposures'],
|
297
|
+
:sent_to_subject_on => Date.yesterday )
|
298
|
+
assert_equal SampleOutcome['sent'],
|
299
|
+
sample.study_subject.homex_outcome.sample_outcome
|
300
|
+
assert_equal sample.sent_to_subject_on,
|
301
|
+
sample.study_subject.homex_outcome.sample_outcome_on
|
302
|
+
} } }
|
303
|
+
end
|
304
|
+
|
305
|
+
test "should update homex outcome sample_outcome to received" do
|
306
|
+
study_subject = create_hx_study_subject
|
307
|
+
assert_difference( 'OperationalEvent.count', 1 ) {
|
308
|
+
assert_difference( 'Sample.count', 1 ) {
|
309
|
+
assert_difference( 'HomexOutcome.count', 1 ) {
|
310
|
+
today = Date.today
|
311
|
+
sample = create_sample(
|
312
|
+
:study_subject => study_subject,
|
313
|
+
:project => Project['HomeExposures'],
|
314
|
+
:sent_to_subject_on => ( today - 3.days ),
|
315
|
+
:collected_at => ( today - 2.days ),
|
316
|
+
:received_by_ccls_at => ( today - 1.day ) )
|
317
|
+
assert_equal SampleOutcome['received'],
|
318
|
+
sample.study_subject.homex_outcome.sample_outcome
|
319
|
+
assert_equal sample.received_by_ccls_at,
|
320
|
+
sample.study_subject.homex_outcome.sample_outcome_on
|
321
|
+
} } }
|
322
|
+
end
|
323
|
+
|
324
|
+
test "should update homex outcome sample_outcome to lab" do
|
325
|
+
study_subject = create_hx_study_subject
|
326
|
+
# This update does not create an operational event
|
327
|
+
# assert_difference( 'OperationalEvent.count', 1 ) {
|
328
|
+
assert_difference( 'Sample.count', 1 ) {
|
329
|
+
assert_difference( 'HomexOutcome.count', 1 ) {
|
330
|
+
today = Date.today
|
331
|
+
sample = create_sample(
|
332
|
+
:study_subject => study_subject,
|
333
|
+
:project => Project['HomeExposures'],
|
334
|
+
:organization => Factory(:organization),
|
335
|
+
:sent_to_subject_on => ( today - 4.days ),
|
336
|
+
:collected_at => ( today - 3.days ),
|
337
|
+
:received_by_ccls_at => ( today - 2.days ),
|
338
|
+
:sent_to_lab_on => ( today - 1.day ) )
|
339
|
+
assert !sample.new_record?, "Object was not created"
|
340
|
+
assert_equal SampleOutcome['lab'],
|
341
|
+
sample.study_subject.homex_outcome.sample_outcome
|
342
|
+
assert_equal sample.sent_to_lab_on,
|
343
|
+
sample.study_subject.homex_outcome.sample_outcome_on
|
344
|
+
} } #}
|
345
|
+
end
|
346
|
+
|
347
|
+
test "should respond to sample_type_parent" do
|
348
|
+
sample = create_sample
|
349
|
+
assert sample.respond_to? :sample_type_parent
|
350
|
+
sample_type_parent = sample.sample_type_parent
|
351
|
+
assert_not_nil sample_type_parent
|
352
|
+
assert sample_type_parent.is_a?(SampleType)
|
353
|
+
end
|
354
|
+
|
355
|
+
#protected
|
356
|
+
#
|
357
|
+
# def create_sample(options={})
|
358
|
+
# sample = Factory.build(:sample,options)
|
359
|
+
# sample.save
|
360
|
+
# sample
|
361
|
+
# end
|
362
|
+
|
363
|
+
end
|