aboutsummaryrefslogtreecommitdiffstats
path: root/spec
diff options
context:
space:
mode:
authorAlban Peignier2018-04-16 16:37:59 +0200
committerGitHub2018-04-16 16:37:59 +0200
commit85bea8da4f994496b636e2a79dae2f269acbd501 (patch)
treebaa7aaea6677e1e8660a721d2057c31466e78984 /spec
parentcdd19438366641ef5069929982030c10018ec00f (diff)
parenteb27950dcf348784dfd0519a92181e11a5c29645 (diff)
downloadchouette-core-85bea8da4f994496b636e2a79dae2f269acbd501.tar.bz2
Merge pull request #486 from af83/6179-update-acts_as_list
Update acts_as_list. Refs #6179
Diffstat (limited to 'spec')
-rw-r--r--spec/models/route_spec.rb35
1 files changed, 35 insertions, 0 deletions
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