aboutsummaryrefslogtreecommitdiffstats
path: root/spec/controllers/routes_controller_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/controllers/routes_controller_spec.rb')
-rw-r--r--spec/controllers/routes_controller_spec.rb51
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