diff options
| author | Teddy Wing | 2017-08-01 19:28:55 +0200 |
|---|---|---|
| committer | Teddy Wing | 2017-08-01 19:30:23 +0200 |
| commit | 240c2270ca8e21c75170d6b7764562c049ef661a (patch) | |
| tree | ae471688195b76f7791f322f8d72fe593dbcd969 | |
| parent | aee3eb9f6533e88c817ffde7299b1d22544a8077 (diff) | |
| download | chouette-core-240c2270ca8e21c75170d6b7764562c049ef661a.tar.bz2 | |
Import#notify_parent: Call #child_change on parent import
Calling `#notify_parent` should call the `#child_change` method on the
import's parent import. That `#child_change` method will tell the parent
to update itself based on the status of the child.
Refs #3511
| -rw-r--r-- | app/models/import.rb | 4 | ||||
| -rw-r--r-- | spec/models/import_spec.rb | 14 |
2 files changed, 18 insertions, 0 deletions
diff --git a/app/models/import.rb b/app/models/import.rb index 20b61a7f5..3cbdb964f 100644 --- a/app/models/import.rb +++ b/app/models/import.rb @@ -14,6 +14,10 @@ class Import < ActiveRecord::Base before_create :initialize_fields def notify_parent + parent.child_change(self) + end + + def child_change(child) end private diff --git a/spec/models/import_spec.rb b/spec/models/import_spec.rb index 88d339ea0..53513eb0c 100644 --- a/spec/models/import_spec.rb +++ b/spec/models/import_spec.rb @@ -9,4 +9,18 @@ RSpec.describe Import, :type => :model do it { should validate_presence_of(:file) } it { should validate_presence_of(:referential) } it { should validate_presence_of(:workbench) } + + describe "#notify_parent" do + it "must call #child_change on its parent" do + workbench_import = build_stubbed(:workbench_import) + netex_import = build_stubbed( + :netex_import, + parent: workbench_import + ) + + expect(workbench_import).to receive(:child_change).with(netex_import) + + netex_import.notify_parent + end + end end |
