aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Gemfile1
-rw-r--r--Gemfile.lock2
-rw-r--r--app/models/import.rb1
-rw-r--r--spec/models/import_spec.rb20
4 files changed, 24 insertions, 0 deletions
diff --git a/Gemfile b/Gemfile
index f57a9d524..aeb776942 100644
--- a/Gemfile
+++ b/Gemfile
@@ -163,6 +163,7 @@ group :test do
gem 'simplecov', :require => false
gem 'simplecov-rcov', :require => false
gem 'htmlbeautifier'
+ gem 'timecop'
end
group :test, :development, :dev do
diff --git a/Gemfile.lock b/Gemfile.lock
index 2239cf853..d03a26d18 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -525,6 +525,7 @@ GEM
thread (0.2.2)
thread_safe (0.3.6)
tilt (1.4.1)
+ timecop (0.9.1)
transpec (3.3.0)
activesupport (>= 3.0, < 6.0)
astrolabe (~> 1.2)
@@ -669,6 +670,7 @@ DEPENDENCIES
squeel!
teaspoon-jasmine
therubyracer (~> 0.12)
+ timecop
transpec
uglifier (~> 2.7.2)
webmock
diff --git a/app/models/import.rb b/app/models/import.rb
index 731454e12..507b40f38 100644
--- a/app/models/import.rb
+++ b/app/models/import.rb
@@ -15,6 +15,7 @@ class Import < ActiveRecord::Base
def notify_parent
parent.child_change(self)
+ update(notified_parent_at: DateTime.now)
end
def child_change(child)
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