aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZog2018-04-16 14:49:15 +0200
committerZog2018-04-16 14:49:15 +0200
commiteb27950dcf348784dfd0519a92181e11a5c29645 (patch)
tree105eaff54724cbc375fff80a029c64c1cea80d46
parentcf63f8f32ecaa6f1bccc70a68e4c6d4d8794373b (diff)
downloadchouette-core-eb27950dcf348784dfd0519a92181e11a5c29645.tar.bz2
Refs #6179; Update acts_as_list6179-update-acts_as_list
And (hopefully) fix bugs on routes having duplicated positions
-rw-r--r--Gemfile2
-rw-r--r--Gemfile.lock4
-rw-r--r--spec/models/route_spec.rb35
3 files changed, 38 insertions, 3 deletions
diff --git a/Gemfile b/Gemfile
index cca55be61..95f366fc1 100644
--- a/Gemfile
+++ b/Gemfile
@@ -125,7 +125,7 @@ gem 'enumerize', '~> 2.1.2'
gem 'deep_cloneable', '~> 2.0.0'
gem 'acts-as-taggable-on', '~> 4.0.0'
-gem 'acts_as_list', '~> 0.6.0'
+gem 'acts_as_list', '~> 0.9.11'
gem 'acts_as_tree', '~> 2.1.0', require: 'acts_as_tree'
gem 'rabl'
diff --git a/Gemfile.lock b/Gemfile.lock
index 4fb77eeb9..2071eee78 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -86,7 +86,7 @@ GEM
tzinfo (~> 1.1)
acts-as-taggable-on (4.0.0)
activerecord (>= 4.0)
- acts_as_list (0.6.0)
+ acts_as_list (0.9.11)
activerecord (>= 3.0)
acts_as_tree (2.1.0)
activerecord (>= 3.0.0)
@@ -593,7 +593,7 @@ DEPENDENCIES
active_attr
activerecord-postgis-adapter (~> 3.0.0)
acts-as-taggable-on (~> 4.0.0)
- acts_as_list (~> 0.6.0)
+ acts_as_list (~> 0.9.11)
acts_as_tree (~> 2.1.0)
apartment (~> 1.0.0)
awesome_print
diff --git a/spec/models/route_spec.rb b/spec/models/route_spec.rb
index b407cd866..58524038b 100644
--- a/spec/models/route_spec.rb
+++ b/spec/models/route_spec.rb
@@ -65,4 +65,39 @@ RSpec.describe Chouette::Route, :type => :model do
end
end
end
+
+ context "when creating stop_points" do
+ # Here we tests that acts_as_list does not mess with the positions
+ let(:stop_areas){
+ 4.times.map{create :stop_area}
+ }
+
+ it "should set a correct order to the stop_points" do
+
+ order = [0, 3, 2, 1]
+ new = Referential.new
+ new.name = "mkmkm"
+ new.organisation = create(:organisation)
+ new.line_referential = create(:line_referential)
+ create(:line, line_referential: new.line_referential)
+ new.stop_area_referential = create(:stop_area_referential)
+ new.objectid_format = :netex
+ new.save!
+ new.switch
+ route = new.routes.new
+
+ route.published_name = route.name = "Route"
+ route.line = new.line_referential.lines.last
+ order.each_with_index do |position, i|
+ _attributes = {
+ stop_area: stop_areas[i],
+ position: position
+ }
+ route.stop_points.build _attributes
+ end
+ route.save
+ expect(route).to be_valid
+ expect{route.run_callbacks(:commit)}.to_not raise_error
+ end
+ end
end