From 17dcf8fe67972f6287fdac40a4477ef8b63ae1b9 Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Mon, 30 Oct 2017 14:59:04 +0100 Subject: 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 --- .../compliance_control_set_copy_worker_spec.rb | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) (limited to 'spec/workers') 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 -- cgit v1.2.3