aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlban Peignier2018-03-20 23:00:41 +0100
committerLuc Donnet2018-03-23 17:21:56 +0100
commit89b7b87b24308d88848bfccc451a4d6f043c04f7 (patch)
tree895c8fe9a975aa5f8fc2b079488fcb70e668617f
parentc427aa354acacb7fc31b90a437af5babec99b93b (diff)
downloadchouette-core-89b7b87b24308d88848bfccc451a4d6f043c04f7.tar.bz2
Don't use Import::Base#status_changed? into #notify_parent (status can be changed by java side). Refs #6243
-rw-r--r--app/models/concerns/iev_interfaces/task.rb7
-rw-r--r--spec/models/export/base_spec.rb4
-rw-r--r--spec/models/import/import_spec.rb4
3 files changed, 7 insertions, 8 deletions
diff --git a/app/models/concerns/iev_interfaces/task.rb b/app/models/concerns/iev_interfaces/task.rb
index fdd976f39..c5abc5afb 100644
--- a/app/models/concerns/iev_interfaces/task.rb
+++ b/app/models/concerns/iev_interfaces/task.rb
@@ -53,11 +53,10 @@ module IevInterfaces::Task
def notify_parent
return unless parent.present?
- return unless status_changed?
+ return if notified_parent_at
parent.child_change
- t = Time.now
- self.notified_parent_at = t
- self.class.where(id: self.id).update_all notified_parent_at: t
+
+ update_column :notified_parent_at, Time.now
end
def children_succeedeed
diff --git a/spec/models/export/base_spec.rb b/spec/models/export/base_spec.rb
index edc0788f2..da52fa1f3 100644
--- a/spec/models/export/base_spec.rb
+++ b/spec/models/export/base_spec.rb
@@ -114,7 +114,7 @@ RSpec.describe Export::Base, type: :model do
allow(netex_export).to receive(:update)
expect(workgroup_export).to receive(:child_change)
- netex_export.status = :foo
+ netex_export.notified_parent_at = nil
netex_export.notify_parent
end
@@ -122,7 +122,7 @@ RSpec.describe Export::Base, type: :model do
allow(workgroup_export).to receive(:child_change)
Timecop.freeze(Time.now) do
- netex_export.status = :bar
+ netex_export.notified_parent_at = nil
netex_export.notify_parent
expect(netex_export.notified_parent_at.strftime('%Y-%m-%d %H:%M:%S.%3N')).to eq Time.now.strftime('%Y-%m-%d %H:%M:%S.%3N')
diff --git a/spec/models/import/import_spec.rb b/spec/models/import/import_spec.rb
index 102c0e1d6..ab8fcc9c0 100644
--- a/spec/models/import/import_spec.rb
+++ b/spec/models/import/import_spec.rb
@@ -115,14 +115,14 @@ RSpec.describe Import::Base, type: :model do
allow(netex_import).to receive(:update)
expect(workbench_import).to receive(:child_change)
- netex_import.status = :foo
+ netex_import.notified_parent_at = nil
netex_import.notify_parent
end
it "must update the :notified_parent_at field of the child import" do
allow(workbench_import).to receive(:child_change)
Timecop.freeze(Time.now) do
- netex_import.status = :bar
+ netex_import.notified_parent_at = nil
netex_import.notify_parent
expect(netex_import.notified_parent_at.strftime('%Y-%m-%d %H:%M:%S.%3N')).to eq Time.now.strftime('%Y-%m-%d %H:%M:%S.%3N')