ccls-ccls_engine 3.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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,47 @@
|
|
|
1
|
+
require 'test_helper'
|
|
2
|
+
|
|
3
|
+
class Ccls::LanguageTest < 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( :interviews, :instrument_versions )
|
|
10
|
+
assert_should_require_attributes( :code )
|
|
11
|
+
assert_should_require_unique_attributes( :code )
|
|
12
|
+
assert_should_not_require_attributes( :position )
|
|
13
|
+
|
|
14
|
+
test "explicit Factory language test" do
|
|
15
|
+
assert_difference('Language.count',1) {
|
|
16
|
+
language = Factory(:language)
|
|
17
|
+
assert_match /Key\d*/, language.key
|
|
18
|
+
assert_match /Code\d*/, language.code
|
|
19
|
+
assert_match /Desc\d*/, language.description
|
|
20
|
+
}
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
test "should return description as to_s" do
|
|
24
|
+
language = create_language
|
|
25
|
+
assert_equal language.description, "#{language}"
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
test "should find random" do
|
|
29
|
+
language = Language.random()
|
|
30
|
+
assert language.is_a?(Language)
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
test "should return nil on random when no records" do
|
|
34
|
+
Language.stubs(:count).returns(0)
|
|
35
|
+
language = Language.random()
|
|
36
|
+
assert_nil language
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
#protected
|
|
40
|
+
#
|
|
41
|
+
# def create_language(options={})
|
|
42
|
+
# language = Factory.build(:language,options)
|
|
43
|
+
# language.save
|
|
44
|
+
# language
|
|
45
|
+
# end
|
|
46
|
+
|
|
47
|
+
end
|
|
@@ -0,0 +1,358 @@
|
|
|
1
|
+
require 'test_helper'
|
|
2
|
+
|
|
3
|
+
class Ccls::LiveBirthDataUpdateTest < ActiveSupport::TestCase
|
|
4
|
+
include Ccls::LiveBirthDataUpdateTestHelper
|
|
5
|
+
|
|
6
|
+
setup :turn_off_paperclip_logging
|
|
7
|
+
|
|
8
|
+
assert_should_create_default_object
|
|
9
|
+
|
|
10
|
+
# These are String tests and these tests and this method should
|
|
11
|
+
# be moved into StringExtension
|
|
12
|
+
|
|
13
|
+
test "should split persons name into 3 names without middle name" do
|
|
14
|
+
names = "John Smith".split_name
|
|
15
|
+
assert_equal 3, names.length
|
|
16
|
+
assert_equal ['John','','Smith'], names
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
test "should split persons name into 3 names with middle name" do
|
|
20
|
+
names = "John Herbert Smith".split_name
|
|
21
|
+
assert_equal 3, names.length
|
|
22
|
+
assert_equal ['John','Herbert','Smith'], names
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
test "should split persons name into 3 names with 2 middle names" do
|
|
26
|
+
names = "John Herbert Walker Smith".split_name
|
|
27
|
+
assert_equal 3, names.length
|
|
28
|
+
assert_equal ['John','Herbert Walker','Smith'], names
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
test "should split persons name into 3 names with middle initial" do
|
|
32
|
+
names = "John H. Smith".split_name
|
|
33
|
+
assert_equal 3, names.length
|
|
34
|
+
assert_equal ['John','H.','Smith'], names
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
test "should split persons name into 3 names even with \\240 codes" do
|
|
38
|
+
names = "John\240Herbert\240Smith".split_name
|
|
39
|
+
assert_equal 3, names.length
|
|
40
|
+
assert_equal ["John","Herbert","Smith"], names
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
test "should split persons name into 3 names even with apostrophe" do
|
|
44
|
+
names = "John Herbert O'Grady".split_name
|
|
45
|
+
assert_equal 3, names.length
|
|
46
|
+
assert_equal ["John","Herbert","O'Grady"], names
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
# TODO test for name with period like Mary Elizabeth St. James
|
|
50
|
+
# TODO test for name with 2 last names
|
|
51
|
+
# TODO test for name with 2 first names
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
test "should create without attached csv_file" do
|
|
57
|
+
assert_difference('LiveBirthDataUpdate.count',1) {
|
|
58
|
+
@object = Factory(:live_birth_data_update)
|
|
59
|
+
}
|
|
60
|
+
assert_nil @object.csv_file_file_name
|
|
61
|
+
assert_nil @object.csv_file_content_type
|
|
62
|
+
assert_nil @object.csv_file_file_size
|
|
63
|
+
assert_nil @object.csv_file_updated_at
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
test "should create with attached csv_file" do
|
|
67
|
+
assert_difference('LiveBirthDataUpdate.count',1) {
|
|
68
|
+
@object = create_test_file_and_live_birth_data_update
|
|
69
|
+
}
|
|
70
|
+
assert_not_nil @object.csv_file_file_name
|
|
71
|
+
assert_equal @object.csv_file_file_name, csv_test_file_name
|
|
72
|
+
assert_not_nil @object.csv_file_content_type
|
|
73
|
+
assert_not_nil @object.csv_file_file_size
|
|
74
|
+
assert_not_nil @object.csv_file_updated_at
|
|
75
|
+
cleanup_live_birth_data_update_and_test_file(@object)
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
test "should convert nil attached csv_file to candidate controls" do
|
|
79
|
+
live_birth_data_update = Factory(:live_birth_data_update)
|
|
80
|
+
assert_nil live_birth_data_update.csv_file_file_name
|
|
81
|
+
assert_difference('CandidateControl.count',0) {
|
|
82
|
+
results = live_birth_data_update.to_candidate_controls
|
|
83
|
+
assert_equal [], results
|
|
84
|
+
}
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
test "should convert non-existant attached csv_file to candidate controls" do
|
|
88
|
+
live_birth_data_update = create_test_file_and_live_birth_data_update
|
|
89
|
+
assert File.exists?(live_birth_data_update.csv_file.path)
|
|
90
|
+
File.delete(live_birth_data_update.csv_file.path)
|
|
91
|
+
assert !File.exists?(live_birth_data_update.csv_file.path)
|
|
92
|
+
assert_difference('CandidateControl.count',0) {
|
|
93
|
+
results = live_birth_data_update.to_candidate_controls
|
|
94
|
+
assert_equal [], results
|
|
95
|
+
}
|
|
96
|
+
cleanup_live_birth_data_update_and_test_file(live_birth_data_update)
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
test "should convert attached csv_file to candidate controls with matching case" do
|
|
100
|
+
create_case_for_live_birth_data_update
|
|
101
|
+
live_birth_data_update = create_test_file_and_live_birth_data_update
|
|
102
|
+
assert_difference('CandidateControl.count',1) {
|
|
103
|
+
results = live_birth_data_update.to_candidate_controls
|
|
104
|
+
assert_equal 2, results.length
|
|
105
|
+
assert results[0].is_a?(StudySubject)
|
|
106
|
+
assert results[0].is_case?
|
|
107
|
+
assert results[1].is_a?(CandidateControl)
|
|
108
|
+
}
|
|
109
|
+
cleanup_live_birth_data_update_and_test_file(live_birth_data_update)
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
test "should convert attached csv_file to candidate controls with missing case" do
|
|
113
|
+
live_birth_data_update = create_test_file_and_live_birth_data_update
|
|
114
|
+
assert_difference('CandidateControl.count',0) {
|
|
115
|
+
results = live_birth_data_update.to_candidate_controls
|
|
116
|
+
assert_equal results,
|
|
117
|
+
["Could not find study_subject with masterid 1234FAKE",
|
|
118
|
+
"Could not find study_subject with masterid 1234FAKE"]
|
|
119
|
+
}
|
|
120
|
+
cleanup_live_birth_data_update_and_test_file(live_birth_data_update)
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
test "should convert attached csv_file to candidate controls with existing candidate control" do
|
|
124
|
+
create_case_for_live_birth_data_update
|
|
125
|
+
live_birth_data_update = create_test_file_and_live_birth_data_update
|
|
126
|
+
results = nil
|
|
127
|
+
assert_difference('CandidateControl.count',1) {
|
|
128
|
+
results = live_birth_data_update.to_candidate_controls
|
|
129
|
+
assert_equal 2, results.length
|
|
130
|
+
assert results[0].is_a?(StudySubject)
|
|
131
|
+
assert results[0].is_case?
|
|
132
|
+
assert results[1].is_a?(CandidateControl)
|
|
133
|
+
}
|
|
134
|
+
assert_difference('CandidateControl.count',0) {
|
|
135
|
+
new_results = live_birth_data_update.to_candidate_controls
|
|
136
|
+
assert_equal 2, new_results.length
|
|
137
|
+
assert new_results[0].is_a?(StudySubject)
|
|
138
|
+
assert new_results[0].is_case?
|
|
139
|
+
assert new_results[1].is_a?(CandidateControl)
|
|
140
|
+
assert_equal results, new_results
|
|
141
|
+
}
|
|
142
|
+
cleanup_live_birth_data_update_and_test_file(live_birth_data_update)
|
|
143
|
+
end
|
|
144
|
+
|
|
145
|
+
test "should convert attached csv_file to candidate controls with blank child_full_name" do
|
|
146
|
+
create_case_for_live_birth_data_update
|
|
147
|
+
live_birth_data_update = create_test_file_and_live_birth_data_update(:child_full_name => '')
|
|
148
|
+
results = nil
|
|
149
|
+
assert_difference('CandidateControl.count',0) {
|
|
150
|
+
results = live_birth_data_update.to_candidate_controls
|
|
151
|
+
assert_equal 2, results.length
|
|
152
|
+
assert results[0].is_a?(StudySubject)
|
|
153
|
+
assert results[0].is_case?
|
|
154
|
+
assert results[1].is_a?(CandidateControl)
|
|
155
|
+
assert results[1].errors.on_attr_and_type?(:first_name, :blank)
|
|
156
|
+
assert results[1].errors.on_attr_and_type?(:last_name, :blank)
|
|
157
|
+
}
|
|
158
|
+
cleanup_live_birth_data_update_and_test_file(live_birth_data_update)
|
|
159
|
+
end
|
|
160
|
+
|
|
161
|
+
test "should convert attached csv_file to candidate controls with blank child_dobm" do
|
|
162
|
+
create_case_for_live_birth_data_update
|
|
163
|
+
live_birth_data_update = create_test_file_and_live_birth_data_update(:child_dobm => '')
|
|
164
|
+
results = nil
|
|
165
|
+
assert_difference('CandidateControl.count',0) {
|
|
166
|
+
results = live_birth_data_update.to_candidate_controls
|
|
167
|
+
assert_equal 2, results.length
|
|
168
|
+
assert results[0].is_a?(StudySubject)
|
|
169
|
+
assert results[0].is_case?
|
|
170
|
+
assert results[1].is_a?(CandidateControl)
|
|
171
|
+
assert results[1].errors.on_attr_and_type?(:dob, :blank)
|
|
172
|
+
}
|
|
173
|
+
cleanup_live_birth_data_update_and_test_file(live_birth_data_update)
|
|
174
|
+
end
|
|
175
|
+
|
|
176
|
+
test "should convert attached csv_file to candidate controls with blank child_dobd" do
|
|
177
|
+
create_case_for_live_birth_data_update
|
|
178
|
+
live_birth_data_update = create_test_file_and_live_birth_data_update(:child_dobd => '')
|
|
179
|
+
results = nil
|
|
180
|
+
assert_difference('CandidateControl.count',0) {
|
|
181
|
+
results = live_birth_data_update.to_candidate_controls
|
|
182
|
+
assert_equal 2, results.length
|
|
183
|
+
assert results[0].is_a?(StudySubject)
|
|
184
|
+
assert results[0].is_case?
|
|
185
|
+
assert results[1].is_a?(CandidateControl)
|
|
186
|
+
assert results[1].errors.on_attr_and_type?(:dob, :blank)
|
|
187
|
+
}
|
|
188
|
+
cleanup_live_birth_data_update_and_test_file(live_birth_data_update)
|
|
189
|
+
end
|
|
190
|
+
|
|
191
|
+
test "should convert attached csv_file to candidate controls with blank child_doby" do
|
|
192
|
+
create_case_for_live_birth_data_update
|
|
193
|
+
live_birth_data_update = create_test_file_and_live_birth_data_update(:child_doby => '')
|
|
194
|
+
results = nil
|
|
195
|
+
assert_difference('CandidateControl.count',0) {
|
|
196
|
+
results = live_birth_data_update.to_candidate_controls
|
|
197
|
+
assert_equal 2, results.length
|
|
198
|
+
assert results[0].is_a?(StudySubject)
|
|
199
|
+
assert results[0].is_case?
|
|
200
|
+
assert results[1].is_a?(CandidateControl)
|
|
201
|
+
assert results[1].errors.on_attr_and_type?(:dob, :blank)
|
|
202
|
+
}
|
|
203
|
+
cleanup_live_birth_data_update_and_test_file(live_birth_data_update)
|
|
204
|
+
end
|
|
205
|
+
|
|
206
|
+
test "should convert attached csv_file to candidate controls with blank child_gender" do
|
|
207
|
+
create_case_for_live_birth_data_update
|
|
208
|
+
live_birth_data_update = create_test_file_and_live_birth_data_update(:child_gender => '')
|
|
209
|
+
results = nil
|
|
210
|
+
assert_difference('CandidateControl.count',0) {
|
|
211
|
+
results = live_birth_data_update.to_candidate_controls
|
|
212
|
+
assert_equal 2, results.length
|
|
213
|
+
assert results[0].is_a?(StudySubject)
|
|
214
|
+
assert results[0].is_case?
|
|
215
|
+
assert results[1].is_a?(CandidateControl)
|
|
216
|
+
assert results[1].errors.on_attr_and_type?(:sex, :inclusion)
|
|
217
|
+
}
|
|
218
|
+
cleanup_live_birth_data_update_and_test_file(live_birth_data_update)
|
|
219
|
+
end
|
|
220
|
+
|
|
221
|
+
# TODO CandidateControl has the following potential validation failures.
|
|
222
|
+
# What to do for these?
|
|
223
|
+
# Force them with default values?
|
|
224
|
+
#
|
|
225
|
+
# validates_presence_of :first_name
|
|
226
|
+
# validates_presence_of :last_name
|
|
227
|
+
# validates_presence_of :dob
|
|
228
|
+
# validates_length_of :related_patid, :is => 4, :allow_blank => true
|
|
229
|
+
# validates_inclusion_of :sex, :in => %w( M F DK )
|
|
230
|
+
|
|
231
|
+
|
|
232
|
+
test "should copy attributes when csv_file converted to candidate control" do
|
|
233
|
+
study_subject = create_case_for_live_birth_data_update
|
|
234
|
+
live_birth_data_update = create_test_file_and_live_birth_data_update
|
|
235
|
+
assert_difference('CandidateControl.count',1) {
|
|
236
|
+
results = live_birth_data_update.to_candidate_controls
|
|
237
|
+
assert_equal 2, results.length
|
|
238
|
+
candidate_control = results.last
|
|
239
|
+
assert_equal candidate_control.related_patid, study_subject.patid
|
|
240
|
+
assert_equal candidate_control.mom_is_biomom, control[:biomom]
|
|
241
|
+
assert_equal candidate_control.dad_is_biodad, control[:biodad]
|
|
242
|
+
#control[:date]},#{
|
|
243
|
+
assert_equal candidate_control.mother_full_name, control[:mother_full_name]
|
|
244
|
+
assert_equal candidate_control.mother_maiden_name, control[:mother_maiden_name]
|
|
245
|
+
#control[:father_full_name]},#{
|
|
246
|
+
assert_equal candidate_control.full_name, control[:child_full_name]
|
|
247
|
+
assert_equal candidate_control.dob,
|
|
248
|
+
Date.new(control[:child_doby], control[:child_dobm], control[:child_dobd])
|
|
249
|
+
# Date.new(control[:child_doby].to_i, control[:child_dobm].to_i, control[:child_dobd].to_i)
|
|
250
|
+
assert_equal candidate_control.sex, control[:child_gender]
|
|
251
|
+
#control[:birthplace_country]},#{
|
|
252
|
+
#control[:birthplace_state]},#{
|
|
253
|
+
#control[:birthplace_city]},#{
|
|
254
|
+
assert_equal candidate_control.mother_hispanicity_id, control[:mother_hispanicity]
|
|
255
|
+
#control[:mother_hispanicity_mex]},#{
|
|
256
|
+
assert_equal candidate_control.mother_race_id, control[:mother_race]
|
|
257
|
+
#control[:mother_race_other]},#{
|
|
258
|
+
assert_equal candidate_control.father_hispanicity_id, control[:father_hispanicity]
|
|
259
|
+
#control[:father_hispanicity_mex]},#{
|
|
260
|
+
assert_equal candidate_control.father_race_id, control[:father_race]
|
|
261
|
+
#control[:father_race_other]}} }
|
|
262
|
+
}
|
|
263
|
+
cleanup_live_birth_data_update_and_test_file(live_birth_data_update)
|
|
264
|
+
end
|
|
265
|
+
|
|
266
|
+
test "should test with real data file" do
|
|
267
|
+
# real data and won't be in repository
|
|
268
|
+
unless File.exists?('test-livebirthdata_011912.csv')
|
|
269
|
+
puts
|
|
270
|
+
puts "-- Real data test file does not exist. Skipping."
|
|
271
|
+
return
|
|
272
|
+
end
|
|
273
|
+
|
|
274
|
+
# minimal semi-real case creation
|
|
275
|
+
s0 = Factory(:case_study_subject,:sex => 'F',
|
|
276
|
+
:first_name => 'FakeFirst1',:last_name => 'FakeLast1',
|
|
277
|
+
:dob => Date.parse('10/16/1977'))
|
|
278
|
+
# s0 has no icf_master_id, so should be ignored
|
|
279
|
+
|
|
280
|
+
s1 = Factory(:case_study_subject,:sex => 'F',
|
|
281
|
+
:first_name => 'FakeFirst2',:last_name => 'FakeLast2',
|
|
282
|
+
:dob => Date.parse('9/21/1988'))
|
|
283
|
+
Factory(:icf_master_id,:icf_master_id => '48882638A')
|
|
284
|
+
s1.assign_icf_master_id
|
|
285
|
+
|
|
286
|
+
s2 = Factory(:case_study_subject,:sex => 'M',
|
|
287
|
+
:first_name => 'FakeFirst3',:last_name => 'FakeLast3',
|
|
288
|
+
:dob => Date.parse('6/1/2009'))
|
|
289
|
+
Factory(:icf_master_id,:icf_master_id => '16655682G')
|
|
290
|
+
s2.assign_icf_master_id
|
|
291
|
+
|
|
292
|
+
live_birth_data_update = Factory(:live_birth_data_update,
|
|
293
|
+
:csv_file => File.open('test-livebirthdata_011912.csv') )
|
|
294
|
+
assert_not_nil live_birth_data_update.csv_file_file_name
|
|
295
|
+
|
|
296
|
+
# 35 lines - 1 header - 3 cases = 31
|
|
297
|
+
assert_difference('CandidateControl.count',31){
|
|
298
|
+
results = live_birth_data_update.to_candidate_controls
|
|
299
|
+
assert results[0].is_a?(String)
|
|
300
|
+
assert_equal results[0],
|
|
301
|
+
"Could not find study_subject with masterid [no ID assigned]"
|
|
302
|
+
assert results[1].is_a?(StudySubject)
|
|
303
|
+
assert results[2].is_a?(StudySubject)
|
|
304
|
+
assert_equal results[1], s1
|
|
305
|
+
assert_equal results[2], s2
|
|
306
|
+
results.each { |r|
|
|
307
|
+
if r.is_a?(CandidateControl) and r.new_record?
|
|
308
|
+
puts r.inspect
|
|
309
|
+
puts r.errors.full_messages.to_sentence
|
|
310
|
+
end
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
live_birth_data_update.destroy
|
|
314
|
+
# cleanup_live_birth_data_update_and_test_file(live_birth_data_update)
|
|
315
|
+
end
|
|
316
|
+
|
|
317
|
+
test "should return a StudySubject in results for case" do
|
|
318
|
+
study_subject = create_case_for_live_birth_data_update
|
|
319
|
+
File.open(csv_test_file_name,'w'){|f|
|
|
320
|
+
f.puts csv_file_header
|
|
321
|
+
f.puts csv_file_case_study_subject }
|
|
322
|
+
live_birth_data_update = create_live_birth_data_update_with_file
|
|
323
|
+
assert_difference('CandidateControl.count',0){
|
|
324
|
+
results = live_birth_data_update.to_candidate_controls
|
|
325
|
+
assert results[0].is_a?(StudySubject)
|
|
326
|
+
assert_equal results[0], study_subject
|
|
327
|
+
}
|
|
328
|
+
cleanup_live_birth_data_update_and_test_file(live_birth_data_update)
|
|
329
|
+
end
|
|
330
|
+
|
|
331
|
+
test "should return a CandidateControl in results for control" do
|
|
332
|
+
study_subject = create_case_for_live_birth_data_update
|
|
333
|
+
File.open(csv_test_file_name,'w'){|f|
|
|
334
|
+
f.puts csv_file_header
|
|
335
|
+
f.puts csv_file_control }
|
|
336
|
+
live_birth_data_update = create_live_birth_data_update_with_file
|
|
337
|
+
assert_difference('CandidateControl.count',1){
|
|
338
|
+
results = live_birth_data_update.to_candidate_controls
|
|
339
|
+
assert results[0].is_a?(CandidateControl)
|
|
340
|
+
}
|
|
341
|
+
cleanup_live_birth_data_update_and_test_file(live_birth_data_update)
|
|
342
|
+
end
|
|
343
|
+
|
|
344
|
+
test "should return a String in results for unknown ca_co_status" do
|
|
345
|
+
study_subject = create_case_for_live_birth_data_update
|
|
346
|
+
File.open(csv_test_file_name,'w'){|f|
|
|
347
|
+
f.puts csv_file_header
|
|
348
|
+
f.puts csv_file_unknown }
|
|
349
|
+
live_birth_data_update = create_live_birth_data_update_with_file
|
|
350
|
+
assert_difference('CandidateControl.count',0){
|
|
351
|
+
results = live_birth_data_update.to_candidate_controls
|
|
352
|
+
assert results[0].is_a?(String)
|
|
353
|
+
assert_equal results[0], "Unexpected ca_co_status :unknown:"
|
|
354
|
+
}
|
|
355
|
+
cleanup_live_birth_data_update_and_test_file(live_birth_data_update)
|
|
356
|
+
end
|
|
357
|
+
|
|
358
|
+
end
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
require 'test_helper'
|
|
2
|
+
|
|
3
|
+
class Ccls::OperationalEventTest < ActiveSupport::TestCase
|
|
4
|
+
|
|
5
|
+
assert_should_create_default_object
|
|
6
|
+
assert_should_initially_belong_to(:enrollment)
|
|
7
|
+
assert_should_initially_belong_to(:operational_event_type)
|
|
8
|
+
|
|
9
|
+
assert_should_require_attributes( :enrollment_id )
|
|
10
|
+
assert_should_not_require_attributes( :occurred_on, :description, :event_notes )
|
|
11
|
+
|
|
12
|
+
assert_requires_complete_date(:occurred_on)
|
|
13
|
+
assert_should_require_attribute_length( :description, :maximum => 250 )
|
|
14
|
+
assert_should_require_attribute_length( :event_notes, :maximum => 65000 )
|
|
15
|
+
|
|
16
|
+
test "explicit Factory operational_event test" do
|
|
17
|
+
assert_difference('OperationalEventType.count',1) {
|
|
18
|
+
assert_difference('OperationalEvent.count',1) {
|
|
19
|
+
operational_event = Factory(:operational_event)
|
|
20
|
+
assert_not_nil operational_event.operational_event_type
|
|
21
|
+
} }
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
test "should require operational_event_type" do
|
|
25
|
+
assert_difference( "OperationalEvent.count", 0 ) do
|
|
26
|
+
operational_event = create_operational_event( :operational_event_type => nil)
|
|
27
|
+
assert !operational_event.errors.on(:operational_event_type)
|
|
28
|
+
assert operational_event.errors.on_attr_and_type?(:operational_event_type_id,:blank)
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
test "should require valid operational_event_type" do
|
|
33
|
+
assert_difference( "OperationalEvent.count", 0 ) do
|
|
34
|
+
operational_event = create_operational_event( :operational_event_type_id => 0)
|
|
35
|
+
assert !operational_event.errors.on(:operational_event_type_id)
|
|
36
|
+
assert operational_event.errors.on_attr_and_type?(:operational_event_type,:blank)
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
# description is not required so ...
|
|
41
|
+
test "should return description as to_s if not nil" do
|
|
42
|
+
operational_event = create_operational_event(:description => 'testing')
|
|
43
|
+
assert_equal operational_event.description, "#{operational_event}"
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
# test "should return NOT description as to_s if nil" do
|
|
47
|
+
# operational_event = create_operational_event
|
|
48
|
+
# assert_not_equal operational_event.description, "#{operational_event}"
|
|
49
|
+
# end
|
|
50
|
+
|
|
51
|
+
test "should order by type ASC" do
|
|
52
|
+
oes = create_oet_operational_events
|
|
53
|
+
events = OperationalEvent.search(:order => 'type',:dir => 'asc')
|
|
54
|
+
assert_equal events, [oes[1],oes[0],oes[2]]
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
test "should order by type DESC" do
|
|
58
|
+
oes = create_oet_operational_events
|
|
59
|
+
events = OperationalEvent.search(:order => 'type',:dir => 'desc')
|
|
60
|
+
assert_equal events, [oes[2],oes[0],oes[1]]
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
test "should order by type and DESC as default dir" do
|
|
64
|
+
oes = create_oet_operational_events
|
|
65
|
+
events = OperationalEvent.search(:order => 'type')
|
|
66
|
+
assert_equal events, [oes[2],oes[0],oes[1]]
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
test "should order by description ASC" do
|
|
70
|
+
oes = create_description_operational_events
|
|
71
|
+
events = OperationalEvent.search(:order => 'description',:dir => 'asc')
|
|
72
|
+
assert_equal events, [oes[1],oes[0],oes[2]]
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
test "should order by description DESC" do
|
|
76
|
+
oes = create_description_operational_events
|
|
77
|
+
events = OperationalEvent.search(:order => 'description',:dir => 'desc')
|
|
78
|
+
assert_equal events, [oes[2],oes[0],oes[1]]
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
test "should order by description and DESC as default dir" do
|
|
82
|
+
oes = create_description_operational_events
|
|
83
|
+
events = OperationalEvent.search(:order => 'description')
|
|
84
|
+
assert_equal events, [oes[2],oes[0],oes[1]]
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
test "should order by occurred_on ASC" do
|
|
88
|
+
oes = create_occurred_on_operational_events
|
|
89
|
+
events = OperationalEvent.search(:order => 'occurred_on',:dir => 'asc')
|
|
90
|
+
assert_equal events, [oes[1],oes[0],oes[2]]
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
test "should order by occurred_on DESC" do
|
|
94
|
+
oes = create_occurred_on_operational_events
|
|
95
|
+
events = OperationalEvent.search(:order => 'occurred_on',:dir => 'desc')
|
|
96
|
+
assert_equal events, [oes[2],oes[0],oes[1]]
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
test "should order by occurred_on and DESC as default dir" do
|
|
100
|
+
oes = create_occurred_on_operational_events
|
|
101
|
+
events = OperationalEvent.search(:order => 'occurred_on')
|
|
102
|
+
assert_equal events, [oes[2],oes[0],oes[1]]
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
test "should order by occurred_on DESC as defaults" do
|
|
106
|
+
oes = create_occurred_on_operational_events
|
|
107
|
+
events = OperationalEvent.search()
|
|
108
|
+
assert_equal events, [oes[2],oes[0],oes[1]]
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
test "should ignore invalid order" do
|
|
112
|
+
oes = create_occurred_on_operational_events
|
|
113
|
+
events = OperationalEvent.search(:order => 'iambogus')
|
|
114
|
+
assert_equal events, [oes[2],oes[0],oes[1]]
|
|
115
|
+
end
|
|
116
|
+
|
|
117
|
+
test "should ignore invalid dir" do
|
|
118
|
+
oes = create_occurred_on_operational_events
|
|
119
|
+
events = OperationalEvent.search(:order => 'occurred_on',
|
|
120
|
+
:dir => 'iambogus')
|
|
121
|
+
assert_equal events, [oes[2],oes[0],oes[1]]
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
test "should ignore valid dir without order" do
|
|
125
|
+
oes = create_occurred_on_operational_events
|
|
126
|
+
events = OperationalEvent.search(:dir => 'ASC')
|
|
127
|
+
assert_equal events, [oes[2],oes[0],oes[1]]
|
|
128
|
+
end
|
|
129
|
+
|
|
130
|
+
test "should copy operational event type description on create" do
|
|
131
|
+
operational_event = create_operational_event
|
|
132
|
+
assert_equal operational_event.reload.description,
|
|
133
|
+
operational_event.operational_event_type.description
|
|
134
|
+
end
|
|
135
|
+
|
|
136
|
+
test "should only include operational events for study_subject" do
|
|
137
|
+
enrollment = Factory(:enrollment)
|
|
138
|
+
operational_event_1 = create_operational_event
|
|
139
|
+
operational_event_2 = create_operational_event(
|
|
140
|
+
:enrollment => enrollment )
|
|
141
|
+
events = OperationalEvent.search(:study_subject_id => enrollment.study_subject.id)
|
|
142
|
+
# enrollment creates subject with auto-created ccls enrollment
|
|
143
|
+
assert_equal 2, events.length
|
|
144
|
+
assert events.include? operational_event_2
|
|
145
|
+
end
|
|
146
|
+
|
|
147
|
+
protected
|
|
148
|
+
|
|
149
|
+
# def create_operational_event(options={})
|
|
150
|
+
# operational_event = Factory.build(:operational_event,options)
|
|
151
|
+
# operational_event.save
|
|
152
|
+
# operational_event
|
|
153
|
+
# end
|
|
154
|
+
|
|
155
|
+
def create_operational_events(*args)
|
|
156
|
+
args.collect{|options| create_operational_event(options) }
|
|
157
|
+
end
|
|
158
|
+
|
|
159
|
+
def create_occurred_on_operational_events
|
|
160
|
+
today = Date.today
|
|
161
|
+
create_operational_events(
|
|
162
|
+
{ :occurred_on => ( today - 1.month ) },
|
|
163
|
+
{ :occurred_on => ( today - 1.year ) },
|
|
164
|
+
{ :occurred_on => ( today - 1.week ) }
|
|
165
|
+
)
|
|
166
|
+
end
|
|
167
|
+
|
|
168
|
+
def create_description_operational_events
|
|
169
|
+
create_operational_events(
|
|
170
|
+
{ :description => 'M' },
|
|
171
|
+
{ :description => 'A' },
|
|
172
|
+
{ :description => 'Z' }
|
|
173
|
+
)
|
|
174
|
+
end
|
|
175
|
+
|
|
176
|
+
def create_oet_operational_events
|
|
177
|
+
create_operational_events(
|
|
178
|
+
{ :operational_event_type => Factory(
|
|
179
|
+
:operational_event_type,:description => 'MMMM') },
|
|
180
|
+
{ :operational_event_type => Factory(
|
|
181
|
+
:operational_event_type,:description => 'AAAA') },
|
|
182
|
+
{ :operational_event_type => Factory(
|
|
183
|
+
:operational_event_type,:description => 'ZZZZ') }
|
|
184
|
+
)
|
|
185
|
+
end
|
|
186
|
+
|
|
187
|
+
end
|