diff options
| author | Teddy Wing | 2017-10-30 14:59:04 +0100 |
|---|---|---|
| committer | Teddy Wing | 2017-10-30 17:48:58 +0100 |
| commit | 17dcf8fe67972f6287fdac40a4477ef8b63ae1b9 (patch) | |
| tree | 4815308c04760ccca87bf3e1104af8bf039a674c | |
| parent | 48a0641066d1b7c534b45e36c921e4b2a708138a (diff) | |
| download | chouette-core-17dcf8fe67972f6287fdac40a4477ef8b63ae1b9.tar.bz2 | |
ComplianceControlSetCopyWorker: Call Java validation API
Call the Java API URL to launch a validation after having copied the
`ComplianceControlSet` into a `ComplianceCheckSet`.
Copied the format with error logging from
`NetexImport#launch_java_import`.
In the test, make the ID variables global by putting them in `let`s.
Add `config.iev_url` to the Rails `test` environment so that we can
access this from our tests.
TODO: I just realised I'm sending the wrong ID. I should be sending the
check set ID.
Refs #4782
| -rw-r--r-- | app/workers/compliance_control_set_copy_worker.rb | 7 | ||||
| -rw-r--r-- | config/environments/test.rb | 3 | ||||
| -rw-r--r-- | spec/workers/compliance_control_set_copy_worker_spec.rb | 21 |
3 files changed, 28 insertions, 3 deletions
diff --git a/app/workers/compliance_control_set_copy_worker.rb b/app/workers/compliance_control_set_copy_worker.rb index ec47651ea..92ec5b903 100644 --- a/app/workers/compliance_control_set_copy_worker.rb +++ b/app/workers/compliance_control_set_copy_worker.rb @@ -3,5 +3,12 @@ class ComplianceControlSetCopyWorker def perform(control_set_id, referential_id) ComplianceControlSetCopier.new.copy(control_set_id, referential_id) + + begin + Net::HTTP.get(URI("#{Rails.configuration.iev_url}/boiv_iev/referentials/validator/new?id=#{control_set_id}")) + rescue Exception => e + logger.error "IEV server error : #{e.message}" + logger.error e.backtrace.inspect + end end end diff --git a/config/environments/test.rb b/config/environments/test.rb index b3312be4a..8bf94f5da 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -62,6 +62,9 @@ Rails.application.configure do # Reflex api url config.reflex_api_url = "https://195.46.215.128/ws/reflex/V1/service=getData" + # IEV url + config.iev_url = ENV.fetch('IEV_URL', 'http://localhost:8080') + config.rails_host = "http://www.example.com" # file to data for demo config.demo_data = "tmp/demo.zip" diff --git a/spec/workers/compliance_control_set_copy_worker_spec.rb b/spec/workers/compliance_control_set_copy_worker_spec.rb index 69161200c..fcd1918c7 100644 --- a/spec/workers/compliance_control_set_copy_worker_spec.rb +++ b/spec/workers/compliance_control_set_copy_worker_spec.rb @@ -1,12 +1,27 @@ RSpec.describe ComplianceControlSetCopyWorker do - it "calls ComplianceControlSetCopier" do - control_set_id = 55 - referential_id = 99 + let(:control_set_id) { 55 } + let(:referential_id) { 99 } + + before(:each) do + allow_any_instance_of(ComplianceControlSetCopier).to receive(:copy) + end + it "calls ComplianceControlSetCopier" do expect_any_instance_of( ComplianceControlSetCopier ).to receive(:copy).with(control_set_id, referential_id) ComplianceControlSetCopyWorker.new.perform(control_set_id, referential_id) end + + it "calls the Java API to launch validation" do + validation_request = stub_request( + :get, + "#{Rails.configuration.iev_url}/boiv_iev/referentials/validator/new?id=#{control_set_id}" + ) + + ComplianceControlSetCopyWorker.new.perform(control_set_id, referential_id) + + expect(validation_request).to have_been_requested + end end |
