diff options
| author | Teddy Wing | 2017-11-13 18:27:48 +0100 | 
|---|---|---|
| committer | Teddy Wing | 2017-11-13 18:27:48 +0100 | 
| commit | 51a0898506e9c6bcc379ed8db01d3f14a1dbe110 (patch) | |
| tree | 27351c2fec102efec73daff5b320ad4661f23d97 /app/models/netex_import.rb | |
| parent | 336dab9900aee831e73113e400609ec2ebd40c20 (diff) | |
| download | chouette-core-51a0898506e9c6bcc379ed8db01d3f14a1dbe110.tar.bz2 | |
NetexImport: Destroy referential on destroy if ready:false
If the `NetexImport`'s associated `Referential` has `ready: false`, when
the `NetexImport` is destroyed, also destroy the `Referential`.
This prevents a case where users get an invalid `Referential` as a
result of an import, but because of the `ready: false`, it doesn't
display on the website, so they can't see what the problem is.
Refs #4962
Diffstat (limited to 'app/models/netex_import.rb')
| -rw-r--r-- | app/models/netex_import.rb | 9 | 
1 files changed, 9 insertions, 0 deletions
diff --git a/app/models/netex_import.rb b/app/models/netex_import.rb index 32939a741..3d8ab3809 100644 --- a/app/models/netex_import.rb +++ b/app/models/netex_import.rb @@ -1,6 +1,7 @@  require 'net/http'  class NetexImport < Import    after_commit :launch_java_import, on: :create +  before_destroy :destroy_non_ready_referential    validates_presence_of :parent @@ -16,4 +17,12 @@ class NetexImport < Import        end      end    end + +  private + +  def destroy_non_ready_referential +    if !referential.ready +      referential.destroy +    end +  end  end  | 
