diff options
| author | teddywing | 2018-04-11 12:39:30 +0200 | 
|---|---|---|
| committer | GitHub | 2018-04-11 12:39:30 +0200 | 
| commit | 3488bd48b98b77bf31a0f254a8059f04e450440f (patch) | |
| tree | a0c083501e3b182a2e7eade6780d4af8e8b5aedc | |
| parent | 2d1ebb630ecfdd7b745571202ee60a35902b545f (diff) | |
| parent | ce85f5ff1ba2336b144d059343786f7aec0575f3 (diff) | |
| download | chouette-core-3488bd48b98b77bf31a0f254a8059f04e450440f.tar.bz2 | |
Merge pull request #467 from af83/fix-duplicate-positions-in-routes
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, | 
