From 7220c54b4ec097bd5d7292cb0b7a068ddb726a7c Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Wed, 30 Aug 2017 18:23:29 +0200 Subject: Import spec: Add test for 'failed' with comination of child statuses When any one of a parent import's children have failed, the parent import should get status 'failed'. --- spec/models/import_spec.rb | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'spec/models/import_spec.rb') diff --git a/spec/models/import_spec.rb b/spec/models/import_spec.rb index 22bbfab09..2a0c7539e 100644 --- a/spec/models/import_spec.rb +++ b/spec/models/import_spec.rb @@ -109,6 +109,24 @@ RSpec.describe Import, type: :model do expect(workbench_import.status).to eq('successful') end + it "Updates :status to failed when any child has failed" do + workbench_import = create(:workbench_import) + [ + 'failed', + 'successful' + ].each do |status| + create( + :netex_import, + parent: workbench_import, + status: status + ) + end + + workbench_import.update_status + + expect(workbench_import.status).to eq('failed') + end + it "updates :ended_at to now when status is finished" do skip "Redo the `#update_status` code to make it easier to write this." end -- cgit v1.2.3