aboutsummaryrefslogtreecommitdiffstats
path: root/spec/models/import_spec.rb
diff options
context:
space:
mode:
authorTeddy Wing2017-08-01 23:19:37 +0200
committerTeddy Wing2017-08-01 23:22:15 +0200
commit7ed3bded976d7b3538fd49a36c6e3e79e6fc56e8 (patch)
tree1f6577ec5d2fc932fb6164ad7a3adbb059b9a689 /spec/models/import_spec.rb
parentc0aff43cbd6f4b5c4d131e577b3ad91679883d63 (diff)
downloadchouette-core-7ed3bded976d7b3538fd49a36c6e3e79e6fc56e8.tar.bz2
Import#notify_parent: Update :notified_parent_at
The `#notify_parent` method should update the `notified_parent_at` field on the child import so we know not to query it in subsequent batches of parent import notifications. Add the Timecop gem in order to be able to safely test the DateTime update. Refs #3511
Diffstat (limited to 'spec/models/import_spec.rb')
-rw-r--r--spec/models/import_spec.rb20
1 files changed, 20 insertions, 0 deletions
diff --git a/spec/models/import_spec.rb b/spec/models/import_spec.rb
index d99376a90..0a484f906 100644
--- a/spec/models/import_spec.rb
+++ b/spec/models/import_spec.rb
@@ -18,10 +18,30 @@ RSpec.describe Import, :type => :model do
parent: workbench_import
)
+ allow(netex_import).to receive(:update)
+
expect(workbench_import).to receive(:child_change).with(netex_import)
netex_import.notify_parent
end
+
+ it "must update the :notified_parent_at field of the child import" do
+ workbench_import = build_stubbed(:workbench_import)
+ netex_import = build_stubbed(
+ :netex_import,
+ parent: workbench_import
+ )
+
+ allow(workbench_import).to receive(:child_change)
+
+ Timecop.freeze(DateTime.now) do
+ expect(netex_import).to receive(:update).with(
+ notified_parent_at: DateTime.now
+ )
+
+ netex_import.notify_parent
+ end
+ end
end
describe "#child_change" do