diff options
| author | Zog | 2018-04-11 08:43:42 +0200 | 
|---|---|---|
| committer | Zog | 2018-04-11 08:43:42 +0200 | 
| commit | ce85f5ff1ba2336b144d059343786f7aec0575f3 (patch) | |
| tree | 05e312065cd9a1db3dd9efa746d615be91ae47ea | |
| parent | de9e2a11af7aac5521bdc6a404d1e873a03f8adc (diff) | |
| download | chouette-core-ce85f5ff1ba2336b144d059343786f7aec0575f3.tar.bz2 | |
Add a sentinel in dev mode to help capture the "double positions" bug
| -rw-r--r-- | app/models/chouette/route.rb | 11 | 
1 files changed, 10 insertions, 1 deletions
| diff --git a/app/models/chouette/route.rb b/app/models/chouette/route.rb index 9c7a3e6d9..14bfa47b6 100644 --- a/app/models/chouette/route.rb +++ b/app/models/chouette/route.rb @@ -7,6 +7,15 @@ module Chouette      include ObjectidSupport      extend Enumerize +    if Rails.env.development? +      after_commit do +        positions = stop_points.pluck(:position) +        if positions.size != positions.uniq.size +          raise "DUPLICATED stop_points positions: #{positions}" +        end +      end +    end +      enumerize :direction, in: %i(straight_forward backward clockwise counter_clockwise north north_west west south_west south south_east east north_east)      enumerize :wayback, in: %i(outbound inbound), default: :outbound @@ -69,7 +78,7 @@ module Chouette      validates_presence_of :line      validates :wayback, inclusion: { in: self.wayback.values }      after_save :calculate_costs!, if: ->() { TomTom.enabled? } -     +      def duplicate opposite=false        overrides = {          'opposite_route_id' => nil, | 
