diff options
| author | Teddy Wing | 2017-09-08 14:25:58 +0200 |
|---|---|---|
| committer | Teddy Wing | 2017-09-11 12:49:45 +0200 |
| commit | 70215298fcb592e52b0f3033a939a594f511e379 (patch) | |
| tree | ed28fa484b6816fc7643257126c88d653a68213b /spec/models/import_spec.rb | |
| parent | 1b2976d7a63cc140304bd94b88b5ddc93e0aceb0 (diff) | |
| download | chouette-core-70215298fcb592e52b0f3033a939a594f511e379.tar.bz2 | |
Import specs: Add tests to verify dependent-destroy of associations
When an import is destroyed, all:
* child imports
* associated `ImportReference`s
* associated `ImportMessage`s
must be destroyed. This is handled by a `dependent: :destory` on the
associations.
Here we add tests to validate that the records get properly destroyed.
Refs #4412
Diffstat (limited to 'spec/models/import_spec.rb')
| -rw-r--r-- | spec/models/import_spec.rb | 35 |
1 files changed, 29 insertions, 6 deletions
diff --git a/spec/models/import_spec.rb b/spec/models/import_spec.rb index 477d269e0..cd5a30982 100644 --- a/spec/models/import_spec.rb +++ b/spec/models/import_spec.rb @@ -26,12 +26,35 @@ RSpec.describe Import, type: :model do ) end - # describe "#destroy" do - # it "must call #destroy on imports children and then import_messages, import_resources linked" do - # TODO - # - # end - # end + describe "#destroy" do + it "must destroy all child imports" do + workbench_import = create(:workbench_import) + create(:netex_import, parent: workbench_import) + + workbench_import.destroy + + expect(workbench_import).to be_destroyed + expect(NetexImport.count).to eq(0) + end + + it "must destroy all associated ImportMessages" do + import = create(:import) + create(:import_resource, import: import) + + import.destroy + + expect(ImportResource.count).to eq(0) + end + + it "must destroy all associated ImportResources" do + import = create(:import) + create(:import_message, import: import) + + import.destroy + + expect(ImportMessage.count).to eq(0) + end + end describe "#notify_parent" do it "must call #child_change on its parent" do |
