aboutsummaryrefslogtreecommitdiffstats
path: root/spec
diff options
context:
space:
mode:
authorTeddy Wing2017-08-07 16:51:19 +0200
committerTeddy Wing2017-08-07 16:51:19 +0200
commit0b79907ea95a1f2fa9c8766474773f6555f49f37 (patch)
tree4a784c303e752060e56d7bb9085469bc1f35d9ef /spec
parent1d490afb5b616f15837259d093d458357f17a439 (diff)
downloadchouette-core-0b79907ea95a1f2fa9c8766474773f6555f49f37.tar.bz2
RoutesController: Add separate method for POST /duplicate
Send POST requests for duplication to a new controller method so we can more easily handle them and separate setup and creation code. Note that the test doesn't work. The `to change` part succeeds even though it shouldn't. Still need to figure out what's going on there, but committing this to hand off the feature to Robert. Refs #4189
Diffstat (limited to 'spec')
-rw-r--r--spec/controllers/routes_controller_spec.rb17
1 files changed, 17 insertions, 0 deletions
diff --git a/spec/controllers/routes_controller_spec.rb b/spec/controllers/routes_controller_spec.rb
index 5c17b78b8..3862d8173 100644
--- a/spec/controllers/routes_controller_spec.rb
+++ b/spec/controllers/routes_controller_spec.rb
@@ -85,4 +85,21 @@ RSpec.describe RoutesController, type: :controller do
expect(response).to be_success
end
end
+
+ describe "POST /duplicate" do
+ it "creates a new route" do
+ expect do
+ post :duplicate,
+ referential_id: route.line.line_referential_id,
+ line_id: route.line_id,
+ id: route.id,
+ params: {
+ name: '102 Route',
+ published_name: '102 route'
+ }
+ end.to change { Chouette::Route.count }.by(1)
+
+ expect(Chouette::Route.last.name).to eq('102 Route')
+ end
+ end
end