aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTeddy Wing2018-02-05 16:54:01 +0100
committerTeddy Wing2018-02-06 10:50:51 +0100
commit2e346505cbf2f82c5aaf6fca37966a39b6c9656c (patch)
tree56e6b1be71d80694a14c9181c4e0c703def2f97a
parentbe1e4ce05348e722e52c2e68f5b1c1514caa00dd (diff)
downloadchouette-core-2e346505cbf2f82c5aaf6fca37966a39b6c9656c.tar.bz2
imports.rake: Change `abort_old` to `netex_abort_old`
After re-reading the ticket, I see now that the aborting of old imports should only apply to `NetexImport`s. Update the code to make this happen. Refs #4963
-rw-r--r--config/schedule.rb2
-rw-r--r--lib/tasks/imports.rake6
-rw-r--r--spec/models/import_spec.rb20
3 files changed, 24 insertions, 4 deletions
diff --git a/config/schedule.rb b/config/schedule.rb
index 636ab654e..40ee8e4ac 100644
--- a/config/schedule.rb
+++ b/config/schedule.rb
@@ -40,7 +40,7 @@ every :day, :at => '4:00 am' do
end
every 5.minutes do
- rake "import:abort_old"
+ rake "import:netex_abort_old"
rake "import:notify_parent"
end
diff --git a/lib/tasks/imports.rake b/lib/tasks/imports.rake
index fee850b23..9d0fc8726 100644
--- a/lib/tasks/imports.rake
+++ b/lib/tasks/imports.rake
@@ -4,8 +4,8 @@ namespace :import do
ParentImportNotifier.notify_when_finished
end
- desc "Mark old unfinished imports as 'aborted'"
- task abort_old: :environment do
- Import.abort_old
+ desc "Mark old unfinished Netex imports as 'aborted'"
+ task netex_abort_old: :environment do
+ NetexImport.abort_old
end
end
diff --git a/spec/models/import_spec.rb b/spec/models/import_spec.rb
index aedcfe4ab..8b85f151b 100644
--- a/spec/models/import_spec.rb
+++ b/spec/models/import_spec.rb
@@ -59,6 +59,26 @@ RSpec.describe Import, type: :model do
expect(import.reload.status).to eq('successful')
end
end
+
+ it "only works on the caller type" do
+ Timecop.freeze(Time.now) do
+ workbench_import = create(
+ :workbench_import,
+ status: 'pending',
+ created_at: 4.hours.ago - 1.minute
+ )
+ netex_import = create(
+ :netex_import,
+ status: 'pending',
+ created_at: 4.hours.ago - 1.minute
+ )
+
+ NetexImport.abort_old
+
+ expect(workbench_import.reload.status).to eq('pending')
+ expect(netex_import.reload.status).to eq('aborted')
+ end
+ end
end
describe "#destroy" do