aboutsummaryrefslogtreecommitdiffstats
path: root/spec
diff options
context:
space:
mode:
authorTeddy Wing2018-04-16 17:41:09 +0200
committerTeddy Wing2018-04-16 17:46:36 +0200
commit220e839fddec44c9a1e73fb5e7cd7f701faf726d (patch)
tree55a761fa34198ac1217753c798860e2f3d7c55e7 /spec
parent85bea8da4f994496b636e2a79dae2f269acbd501 (diff)
downloadchouette-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 'spec')
-rw-r--r--spec/models/chouette/route/route_base_spec.rb19
1 files changed, 19 insertions, 0 deletions
diff --git a/spec/models/chouette/route/route_base_spec.rb b/spec/models/chouette/route/route_base_spec.rb
index 43ff28c40..e76f10a13 100644
--- a/spec/models/chouette/route/route_base_spec.rb
+++ b/spec/models/chouette/route/route_base_spec.rb
@@ -77,5 +77,24 @@ RSpec.describe Chouette::Route, :type => :model do
expect(route).not_to receive(:calculate_costs!)
route.save
end
+
+ it "doesn't call #calculate_costs! after_commit if in a ReferentialSuite",
+ truncation: true do
+ begin
+ allow(TomTom).to receive(:enabled?).and_return(true)
+
+ referential_suite = create(:referential_suite)
+ referential = create(:referential, referential_suite: referential_suite)
+
+ referential.switch do
+ route = build(:route)
+
+ expect(route).not_to receive(:calculate_costs!)
+ route.save
+ end
+ ensure
+ referential.destroy
+ end
+ end
end
end