diff options
| author | Luc Donnet | 2017-09-13 16:56:23 +0200 |
|---|---|---|
| committer | Luc Donnet | 2017-09-13 16:56:23 +0200 |
| commit | 3b7bbba3ce2f0a532ac7a8e7d1116e563526f112 (patch) | |
| tree | b49075ec37573ca7174794e3db6b7da12d92d583 /spec/controllers/routes_controller_spec.rb | |
| parent | 5ee3a180de710d23ceb7660b1bcc454701b42d87 (diff) | |
| parent | 4804a4886c5267c1be1c367caaf35c17c681d179 (diff) | |
| download | chouette-core-3b7bbba3ce2f0a532ac7a8e7d1116e563526f112.tar.bz2 | |
Merge branch 'master' of github.com:AF83/stif-boiv
Diffstat (limited to 'spec/controllers/routes_controller_spec.rb')
| -rw-r--r-- | spec/controllers/routes_controller_spec.rb | 51 |
1 files changed, 33 insertions, 18 deletions
diff --git a/spec/controllers/routes_controller_spec.rb b/spec/controllers/routes_controller_spec.rb index 000b799db..336f20945 100644 --- a/spec/controllers/routes_controller_spec.rb +++ b/spec/controllers/routes_controller_spec.rb @@ -1,7 +1,9 @@ -RSpec.describe RoutesController, :type => :controller do +Route = Chouette::Route + +RSpec.describe RoutesController, type: :controller do login_user - let!(:route) { create(:route) } + let(:route) { create(:route) } it { is_expected.to be_kind_of(ChouetteController) } @@ -10,6 +12,7 @@ RSpec.describe RoutesController, :type => :controller do # expect(response).to redirect_to( referential_line_path(referential,route.line) ) end end + shared_examples_for "line and referential linked" do it "assigns route.line as @line" do expect(assigns[:line]).to eq(route.line) @@ -19,6 +22,7 @@ RSpec.describe RoutesController, :type => :controller do expect(assigns[:referential]).to eq(referential) end end + shared_examples_for "route, line and referential linked" do it "assigns route as @route" do expect(assigns[:route]).to eq(route) @@ -28,8 +32,8 @@ RSpec.describe RoutesController, :type => :controller do describe "GET /index" do before(:each) do - get :index, :line_id => route.line_id, - :referential_id => referential.id + get :index, line_id: route.line_id, + referential_id: referential.id end it_behaves_like "line and referential linked" @@ -38,9 +42,9 @@ RSpec.describe RoutesController, :type => :controller do describe "POST /create" do before(:each) do - post :create, :line_id => route.line_id, - :referential_id => referential.id, - :route => { :name => "changed"} + post :create, line_id: route.line_id, + referential_id: referential.id, + route: { name: "changed"} end it_behaves_like "line and referential linked" @@ -49,9 +53,9 @@ RSpec.describe RoutesController, :type => :controller do describe "PUT /update" do before(:each) do - put :update, :id => route.id, :line_id => route.line_id, - :referential_id => referential.id, - :route => route.attributes + put :update, id: route.id, line_id: route.line_id, + referential_id: referential.id, + route: route.attributes end it_behaves_like "route, line and referential linked" @@ -60,9 +64,9 @@ RSpec.describe RoutesController, :type => :controller do describe "GET /show" do before(:each) do - get :show, :id => route.id, - :line_id => route.line_id, - :referential_id => referential.id + get :show, id: route.id, + line_id: route.line_id, + referential_id: referential.id end it_behaves_like "route, line and referential linked" @@ -71,11 +75,22 @@ RSpec.describe RoutesController, :type => :controller do expect(assigns[:map]).to be_an_instance_of(RouteMap) expect(assigns[:map].route).to eq(route) end - - #it "assigns route.stop_points.paginate(:page => nil) as @stop_points" do - # expect(assigns[:stop_points]).to eq(route.stop_points.paginate(:page => nil)) - #end end -end + describe "POST /duplicate" do + let!( :route_prime ){ route } + + 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 + end.to change { Route.count }.by(1) + + expect(Route.last.name).to eq(route.name) + expect(Route.last.published_name).to eq(route.published_name) + end + end +end |
