aboutsummaryrefslogtreecommitdiffstats
path: root/spec/controllers
diff options
context:
space:
mode:
authorTeddy Wing2017-08-07 16:51:19 +0200
committerRobert2017-08-11 10:03:46 +0200
commit51b73758486294862c47707d9b85e7cefeb0242a (patch)
treec1882cd76952f0da5f0851431f2d703cd35773d5 /spec/controllers
parent8cea700c7ebc1e9daf8eda4b35e9d9c28e46249c (diff)
downloadchouette-core-51b73758486294862c47707d9b85e7cefeb0242a.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/controllers')
-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