pvdgm_services 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/README.md +29 -0
- data/Rakefile +40 -0
- data/app/contexts/services/accept_hl7_message_context.rb +32 -0
- data/app/contexts/services/application_mds_context.rb +21 -0
- data/app/contexts/services/complete_sltc_registration_process_context.rb +23 -0
- data/app/contexts/services/create_account_mapping_context.rb +23 -0
- data/app/contexts/services/create_configured_account_context.rb +26 -0
- data/app/contexts/services/create_configured_facility_context.rb +26 -0
- data/app/contexts/services/create_credential_context.rb +23 -0
- data/app/contexts/services/create_facility_mapping_context.rb +23 -0
- data/app/contexts/services/create_public_key_context.rb +22 -0
- data/app/contexts/services/create_service_context.rb +22 -0
- data/app/contexts/services/create_service_definition_context.rb +26 -0
- data/app/contexts/services/create_sltc_registration_context.rb +24 -0
- data/app/contexts/services/create_third_party_context.rb +22 -0
- data/app/contexts/services/hl7_message_trimming_context.rb +19 -0
- data/app/contexts/services/invoke_service_context.rb +21 -0
- data/app/contexts/services/list_sltc_providers_context.rb +22 -0
- data/app/contexts/services/mds_file_processing_context.rb +27 -0
- data/app/contexts/services/mds_file_upload_context.rb +25 -0
- data/app/contexts/services/mds_pull_context.rb +21 -0
- data/app/contexts/services/monthly_service_table_cleanup_context.rb +19 -0
- data/app/contexts/services/notify_new_registration_context.rb +22 -0
- data/app/contexts/services/notify_sltc_provider_change_context.rb +19 -0
- data/app/contexts/services/request_sltc_baseline_context.rb +23 -0
- data/app/contexts/services/update_account_mapping_context.rb +23 -0
- data/app/contexts/services/update_configured_account_context.rb +26 -0
- data/app/contexts/services/update_configured_facility_context.rb +26 -0
- data/app/contexts/services/update_credential_context.rb +23 -0
- data/app/contexts/services/update_facility_mapping_context.rb +23 -0
- data/app/contexts/services/update_public_key_context.rb +23 -0
- data/app/contexts/services/update_service_context.rb +23 -0
- data/app/contexts/services/update_service_definition_context.rb +26 -0
- data/app/contexts/services/update_third_party_context.rb +23 -0
- data/app/controllers/services/account_mappings_controller.rb +54 -0
- data/app/controllers/services/adts_controller.rb +35 -0
- data/app/controllers/services/application_controller.rb +17 -0
- data/app/controllers/services/assessment_requests_controller.rb +48 -0
- data/app/controllers/services/available_files_controller.rb +19 -0
- data/app/controllers/services/configured_account_base_controller.rb +17 -0
- data/app/controllers/services/configured_accounts_controller.rb +59 -0
- data/app/controllers/services/configured_facilities_controller.rb +65 -0
- data/app/controllers/services/facility_mappings_controller.rb +58 -0
- data/app/controllers/services/mds_files_controller.rb +75 -0
- data/app/controllers/services/mds_pull_accounts_controller.rb +57 -0
- data/app/controllers/services/public_keys_controller.rb +50 -0
- data/app/controllers/services/service_base_controller.rb +18 -0
- data/app/controllers/services/service_definition_base_controller.rb +31 -0
- data/app/controllers/services/service_definitions_controller.rb +59 -0
- data/app/controllers/services/services_controller.rb +56 -0
- data/app/controllers/services/sltc_providers_controller.rb +15 -0
- data/app/controllers/services/sltc_registrations_controller.rb +74 -0
- data/app/controllers/services/status_masking.rb +17 -0
- data/app/controllers/services/third_parties_controller.rb +47 -0
- data/app/controllers/services/third_party_base_controller.rb +17 -0
- data/app/controllers/services/validation_controller.rb +17 -0
- data/app/helpers/services/application_helper.rb +8 -0
- data/app/helpers/services/assessment_request_helper.rb +19 -0
- data/app/helpers/services/available_files_helper.rb +27 -0
- data/app/helpers/services/mds_pull_accounts_helper.rb +27 -0
- data/app/helpers/services/sltc_registrations_helper.rb +15 -0
- data/app/mailers/services_mailer.rb +57 -0
- data/app/models/services/abaqis_mds_push.rb +51 -0
- data/app/models/services/account_mapping.rb +10 -0
- data/app/models/services/application_api.rb +19 -0
- data/app/models/services/assessment_request.rb +18 -0
- data/app/models/services/available_file.rb +73 -0
- data/app/models/services/configured_account.rb +26 -0
- data/app/models/services/configured_facility.rb +16 -0
- data/app/models/services/credential.rb +9 -0
- data/app/models/services/facility_mapping.rb +12 -0
- data/app/models/services/ftp_server.rb +69 -0
- data/app/models/services/hl7_inbound_service.rb +47 -0
- data/app/models/services/hl7_message.rb +27 -0
- data/app/models/services/isc_code.rb +15 -0
- data/app/models/services/isc_code_lookup.rb +75 -0
- data/app/models/services/mds_assessment.rb +371 -0
- data/app/models/services/mds_content.rb +55 -0
- data/app/models/services/mds_pull.rb +41 -0
- data/app/models/services/mds_pull_account.rb +192 -0
- data/app/models/services/mds_push.rb +24 -0
- data/app/models/services/mds_upload.rb +64 -0
- data/app/models/services/mds_upload_content.rb +148 -0
- data/app/models/services/mds_ws_response.rb +21 -0
- data/app/models/services/mds_ws_response_handler.rb +31 -0
- data/app/models/services/pcc_mds_pull.rb +77 -0
- data/app/models/services/provider_change.rb +26 -0
- data/app/models/services/public_key.rb +11 -0
- data/app/models/services/service.rb +20 -0
- data/app/models/services/service_definition.rb +37 -0
- data/app/models/services/service_implementation.rb +29 -0
- data/app/models/services/sltc_api.rb +179 -0
- data/app/models/services/sltc_api_exception.rb +54 -0
- data/app/models/services/sltc_mds_pull.rb +230 -0
- data/app/models/services/sltc_registration.rb +23 -0
- data/app/models/services/third_party.rb +18 -0
- data/app/roles/services/account_mapping_creator.rb +13 -0
- data/app/roles/services/account_mapping_updator.rb +12 -0
- data/app/roles/services/configured_account_creator.rb +13 -0
- data/app/roles/services/configured_account_updater.rb +12 -0
- data/app/roles/services/configured_facility_creator.rb +13 -0
- data/app/roles/services/configured_facility_updater.rb +12 -0
- data/app/roles/services/credential_creator.rb +11 -0
- data/app/roles/services/credential_updater.rb +20 -0
- data/app/roles/services/facility_mapping_creator.rb +13 -0
- data/app/roles/services/facility_mapping_updater.rb +11 -0
- data/app/roles/services/hl7_adt_message_saver.rb +15 -0
- data/app/roles/services/hl7_message_trimmer.rb +14 -0
- data/app/roles/services/mds_assessment_categorizer.rb +71 -0
- data/app/roles/services/mds_file_processor.rb +86 -0
- data/app/roles/services/mds_notifications.rb +44 -0
- data/app/roles/services/monthly_service_table_cleaner.rb +19 -0
- data/app/roles/services/new_registration_notifier.rb +11 -0
- data/app/roles/services/public_key_creator.rb +14 -0
- data/app/roles/services/public_key_updater.rb +12 -0
- data/app/roles/services/service_creator.rb +13 -0
- data/app/roles/services/service_definition_creator.rb +13 -0
- data/app/roles/services/service_definition_updater.rb +12 -0
- data/app/roles/services/service_invoker.rb +25 -0
- data/app/roles/services/service_updater.rb +11 -0
- data/app/roles/services/sltc_baseline_requestor.rb +19 -0
- data/app/roles/services/sltc_provider_change_notifier.rb +25 -0
- data/app/roles/services/sltc_provider_lister.rb +13 -0
- data/app/roles/services/sltc_registration_completer.rb +81 -0
- data/app/roles/services/sltc_registration_saver.rb +13 -0
- data/app/roles/services/submit_mds_file_for_processing.rb +28 -0
- data/app/roles/services/third_party_creator.rb +13 -0
- data/app/roles/services/third_party_updater.rb +12 -0
- data/app/utils/services/file_upload_handler.rb +33 -0
- data/app/utils/services/mds_upload_filters.rb +26 -0
- data/app/utils/services/mds_xml_file_parser.rb +104 -0
- data/app/utils/services/upload_file.rb +13 -0
- data/app/validators/isc_code_validator.rb +42 -0
- data/app/validators/mds_birthdate_validator.rb +37 -0
- data/app/validators/mds_date_validator.rb +8 -0
- data/app/validators/mds_integer_validator.rb +15 -0
- data/app/validators/mds_version_validator.rb +16 -0
- data/app/validators/state_code_validator.rb +9 -0
- data/app/views/layouts/services/application.html.erb +14 -0
- data/app/views/services/account_mappings/index.json.jbuilder +9 -0
- data/app/views/services/account_mappings/show.json.jbuilder +7 -0
- data/app/views/services/assessment_requests/index.json.jbuilder +11 -0
- data/app/views/services/available_files/index.json.jbuilder +13 -0
- data/app/views/services/configured_accounts/index.json.jbuilder +13 -0
- data/app/views/services/configured_accounts/show.json.jbuilder +11 -0
- data/app/views/services/configured_facilities/index.json.jbuilder +13 -0
- data/app/views/services/configured_facilities/show.json.jbuilder +11 -0
- data/app/views/services/facility_mappings/index.json.jbuilder +10 -0
- data/app/views/services/facility_mappings/show.json.jbuilder +8 -0
- data/app/views/services/mds_files/create.builder +10 -0
- data/app/views/services/mds_pull_accounts/index.json.jbuilder +11 -0
- data/app/views/services/public_keys/index.json.jbuilder +8 -0
- data/app/views/services/public_keys/show.json.jbuilder +6 -0
- data/app/views/services/service_definitions/index.json.jbuilder +17 -0
- data/app/views/services/service_definitions/show.json.jbuilder +16 -0
- data/app/views/services/services/index.json.jbuilder +6 -0
- data/app/views/services/services/show.json.jbuilder +4 -0
- data/app/views/services/sltc_providers/index.json.jbuilder +10 -0
- data/app/views/services/sltc_registrations/index.json.jbuilder +10 -0
- data/app/views/services/third_parties/index.json.jbuilder +7 -0
- data/app/views/services/third_parties/show.json.jbuilder +5 -0
- data/app/views/services_mailer/burying_job.html.erb +20 -0
- data/app/views/services_mailer/delaying_job.html.erb +20 -0
- data/app/views/services_mailer/notify_sltc_client_registration.html.erb +39 -0
- data/app/views/services_mailer/notify_sltc_client_registration_invalid_request_type.html.erb +8 -0
- data/app/views/services_mailer/notify_sltc_client_registration_request_invalid.html.erb +10 -0
- data/app/views/services_mailer/notify_sltc_client_registration_validation_errors.html.erb +13 -0
- data/app/views/services_mailer/notify_sltc_provider_changes.html.erb +26 -0
- data/app/views/services_mailer/notify_support_about_no_mds_pull.html.erb +6 -0
- data/config/routes.rb +48 -0
- data/db/migrate/20140102000000_create_services_engine_tables.rb +131 -0
- data/db/migrate/20140517184450_new_services_columns.rb +24 -0
- data/db/migrate/20140525142842_new_configured_provider_table.rb +18 -0
- data/db/migrate/20140714172442_add_error_column_to_hl7_messages.rb +5 -0
- data/db/migrate/20140730164152_mds_upload_tables.rb +78 -0
- data/db/sql_data/service_data_setup.sql +24 -0
- data/lib/services/engine.rb +40 -0
- data/lib/services/version.rb +3 -0
- data/lib/services.rb +4 -0
- data/lib/tasks/services_tasks.rake +40 -0
- data/spec/dummy/README.rdoc +261 -0
- data/spec/dummy/Rakefile +7 -0
- data/spec/dummy/app/assets/javascripts/application.js +15 -0
- data/spec/dummy/app/assets/stylesheets/application.css +13 -0
- data/spec/dummy/app/controllers/application_controller.rb +3 -0
- data/spec/dummy/app/helpers/application_helper.rb +2 -0
- data/spec/dummy/app/views/layouts/application.html.erb +14 -0
- data/spec/dummy/config/application.rb +60 -0
- data/spec/dummy/config/boot.rb +10 -0
- data/spec/dummy/config/database.yml +29 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/development.rb +35 -0
- data/spec/dummy/config/environments/production.rb +68 -0
- data/spec/dummy/config/environments/test.rb +32 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy/config/initializers/email.rb +1 -0
- data/spec/dummy/config/initializers/inflections.rb +15 -0
- data/spec/dummy/config/initializers/mime_types.rb +5 -0
- data/spec/dummy/config/initializers/secret_token.rb +7 -0
- data/spec/dummy/config/initializers/session_store.rb +8 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/spec/dummy/config/locales/en.yml +5 -0
- data/spec/dummy/config/routes.rb +4 -0
- data/spec/dummy/config.ru +4 -0
- data/spec/dummy/db/schema.rb +237 -0
- data/spec/dummy/db/sql_data/services_isc_codes.sql +878 -0
- data/spec/dummy/log/test.log +3498 -0
- data/spec/dummy/public/404.html +26 -0
- data/spec/dummy/public/422.html +26 -0
- data/spec/dummy/public/500.html +25 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/dummy/script/rails +6 -0
- data/spec/models/abaqis_mds_push_spec.rb +120 -0
- data/spec/models/available_file_spec.rb +234 -0
- data/spec/models/configured_account_spec.rb +39 -0
- data/spec/models/ftp_server_spec.rb +221 -0
- data/spec/models/isc_code_lookup_spec.rb +125 -0
- data/spec/models/isc_code_spec.rb +5 -0
- data/spec/models/mds_assessment_spec.rb +1070 -0
- data/spec/models/mds_pull_account_spec.rb +468 -0
- data/spec/models/mds_pull_spec.rb +48 -0
- data/spec/models/mds_push_spec.rb +43 -0
- data/spec/models/mds_ws_response_spec.rb +54 -0
- data/spec/models/pcc_mds_pull_spec.rb +273 -0
- data/spec/models/service_implementation_spec.rb +88 -0
- data/spec/models/sltc_api_exception_spec.rb +136 -0
- data/spec/models/sltc_api_spec.rb +192 -0
- data/spec/models/sltc_mds_pull_spec.rb +776 -0
- data/spec/roles/account_mapping_creator_spec.rb +40 -0
- data/spec/roles/account_mapping_updator_spec.rb +16 -0
- data/spec/roles/configured_account_creator_spec.rb +40 -0
- data/spec/roles/configured_account_updater_spec.rb +16 -0
- data/spec/roles/configured_facility_creator_spec.rb +40 -0
- data/spec/roles/configured_facility_updater_spec.rb +16 -0
- data/spec/roles/credential_creator_spec.rb +23 -0
- data/spec/roles/credential_updater_spec.rb +38 -0
- data/spec/roles/facility_mapping_creator_spec.rb +40 -0
- data/spec/roles/facility_mapping_updater_spec.rb +16 -0
- data/spec/roles/hl7_adt_message_saver_spec.rb +35 -0
- data/spec/roles/hl7_message_trimmer_spec.rb +31 -0
- data/spec/roles/monthly_service_table_cleaner_spec.rb +27 -0
- data/spec/roles/new_registration_notifier_spec.rb +18 -0
- data/spec/roles/service_ceator_spec.rb +34 -0
- data/spec/roles/service_definition_creator_spec.rb +40 -0
- data/spec/roles/service_definition_updater_spec.rb +16 -0
- data/spec/roles/service_invoker_spec.rb +22 -0
- data/spec/roles/service_updater_spec.rb +17 -0
- data/spec/roles/sltc_baseline_requestor_spec.rb +30 -0
- data/spec/roles/sltc_provider_lister_spec.rb +27 -0
- data/spec/roles/sltc_registration_completer_spec.rb +187 -0
- data/spec/roles/sltc_registration_saver_spec.rb +34 -0
- data/spec/roles/third_party_creator_spec.rb +34 -0
- data/spec/roles/third_party_updater_spec.rb +17 -0
- data/spec/spec_helper.rb +72 -0
- metadata +581 -0
@@ -0,0 +1,26 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>The page you were looking for doesn't exist (404)</title>
|
5
|
+
<style type="text/css">
|
6
|
+
body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
|
7
|
+
div.dialog {
|
8
|
+
width: 25em;
|
9
|
+
padding: 0 4em;
|
10
|
+
margin: 4em auto 0 auto;
|
11
|
+
border: 1px solid #ccc;
|
12
|
+
border-right-color: #999;
|
13
|
+
border-bottom-color: #999;
|
14
|
+
}
|
15
|
+
h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
|
16
|
+
</style>
|
17
|
+
</head>
|
18
|
+
|
19
|
+
<body>
|
20
|
+
<!-- This file lives in public/404.html -->
|
21
|
+
<div class="dialog">
|
22
|
+
<h1>The page you were looking for doesn't exist.</h1>
|
23
|
+
<p>You may have mistyped the address or the page may have moved.</p>
|
24
|
+
</div>
|
25
|
+
</body>
|
26
|
+
</html>
|
@@ -0,0 +1,26 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>The change you wanted was rejected (422)</title>
|
5
|
+
<style type="text/css">
|
6
|
+
body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
|
7
|
+
div.dialog {
|
8
|
+
width: 25em;
|
9
|
+
padding: 0 4em;
|
10
|
+
margin: 4em auto 0 auto;
|
11
|
+
border: 1px solid #ccc;
|
12
|
+
border-right-color: #999;
|
13
|
+
border-bottom-color: #999;
|
14
|
+
}
|
15
|
+
h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
|
16
|
+
</style>
|
17
|
+
</head>
|
18
|
+
|
19
|
+
<body>
|
20
|
+
<!-- This file lives in public/422.html -->
|
21
|
+
<div class="dialog">
|
22
|
+
<h1>The change you wanted was rejected.</h1>
|
23
|
+
<p>Maybe you tried to change something you didn't have access to.</p>
|
24
|
+
</div>
|
25
|
+
</body>
|
26
|
+
</html>
|
@@ -0,0 +1,25 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>We're sorry, but something went wrong (500)</title>
|
5
|
+
<style type="text/css">
|
6
|
+
body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
|
7
|
+
div.dialog {
|
8
|
+
width: 25em;
|
9
|
+
padding: 0 4em;
|
10
|
+
margin: 4em auto 0 auto;
|
11
|
+
border: 1px solid #ccc;
|
12
|
+
border-right-color: #999;
|
13
|
+
border-bottom-color: #999;
|
14
|
+
}
|
15
|
+
h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
|
16
|
+
</style>
|
17
|
+
</head>
|
18
|
+
|
19
|
+
<body>
|
20
|
+
<!-- This file lives in public/500.html -->
|
21
|
+
<div class="dialog">
|
22
|
+
<h1>We're sorry, but something went wrong.</h1>
|
23
|
+
</div>
|
24
|
+
</body>
|
25
|
+
</html>
|
File without changes
|
@@ -0,0 +1,6 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
|
3
|
+
|
4
|
+
APP_PATH = File.expand_path('../../config/application', __FILE__)
|
5
|
+
require File.expand_path('../../config/boot', __FILE__)
|
6
|
+
require 'rails/commands'
|
@@ -0,0 +1,120 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Services::AbaqisMdsPush do
|
4
|
+
|
5
|
+
context 'Instance Methods' do
|
6
|
+
|
7
|
+
before(:each) do
|
8
|
+
@service_definition = double("ServiceDefinition")
|
9
|
+
@amp = Services::AbaqisMdsPush.new(@service_definition)
|
10
|
+
end
|
11
|
+
|
12
|
+
context '#url' do
|
13
|
+
|
14
|
+
it "should properly format the URL for the service" do
|
15
|
+
@service_definition.should_receive(:server_base_url).and_return('https://www')
|
16
|
+
|
17
|
+
expect(@amp.url).to eq("https://www/stagei/mds30_composite_file")
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
|
22
|
+
context '#submit_to_service' do
|
23
|
+
|
24
|
+
it "should raise an exception if the account is not configured for the mds web service" do
|
25
|
+
mock_ca = double("ConfiguredAccount")
|
26
|
+
mock_ca.should_receive(:account_id).and_return(1)
|
27
|
+
|
28
|
+
@service_definition.should_receive(:configured_accounts).and_return do
|
29
|
+
double("ConfiguredAccounts").tap do | mock_cas |
|
30
|
+
mock_cas.should_receive(:where).
|
31
|
+
with(account_id: 1).
|
32
|
+
and_return([ ])
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
mock_af = double("AvailableFile")
|
37
|
+
|
38
|
+
mock_af.should_receive(:configured_account).and_return(mock_ca)
|
39
|
+
|
40
|
+
expect { @amp.submit_to_service(mock_af) }.to raise_error
|
41
|
+
|
42
|
+
end
|
43
|
+
|
44
|
+
it "should raise an exception if the account does not have a password configured" do
|
45
|
+
mock_ca = double("ConfiguredAccount")
|
46
|
+
mock_ca.should_receive(:account_id).and_return(1)
|
47
|
+
|
48
|
+
mock_sd_ca = double("SDCOnfiguredAccount")
|
49
|
+
mock_sd_ca.should_receive(:credentials).and_return([ ])
|
50
|
+
mock_sd_ca.should_receive(:enabled?).and_return(true)
|
51
|
+
|
52
|
+
@service_definition.should_receive(:configured_accounts).and_return do
|
53
|
+
double("ConfiguredAccounts").tap do | mock_cas |
|
54
|
+
mock_cas.should_receive(:where).
|
55
|
+
with(account_id: 1).
|
56
|
+
and_return([ mock_sd_ca ])
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
mock_af = double("AvailableFile")
|
61
|
+
mock_af.should_receive(:configured_account).and_return(mock_ca)
|
62
|
+
|
63
|
+
expect { @amp.submit_to_service(mock_af) }.to raise_error
|
64
|
+
|
65
|
+
end
|
66
|
+
|
67
|
+
it "should update the status attribute of the file to error if the upload fails" do
|
68
|
+
@amp.should_receive(:url).and_return("https://www.abaqis.com/stagei/mds30_composite_file")
|
69
|
+
|
70
|
+
mock_ca = double("ConfiguredAccount")
|
71
|
+
mock_ca.should_receive(:account_id).and_return(1089)
|
72
|
+
|
73
|
+
mock_cred = double("Credentials")
|
74
|
+
mock_cred.should_receive(:password).and_return('the password')
|
75
|
+
|
76
|
+
mock_sd_ca = double("SDCOnfiguredAccount")
|
77
|
+
mock_sd_ca.should_receive(:credentials).and_return([ mock_cred ])
|
78
|
+
mock_sd_ca.should_receive(:enabled?).and_return(true)
|
79
|
+
|
80
|
+
@service_definition.should_receive(:configured_accounts).and_return do
|
81
|
+
double("ConfiguredAccounts").tap do | mock_cas |
|
82
|
+
mock_cas.should_receive(:where).
|
83
|
+
with(account_id: 1089).
|
84
|
+
and_return([ mock_sd_ca ])
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
mock_af = double("AvailableFile")
|
89
|
+
mock_af.should_receive(:configured_account).and_return(mock_ca)
|
90
|
+
mock_af.should_receive(:actual_file_path).and_return('/tmp/somewhere.zip')
|
91
|
+
mock_af.should_receive(:update_attributes).with(status: Services::AvailableFile::STATUS_UPLOAD_ERROR, error: "The error message" )
|
92
|
+
|
93
|
+
mock_file = double("File")
|
94
|
+
File.should_receive(:new).with('/tmp/somewhere.zip', 'rb').and_return(mock_file)
|
95
|
+
|
96
|
+
mock_response = double("HTTPResponse")
|
97
|
+
mock_response.should_receive(:body).and_return("<?xml?>")
|
98
|
+
|
99
|
+
RestClient.
|
100
|
+
should_receive(:post).
|
101
|
+
with("https://www.abaqis.com/stagei/mds30_composite_file",
|
102
|
+
{ composite_file: mock_file },
|
103
|
+
{ 'account-id' => 1089,
|
104
|
+
'account-password' => 'the password' }).
|
105
|
+
and_return(mock_response)
|
106
|
+
|
107
|
+
mock_pr = double("ParsedResponse")
|
108
|
+
mock_pr.should_receive(:status).and_return(Services::MdsWsResponse::STATUS_ERROR)
|
109
|
+
mock_pr.should_receive(:error_message).and_return("The error message")
|
110
|
+
|
111
|
+
Services::MdsWsResponse.should_receive(:parse_xml_response).with("<?xml?>").and_return(mock_pr)
|
112
|
+
|
113
|
+
@amp.submit_to_service(mock_af)
|
114
|
+
end
|
115
|
+
|
116
|
+
end
|
117
|
+
|
118
|
+
end
|
119
|
+
|
120
|
+
end
|
@@ -0,0 +1,234 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Services::AvailableFile do
|
4
|
+
|
5
|
+
context 'Scopes' do
|
6
|
+
|
7
|
+
before(:each) do
|
8
|
+
tp = Services::ThirdParty.create!(name: 'MyThirdParty',
|
9
|
+
contact_email: 'joe@bazooka.com')
|
10
|
+
|
11
|
+
svc = Services::Service.create!(name: 'MyService')
|
12
|
+
|
13
|
+
sd = Services::ServiceDefinition.create!(third_party: tp,
|
14
|
+
service: svc,
|
15
|
+
hostname: 'localhost',
|
16
|
+
base_uri: '/home',
|
17
|
+
username: 'providigm',
|
18
|
+
service_class: 'MyServiceClass')
|
19
|
+
|
20
|
+
ca = Services::ConfiguredAccount.create!(service_definition: sd,
|
21
|
+
account_id: 2,
|
22
|
+
username: 'sam',
|
23
|
+
enabled: true)
|
24
|
+
|
25
|
+
@available_file = Services::AvailableFile.create!(configured_account: ca,
|
26
|
+
request_id: 'abc123',
|
27
|
+
filename: 'the_file.zip',
|
28
|
+
status: Services::AvailableFile::STATUS_AVAILABLE)
|
29
|
+
|
30
|
+
@downloaded_file = Services::AvailableFile.create!(configured_account: ca,
|
31
|
+
request_id: 'abc123',
|
32
|
+
filename: 'the_file.zip',
|
33
|
+
status: Services::AvailableFile::STATUS_DOWNLOADED)
|
34
|
+
|
35
|
+
@cleared_file = Services::AvailableFile.create!(configured_account: ca,
|
36
|
+
request_id: 'abc123',
|
37
|
+
filename: 'the_file.zip',
|
38
|
+
status: Services::AvailableFile::STATUS_CLEARED)
|
39
|
+
|
40
|
+
@uploaded_file = Services::AvailableFile.create!(configured_account: ca,
|
41
|
+
request_id: 'abc123',
|
42
|
+
filename: 'the_file.zip',
|
43
|
+
status: Services::AvailableFile::STATUS_UPLOADED)
|
44
|
+
|
45
|
+
@invalid_file = Services::AvailableFile.create!(configured_account: ca,
|
46
|
+
request_id: 'abc123',
|
47
|
+
filename: 'the_file.zip',
|
48
|
+
status: Services::AvailableFile::STATUS_INVALID)
|
49
|
+
|
50
|
+
@missing_file = Services::AvailableFile.create!(configured_account: ca,
|
51
|
+
request_id: 'abc123',
|
52
|
+
filename: 'the_file.zip',
|
53
|
+
status: Services::AvailableFile::STATUS_MISSING)
|
54
|
+
|
55
|
+
@upload_error_file = Services::AvailableFile.create!(configured_account: ca,
|
56
|
+
request_id: 'abc123',
|
57
|
+
filename: 'the_file.zip',
|
58
|
+
status: Services::AvailableFile::STATUS_UPLOAD_ERROR)
|
59
|
+
|
60
|
+
@deleted_file = Services::AvailableFile.create!(configured_account: ca,
|
61
|
+
request_id: 'abc123',
|
62
|
+
filename: 'the_file.zip',
|
63
|
+
status: Services::AvailableFile::STATUS_DELETED)
|
64
|
+
|
65
|
+
|
66
|
+
end
|
67
|
+
|
68
|
+
context 'available' do
|
69
|
+
|
70
|
+
it "should return only the available available files" do
|
71
|
+
expect(Services::AvailableFile.available).to eq([ @available_file ])
|
72
|
+
end
|
73
|
+
|
74
|
+
end
|
75
|
+
|
76
|
+
context 'downloaded' do
|
77
|
+
|
78
|
+
it "should return only the downloaded available files" do
|
79
|
+
expect(Services::AvailableFile.downloaded).to eq([ @downloaded_file ])
|
80
|
+
end
|
81
|
+
|
82
|
+
end
|
83
|
+
|
84
|
+
context 'cleared' do
|
85
|
+
|
86
|
+
it "should return only the cleared available files" do
|
87
|
+
expect(Services::AvailableFile.cleared).to eq([ @cleared_file ])
|
88
|
+
end
|
89
|
+
|
90
|
+
end
|
91
|
+
|
92
|
+
context 'uploaded' do
|
93
|
+
|
94
|
+
it "should return only the uploaded available files" do
|
95
|
+
expect(Services::AvailableFile.uploaded).to eq([ @uploaded_file ])
|
96
|
+
end
|
97
|
+
|
98
|
+
end
|
99
|
+
|
100
|
+
context 'invalid' do
|
101
|
+
|
102
|
+
it "should return only the invalid available files" do
|
103
|
+
expect(Services::AvailableFile.invalid).to eq([ @invalid_file ])
|
104
|
+
end
|
105
|
+
|
106
|
+
end
|
107
|
+
|
108
|
+
context 'missing' do
|
109
|
+
|
110
|
+
it "should return only the missing available files" do
|
111
|
+
expect(Services::AvailableFile.missing).to eq([ @missing_file ])
|
112
|
+
end
|
113
|
+
|
114
|
+
end
|
115
|
+
|
116
|
+
context 'upload_error' do
|
117
|
+
|
118
|
+
it "should return only the upload_error available files" do
|
119
|
+
expect(Services::AvailableFile.upload_error).to eq([ @upload_error_file ])
|
120
|
+
end
|
121
|
+
|
122
|
+
end
|
123
|
+
|
124
|
+
context 'deleted' do
|
125
|
+
|
126
|
+
it "should return only the deleted available files" do
|
127
|
+
expect(Services::AvailableFile.deleted).to eq([ @deleted_file ])
|
128
|
+
end
|
129
|
+
|
130
|
+
end
|
131
|
+
|
132
|
+
end
|
133
|
+
|
134
|
+
context 'Instance Methods' do
|
135
|
+
|
136
|
+
context '#downloaded_file_path' do
|
137
|
+
|
138
|
+
it "should create a path that includes the name of the file" do
|
139
|
+
af = Services::AvailableFile.new(filename: 'the_file.zip')
|
140
|
+
af.id = 32
|
141
|
+
|
142
|
+
expect(af.downloaded_file_path).to eq(Rails.root.join("tmp", "available_file_32", "the_file.zip").to_s)
|
143
|
+
end
|
144
|
+
|
145
|
+
end
|
146
|
+
|
147
|
+
context '#download_path' do
|
148
|
+
|
149
|
+
it "should create a path to which a file will be downloaded" do
|
150
|
+
af = Services::AvailableFile.new(filename: 'the_file.zip')
|
151
|
+
af.id = 32
|
152
|
+
|
153
|
+
expect(af.download_path).to eq(Rails.root.join("tmp", "available_file_32").to_s)
|
154
|
+
end
|
155
|
+
|
156
|
+
end
|
157
|
+
|
158
|
+
context '#split_path' do
|
159
|
+
|
160
|
+
it "should create a path to which assessments in an MDS file will be extracted" do
|
161
|
+
af = Services::AvailableFile.new(filename: 'the_file.zip')
|
162
|
+
af.id = 32
|
163
|
+
|
164
|
+
expect(af.split_path).to eq(Rails.root.join("tmp", "available_file_32", "split").to_s)
|
165
|
+
end
|
166
|
+
|
167
|
+
end
|
168
|
+
|
169
|
+
context '#composite_path' do
|
170
|
+
|
171
|
+
it "should create a path to where a composite file will be created" do
|
172
|
+
af = Services::AvailableFile.new(filename: 'the_file.zip',
|
173
|
+
composite_file_name: 'the_composite.zip')
|
174
|
+
af.id = 32
|
175
|
+
|
176
|
+
expect(af.composite_path).to eq(Rails.root.join("tmp", "available_file_32", "split", MdsFileUtils::ZipSplitter.name, "the_composite.zip").to_s)
|
177
|
+
end
|
178
|
+
|
179
|
+
end
|
180
|
+
|
181
|
+
context '#actual_file_path' do
|
182
|
+
|
183
|
+
it "should return the path to the normal mds file on the file system" do
|
184
|
+
af = Services::AvailableFile.new(filename: 'the_file.zip')
|
185
|
+
af.id = 32
|
186
|
+
|
187
|
+
expect(af.actual_file_path).to eq(Rails.root.join("tmp", "available_file_32", "the_file.zip").to_s)
|
188
|
+
end
|
189
|
+
|
190
|
+
it "should return the path to composite file on the file system" do
|
191
|
+
af = Services::AvailableFile.new(filename: 'the_file.zip',
|
192
|
+
composite_file_name: 'the_composite.zip')
|
193
|
+
af.id = 32
|
194
|
+
|
195
|
+
expect(af.composite_path).to eq(Rails.root.join("tmp", "available_file_32", "split", MdsFileUtils::ZipSplitter.name, "the_composite.zip").to_s)
|
196
|
+
end
|
197
|
+
|
198
|
+
end
|
199
|
+
|
200
|
+
context '#downloaded_file_exists?' do
|
201
|
+
|
202
|
+
it "should return true or false depending on if the downloaded file is on the file system" do
|
203
|
+
af = Services::AvailableFile.new(filename: 'the_file.zip')
|
204
|
+
af.id = 32
|
205
|
+
|
206
|
+
File.
|
207
|
+
should_receive(:exists?).
|
208
|
+
with(Rails.root.join("tmp", "available_file_32", "the_file.zip").to_s).
|
209
|
+
and_return(true)
|
210
|
+
|
211
|
+
expect(af.downloaded_file_exists?).to be_true
|
212
|
+
end
|
213
|
+
|
214
|
+
end
|
215
|
+
|
216
|
+
context '#valid_mds_file?' do
|
217
|
+
|
218
|
+
it "should delegate the valid mds test to the zip file guy" do
|
219
|
+
mock_zip = double("MdsFileUtils::ZipAnalyzer")
|
220
|
+
mock_zip.should_receive(:valid_zip?).and_return(false)
|
221
|
+
|
222
|
+
MdsFileUtils::ZipAnalyzer.should_receive(:new).with(Rails.root.join('tmp/available_file_32','the_file.zip').to_path).and_return(mock_zip)
|
223
|
+
|
224
|
+
af = Services::AvailableFile.new(filename: 'the_file.zip')
|
225
|
+
af.id = 32
|
226
|
+
|
227
|
+
expect(af.valid_mds_file?).to be_false
|
228
|
+
end
|
229
|
+
|
230
|
+
end
|
231
|
+
|
232
|
+
end
|
233
|
+
|
234
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Services::ConfiguredAccount do
|
4
|
+
|
5
|
+
context 'Scopes' do
|
6
|
+
|
7
|
+
before(:each) do
|
8
|
+
tp = Services::ThirdParty.create!(name: 'TheThirdParty',
|
9
|
+
contact_email: 'joe@msn.com')
|
10
|
+
svc = Services::Service.create!(name: 'TheService')
|
11
|
+
@sd = Services::ServiceDefinition.create!(third_party: tp,
|
12
|
+
service: svc,
|
13
|
+
hostname: 'localhost',
|
14
|
+
base_uri: 'https:/service.com',
|
15
|
+
username: 'providigm',
|
16
|
+
service_class: 'ServiceImpl')
|
17
|
+
end
|
18
|
+
|
19
|
+
it "should return only the enabled configured accounts" do
|
20
|
+
ca = Services::ConfiguredAccount.create!(service_definition: @sd,
|
21
|
+
account_id: 102,
|
22
|
+
username: 'sam',
|
23
|
+
enabled: true)
|
24
|
+
|
25
|
+
expect(Services::ConfiguredAccount.enabled).to eq([ ca ])
|
26
|
+
end
|
27
|
+
|
28
|
+
it "should return an empty association if no enabled accounts exist" do
|
29
|
+
ca = Services::ConfiguredAccount.create!(service_definition: @sd,
|
30
|
+
account_id: 102,
|
31
|
+
username: 'sam',
|
32
|
+
enabled: false)
|
33
|
+
|
34
|
+
expect(Services::ConfiguredAccount.enabled).to eq([ ])
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|