diff options
| author | Teddy Wing | 2018-04-16 17:41:09 +0200 | 
|---|---|---|
| committer | Teddy Wing | 2018-04-16 17:46:36 +0200 | 
| commit | 220e839fddec44c9a1e73fb5e7cd7f701faf726d (patch) | |
| tree | 55a761fa34198ac1217753c798860e2f3d7c55e7 /app/models/chouette/route.rb | |
| parent | 85bea8da4f994496b636e2a79dae2f269acbd501 (diff) | |
| download | chouette-core-220e839fddec44c9a1e73fb5e7cd7f701faf726d.tar.bz2 | |
Route: Don't run `#calculate_costs!` during a referential merge6410-route--don,t-run-calculate_costs-during-referential-mer
This callback got triggered during a referential merge, but it isn't
needed at that point. It should only be executed as a result of a user
updating the route (via the web interface).
Using Alban's suggestion, we can detect that we're in the process of a
merge if the associated referential is in a `ReferentialSuite`. Use this
as a condition to run the callback.
Refs #6410
Diffstat (limited to 'app/models/chouette/route.rb')
| -rw-r--r-- | app/models/chouette/route.rb | 6 | 
1 files changed, 5 insertions, 1 deletions
| diff --git a/app/models/chouette/route.rb b/app/models/chouette/route.rb index c5e909d7e..a5eab3002 100644 --- a/app/models/chouette/route.rb +++ b/app/models/chouette/route.rb @@ -80,7 +80,11 @@ module Chouette      validates :wayback, inclusion: { in: self.wayback.values }      after_commit :calculate_costs!,        on: [:create, :update], -      if: ->() { TomTom.enabled? } +      if: ->() { +        # Ensure the call back doesn't run during a referential merge +        !referential.in_referential_suite? && +          TomTom.enabled? +      }      def duplicate opposite=false        overrides = { | 
