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,53 @@
|
|
1
|
+
module Ccls::ActionViewExtension::Base
|
2
|
+
|
3
|
+
def self.included(base)
|
4
|
+
base.send(:include, InstanceMethods)
|
5
|
+
end
|
6
|
+
|
7
|
+
module InstanceMethods
|
8
|
+
|
9
|
+
def yndk(value=nil)
|
10
|
+
YNDK[value]||' '
|
11
|
+
end
|
12
|
+
|
13
|
+
def ynodk(value=nil)
|
14
|
+
YNODK[value]||' '
|
15
|
+
end
|
16
|
+
|
17
|
+
def ynrdk(value=nil)
|
18
|
+
YNRDK[value]||' '
|
19
|
+
end
|
20
|
+
|
21
|
+
def adna(value=nil)
|
22
|
+
ADNA[value]||' '
|
23
|
+
end
|
24
|
+
|
25
|
+
def _wrapped_yndk_spans(object_name,method,options={})
|
26
|
+
object = instance_variable_get("@#{object_name}")
|
27
|
+
_wrapped_spans(object_name,method,options.update(
|
28
|
+
:value => (YNDK[object.send(method)]||' ') ) )
|
29
|
+
end
|
30
|
+
|
31
|
+
def _wrapped_ynodk_spans(object_name,method,options={})
|
32
|
+
object = instance_variable_get("@#{object_name}")
|
33
|
+
_wrapped_spans(object_name,method,options.update(
|
34
|
+
:value => (YNODK[object.send(method)]||' ') ) )
|
35
|
+
end
|
36
|
+
|
37
|
+
def _wrapped_ynrdk_spans(object_name,method,options={})
|
38
|
+
object = instance_variable_get("@#{object_name}")
|
39
|
+
_wrapped_spans(object_name,method,options.update(
|
40
|
+
:value => (YNRDK[object.send(method)]||' ') ) )
|
41
|
+
end
|
42
|
+
|
43
|
+
def _wrapped_adna_spans(object_name,method,options={})
|
44
|
+
object = instance_variable_get("@#{object_name}")
|
45
|
+
_wrapped_spans(object_name,method,options.update(
|
46
|
+
:value => (ADNA[object.send(method)]||' ') ) )
|
47
|
+
end
|
48
|
+
|
49
|
+
end # module InstanceMethods
|
50
|
+
|
51
|
+
end # module Ccls::ActionViewExtension::Base
|
52
|
+
ActionView::Base.send(:include,
|
53
|
+
Ccls::ActionViewExtension::Base )
|
@@ -0,0 +1,39 @@
|
|
1
|
+
module Ccls::ActionViewExtension::FormBuilder
|
2
|
+
|
3
|
+
def self.included(base)
|
4
|
+
base.send(:include,InstanceMethods)
|
5
|
+
end
|
6
|
+
|
7
|
+
module InstanceMethods
|
8
|
+
|
9
|
+
# NOTE
|
10
|
+
# calling <%= f.wrapped_yndk_select :code %> will NOT call these methods.
|
11
|
+
# It will call the method missing and then the @template.method
|
12
|
+
# Actually, now I believe that it will.
|
13
|
+
#
|
14
|
+
|
15
|
+
def yndk_select(method,options={},html_options={})
|
16
|
+
@template.select(object_name, method, YNDK.selector_options,
|
17
|
+
{:include_blank => true}.merge(objectify_options(options)), html_options)
|
18
|
+
end
|
19
|
+
|
20
|
+
def ynrdk_select(method,options={},html_options={})
|
21
|
+
@template.select(object_name, method, YNRDK.selector_options,
|
22
|
+
{:include_blank => true}.merge(objectify_options(options)), html_options)
|
23
|
+
end
|
24
|
+
|
25
|
+
def ynodk_select(method,options={},html_options={})
|
26
|
+
@template.select(object_name, method, YNODK.selector_options,
|
27
|
+
{:include_blank => true}.merge(objectify_options(options)), html_options)
|
28
|
+
end
|
29
|
+
|
30
|
+
def adna_select(method,options={},html_options={})
|
31
|
+
@template.select(object_name, method, ADNA.selector_options,
|
32
|
+
{:include_blank => true}.merge(objectify_options(options)), html_options)
|
33
|
+
end
|
34
|
+
|
35
|
+
end # module InstanceMethods
|
36
|
+
|
37
|
+
end # module Ccls::ActionViewExtension::FormBuilder
|
38
|
+
ActionView::Helpers::FormBuilder.send(:include,
|
39
|
+
Ccls::ActionViewExtension::FormBuilder )
|
@@ -0,0 +1,70 @@
|
|
1
|
+
module Ccls::ActiveRecordExtension::Base
|
2
|
+
|
3
|
+
def self.included(base)
|
4
|
+
# base.send(:include, InstanceMethods)
|
5
|
+
base.extend(ClassMethods)
|
6
|
+
end
|
7
|
+
|
8
|
+
module ClassMethods
|
9
|
+
|
10
|
+
def acts_like_a_hash(*args)
|
11
|
+
options = {
|
12
|
+
:key => :key,
|
13
|
+
:value => :description
|
14
|
+
}.update(args.extract_options!)
|
15
|
+
|
16
|
+
class_eval do
|
17
|
+
|
18
|
+
validates_presence_of options[:key], options[:value]
|
19
|
+
validates_uniqueness_of options[:key], options[:value]
|
20
|
+
validates_length_of options[:key], options[:value],
|
21
|
+
:maximum => 250, :allow_blank => true
|
22
|
+
|
23
|
+
# Treats the class a bit like a Hash and
|
24
|
+
# searches for a record with a matching key.
|
25
|
+
def self.[](key)
|
26
|
+
# may need to deal with options[:key] here, but not needed yet
|
27
|
+
find_by_key(key.to_s)
|
28
|
+
end
|
29
|
+
|
30
|
+
end # class_eval do
|
31
|
+
end # def acts_like_a_hash(*args)
|
32
|
+
|
33
|
+
|
34
|
+
# #
|
35
|
+
# # Create virtual attribute accessors for datetime parts,
|
36
|
+
# # year, month, day, hour, minute for use by
|
37
|
+
# # view selectors and model validations?
|
38
|
+
# #
|
39
|
+
# # If this all works, may want to separate it out.
|
40
|
+
# #
|
41
|
+
# def datetime_accessors_for(*args)
|
42
|
+
# options = {
|
43
|
+
# }.update(args.extract_options!)
|
44
|
+
# args.each do |field|
|
45
|
+
#
|
46
|
+
## What if there is no 'field'? Typo?
|
47
|
+
#
|
48
|
+
## When to actually compile the 'field'
|
49
|
+
#
|
50
|
+
## define instance variable "#{field}_year"
|
51
|
+
#
|
52
|
+
# define_method "#{field}_year" do
|
53
|
+
# # return the instance variable? or pull it from 'field'?
|
54
|
+
# end
|
55
|
+
#
|
56
|
+
# define_method "#{field}_year=" do |new_year|
|
57
|
+
# # just set the instance variable?
|
58
|
+
# end
|
59
|
+
#
|
60
|
+
# end
|
61
|
+
# end # def datetime_accessors_for(*args)
|
62
|
+
|
63
|
+
end # module ClassMethods
|
64
|
+
|
65
|
+
# module InstanceMethods
|
66
|
+
# end # module InstanceMethods
|
67
|
+
|
68
|
+
end # module Ccls::ActiveRecordExtension::Base
|
69
|
+
ActiveRecord::Base.send(:include,
|
70
|
+
Ccls::ActiveRecordExtension::Base )
|
@@ -0,0 +1,69 @@
|
|
1
|
+
module Ccls::Assertions
|
2
|
+
|
3
|
+
def self.included(base)
|
4
|
+
base.extend(ClassMethods)
|
5
|
+
end
|
6
|
+
|
7
|
+
def assert_subject_is_eligible(study_subject)
|
8
|
+
hxe = study_subject.enrollments.find_by_project_id(Project['HomeExposures'].id)
|
9
|
+
assert_not_nil hxe
|
10
|
+
assert_nil hxe.ineligible_reason_id
|
11
|
+
assert_equal hxe.is_eligible, YNDK[:yes]
|
12
|
+
end
|
13
|
+
alias_method :assert_study_subject_is_eligible, :assert_subject_is_eligible
|
14
|
+
|
15
|
+
def assert_subject_is_not_eligible(study_subject)
|
16
|
+
hxe = study_subject.enrollments.find_by_project_id(Project['HomeExposures'].id)
|
17
|
+
assert_not_nil hxe
|
18
|
+
assert_not_nil hxe.ineligible_reason_id
|
19
|
+
assert_equal hxe.is_eligible, YNDK[:no]
|
20
|
+
end
|
21
|
+
alias_method :assert_study_subject_is_not_eligible, :assert_subject_is_not_eligible
|
22
|
+
|
23
|
+
module ClassMethods
|
24
|
+
|
25
|
+
def assert_should_create_default_object
|
26
|
+
# It appears that model_name is a defined class method already in ...
|
27
|
+
# activesupport-####/lib/active_support/core_ext/module/model_naming.rb
|
28
|
+
test "should create default #{model_name.sub(/Test$/,'').underscore}" do
|
29
|
+
assert_difference( "#{model_name}.count", 1 ) do
|
30
|
+
object = create_object
|
31
|
+
assert !object.new_record?,
|
32
|
+
"#{object.errors.full_messages.to_sentence}"
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def assert_should_behave_like_a_hash(*args)
|
38
|
+
options = {
|
39
|
+
:key => :key,
|
40
|
+
:value => :description
|
41
|
+
}
|
42
|
+
options.update(args.extract_options!)
|
43
|
+
|
44
|
+
assert_should_require_attribute( options[:key], options[:value] )
|
45
|
+
assert_should_require_unique_attribute( options[:key], options[:value] )
|
46
|
+
assert_should_require_attribute_length( options[:key], options[:value],
|
47
|
+
:maximum => 250 )
|
48
|
+
|
49
|
+
test "should find by key with ['string']" do
|
50
|
+
object = create_object
|
51
|
+
assert object.is_a?(model_name.constantize)
|
52
|
+
found = (model_name.constantize)[object.key.to_s]
|
53
|
+
assert found.is_a?(model_name.constantize)
|
54
|
+
assert_equal object, found
|
55
|
+
end
|
56
|
+
|
57
|
+
test "should find by key with [:symbol]" do
|
58
|
+
object = create_object
|
59
|
+
assert object.is_a?(model_name.constantize)
|
60
|
+
found = (model_name.constantize)[object.key.to_sym]
|
61
|
+
assert found.is_a?(model_name.constantize)
|
62
|
+
assert_equal object, found
|
63
|
+
end
|
64
|
+
|
65
|
+
end
|
66
|
+
|
67
|
+
end
|
68
|
+
end
|
69
|
+
ActiveSupport::TestCase.send(:include,Ccls::Assertions)
|
@@ -0,0 +1,54 @@
|
|
1
|
+
class Autotest::Rails
|
2
|
+
|
3
|
+
#
|
4
|
+
# Need both the mapping and the extra files
|
5
|
+
#
|
6
|
+
def run_with_ccls_engine
|
7
|
+
add_exception %r%config/%
|
8
|
+
add_exception %r%versions/%
|
9
|
+
add_exception %r%\.git/%
|
10
|
+
self.extra_files << File.expand_path(File.join(
|
11
|
+
File.dirname(__FILE__),'/../../test/unit/ccls/'))
|
12
|
+
|
13
|
+
# self.extra_files << File.expand_path(File.join(
|
14
|
+
# File.dirname(__FILE__),'/../../test/functional/ccls/'))
|
15
|
+
|
16
|
+
# add_mapping(
|
17
|
+
# %r{^#{File.expand_path(File.join(File.dirname(__FILE__),'/../../test/'))}/(unit|functional)/ccls/.*_test\.rb$}
|
18
|
+
# ) do |filename, _|
|
19
|
+
# filename
|
20
|
+
# end
|
21
|
+
|
22
|
+
add_mapping(
|
23
|
+
%r{^#{File.expand_path(File.join(File.dirname(__FILE__),'/../../test/'))}/unit/ccls/.*_test\.rb$}
|
24
|
+
) do |filename, _|
|
25
|
+
filename
|
26
|
+
end
|
27
|
+
|
28
|
+
##
|
29
|
+
# This stops the ...
|
30
|
+
#
|
31
|
+
# Unable to map class Ccls::IdentifierTest to a file
|
32
|
+
# Unable to map class Ccls::SubjectTest to a file
|
33
|
+
#
|
34
|
+
# By default autotest is expecting all the namespaces to end with Test
|
35
|
+
# ie. CclsTest::IdentifierTest
|
36
|
+
# Could have renamed the dir, I suppose.
|
37
|
+
#
|
38
|
+
Dir[File.join(File.dirname(__FILE__),'/../../test/unit/**/*rb')].each do |f|
|
39
|
+
# the condition isn't as important as grabbing "ccls/test_file_name.rb" for camelcasing
|
40
|
+
if f =~ /test\/unit\/(ccls\/.*)\.rb/
|
41
|
+
self.extra_class_map[$1.camelcase] = File.expand_path(f)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
# Dir[File.join(File.dirname(__FILE__),'/../../test/functional/**/*rb')].each do |f|
|
45
|
+
# if f =~ /test\/functional\/(ccls\/.*)\.rb/
|
46
|
+
# self.extra_class_map[$1.camelcase] = File.expand_path(f)
|
47
|
+
# end
|
48
|
+
# end
|
49
|
+
|
50
|
+
run_without_ccls_engine
|
51
|
+
end
|
52
|
+
alias_method_chain :run, :ccls_engine
|
53
|
+
|
54
|
+
end
|
@@ -0,0 +1,117 @@
|
|
1
|
+
# == requires
|
2
|
+
# * uid (unique)
|
3
|
+
#
|
4
|
+
# == accessible attributes
|
5
|
+
# * sn
|
6
|
+
# * displayname
|
7
|
+
# * mail
|
8
|
+
# * telephonenumber
|
9
|
+
class Ccls::User < Calnet::User #ActiveRecord::Base
|
10
|
+
self.abstract_class = true
|
11
|
+
|
12
|
+
# def self.search(options={})
|
13
|
+
# conditions = {}
|
14
|
+
# includes = joins = []
|
15
|
+
# if !options[:role_name].blank?
|
16
|
+
# includes = [:roles]
|
17
|
+
# if Role.all.collect(&:name).include?(options[:role_name])
|
18
|
+
# joins = [:roles]
|
19
|
+
## conditions = ["roles.name = '#{options[:role_name]}'"]
|
20
|
+
# conditions = ["roles.name = ?",options[:role_name]]
|
21
|
+
# # else
|
22
|
+
# # @errors = "No such role '#{options[:role_name]}'"
|
23
|
+
# end
|
24
|
+
# end
|
25
|
+
# self.all(
|
26
|
+
# :joins => joins,
|
27
|
+
# :include => includes,
|
28
|
+
# :conditions => conditions )
|
29
|
+
# end
|
30
|
+
#
|
31
|
+
# # Find or Create a user from a given uid, and then
|
32
|
+
# # proceed to update the user's information from the
|
33
|
+
# # UCB::LDAP::Person.find_by_uid(uid) response.
|
34
|
+
# #
|
35
|
+
# # Returns: user
|
36
|
+
# def self.find_create_and_update_by_uid(uid)
|
37
|
+
# user = self.find_or_create_by_uid(uid)
|
38
|
+
# person = UCB::LDAP::Person.find_by_uid(uid)
|
39
|
+
# user.update_attributes!({
|
40
|
+
# :displayname => person.displayname,
|
41
|
+
# :sn => person.sn.first,
|
42
|
+
# :mail => person.mail.first || '',
|
43
|
+
# :telephonenumber => person.telephonenumber.first
|
44
|
+
# }) unless person.nil?
|
45
|
+
# user
|
46
|
+
# end
|
47
|
+
#
|
48
|
+
# # FYI. gravatar can't deal with a nil email
|
49
|
+
# gravatar :mail, :rating => 'PG'
|
50
|
+
#
|
51
|
+
# # gravatar.url will include & that are not encoded to &
|
52
|
+
# # which works just fine, but technically is invalid html.
|
53
|
+
# def gravatar_url
|
54
|
+
# gravatar.url.gsub(/&/,'&')
|
55
|
+
# end
|
56
|
+
#
|
57
|
+
# def to_s
|
58
|
+
# displayname
|
59
|
+
# end
|
60
|
+
|
61
|
+
# this has been included above
|
62
|
+
# ucb_authenticated
|
63
|
+
|
64
|
+
# defined in plugin/engine ...
|
65
|
+
#
|
66
|
+
# def may_administrate?(*args)
|
67
|
+
# (self.role_names & ['superuser','administrator']).length > 0
|
68
|
+
# end
|
69
|
+
#
|
70
|
+
# def may_read?(*args)
|
71
|
+
# (self.role_names &
|
72
|
+
# ['superuser','administrator','editor','interviewer','reader']
|
73
|
+
# ).length > 0
|
74
|
+
# end
|
75
|
+
#
|
76
|
+
# def may_edit?(*args)
|
77
|
+
# (self.role_names &
|
78
|
+
# ['superuser','administrator','editor']
|
79
|
+
# ).length > 0
|
80
|
+
# end
|
81
|
+
|
82
|
+
def self.inherited(subclass)
|
83
|
+
|
84
|
+
subclass.class_eval do
|
85
|
+
# for some reason is nil which causes problems
|
86
|
+
self.default_scoping = []
|
87
|
+
|
88
|
+
# I don't think that having this in a separate gem
|
89
|
+
# is necessary anymore. This is the only place that
|
90
|
+
# it is ever used. I'll import the calnet_authenticated
|
91
|
+
# functionality later.
|
92
|
+
# calnet_authenticated
|
93
|
+
# validates_presence_of :uid
|
94
|
+
# validates_uniqueness_of :uid
|
95
|
+
|
96
|
+
# include the many may_*? for use in the controllers
|
97
|
+
# I don't know why I need this in BOTH Calnet::User AND Ccls::User
|
98
|
+
# It works without it in the console, but some random tests fail
|
99
|
+
# should probably ensure that calling it twice doesn't do anything bad
|
100
|
+
authorized
|
101
|
+
|
102
|
+
# alias_method :may_create?, :may_edit?
|
103
|
+
# alias_method :may_update?, :may_edit?
|
104
|
+
# alias_method :may_destroy?, :may_edit?
|
105
|
+
|
106
|
+
# %w( people races languages refusal_reasons ineligible_reasons
|
107
|
+
# ).each do |resource|
|
108
|
+
# alias_method "may_create_#{resource}?".to_sym, :may_administrate?
|
109
|
+
# alias_method "may_read_#{resource}?".to_sym, :may_administrate?
|
110
|
+
# alias_method "may_edit_#{resource}?".to_sym, :may_administrate?
|
111
|
+
# alias_method "may_update_#{resource}?".to_sym, :may_administrate?
|
112
|
+
# alias_method "may_destroy_#{resource}?".to_sym, :may_administrate?
|
113
|
+
# end
|
114
|
+
end # class_eval
|
115
|
+
end # inherited()
|
116
|
+
|
117
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module Ccls::CoreExtension
|
2
|
+
|
3
|
+
def class_exists?(full_class_name)
|
4
|
+
name_spaces = full_class_name.to_s.split('::')
|
5
|
+
class_name = name_spaces.pop
|
6
|
+
name_space = name_spaces.join('::')
|
7
|
+
klass = ((name_space.blank?) ? Module : name_space.constantize).const_get(class_name.to_s)
|
8
|
+
return klass.is_a?(Class)
|
9
|
+
rescue NameError
|
10
|
+
return false
|
11
|
+
end
|
12
|
+
|
13
|
+
end # Ccls::CoreExtension
|
14
|
+
include Ccls::CoreExtension
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# %a - The abbreviated weekday name (``Sun'')
|
2
|
+
# %A - The full weekday name (``Sunday'')
|
3
|
+
# %b - The abbreviated month name (``Jan'')
|
4
|
+
# %B - The full month name (``January'')
|
5
|
+
# %c - The preferred local date and time representation
|
6
|
+
# %d - Day of the month (01..31)
|
7
|
+
# %H - Hour of the day, 24-hour clock (00..23)
|
8
|
+
# %I - Hour of the day, 12-hour clock (01..12)
|
9
|
+
# %j - Day of the year (001..366)
|
10
|
+
# %m - Month of the year (01..12)
|
11
|
+
# %M - Minute of the hour (00..59)
|
12
|
+
# %p - Meridian indicator (``AM'' or ``PM'')
|
13
|
+
# %S - Second of the minute (00..60)
|
14
|
+
# %U - Week number of the current year,
|
15
|
+
# starting with the first Sunday as the first
|
16
|
+
# day of the first week (00..53)
|
17
|
+
# %W - Week number of the current year,
|
18
|
+
# starting with the first Monday as the first
|
19
|
+
# day of the first week (00..53)
|
20
|
+
# %w - Day of the week (Sunday is 0, 0..6)
|
21
|
+
# %x - Preferred representation for the date alone, no time
|
22
|
+
# %X - Preferred representation for the time alone, no date
|
23
|
+
# %y - Year without a century (00..99)
|
24
|
+
# %Y - Year with century
|
25
|
+
# %Z - Time zone name
|
26
|
+
|
27
|
+
Time::DATE_FORMATS[:mdy] = "%b %d, %Y" # Jan 01, 2009
|
28
|
+
Time::DATE_FORMATS[:dob] = "%m/%d/%Y" # 01/01/2009
|
29
|
+
Date::DATE_FORMATS[:dob] = "%m/%d/%Y" # 01/01/2009
|
30
|
+
Time::DATE_FORMATS[:filename] = "%Y%m%d%H%M%S" # 20091231235959
|