diff options
| author | Marc Florisson | 2012-05-16 22:54:23 +0200 |
|---|---|---|
| committer | Marc Florisson | 2012-05-16 22:54:23 +0200 |
| commit | 9485e4ddc7afc5c481b066dfc8bb315f296d0023 (patch) | |
| tree | 72700680784e3acb49a0450098ea73b3d6ef461b /spec | |
| parent | 7bcb93aff46042a8fd229f6c78b3e8bbb4431f5c (diff) | |
| download | chouette-core-9485e4ddc7afc5c481b066dfc8bb315f296d0023.tar.bz2 | |
add some spec on route and stop_points
Diffstat (limited to 'spec')
| -rw-r--r-- | spec/controllers/stop_points_controller_spec.rb | 9 | ||||
| -rw-r--r-- | spec/requests/routes_spec.rb | 56 | ||||
| -rw-r--r-- | spec/requests/stop_points_spec.rb | 29 |
3 files changed, 93 insertions, 1 deletions
diff --git a/spec/controllers/stop_points_controller_spec.rb b/spec/controllers/stop_points_controller_spec.rb index 20ed1170e..b6c9e5dfa 100644 --- a/spec/controllers/stop_points_controller_spec.rb +++ b/spec/controllers/stop_points_controller_spec.rb @@ -12,6 +12,11 @@ describe StopPointsController do it { should be_kind_of(ChouetteController) } + shared_examples_for "redirected to referential_line_stop_points_path(referential,line,route)" do + it "should redirect_to referential_line_route_stop_points_path(referential,line,route)" do + response.should redirect_to( referential_line_route_stop_points_path(referential,route.line,route) ) + end + end shared_examples_for "route, line and referential linked (stop_points)" do it "assigns route as @route" do assigns[:route].should == route @@ -44,12 +49,13 @@ describe StopPointsController do :stop_point => permutated_stop_point_ids end it_behaves_like "route, line and referential linked (stop_points)" + it_behaves_like "redirected to referential_line_stop_points_path(referential,line,route)" end describe "#sort" do it "should delegate to route.sort! with permutated_stop_point_ids" do controller.stub!(:route => route, :params => { :stop_point => permutated_stop_point_ids}) - controller.stub!(:respond_to => nil) + controller.stub!(:redirect_to => nil) route.should_receive(:reorder!).with(permutated_stop_point_ids) controller.sort end @@ -71,5 +77,6 @@ describe StopPointsController do end it_behaves_like "route, line and referential linked (stop_points)" + it_behaves_like "redirected to referential_line_stop_points_path(referential,line,route)" end end diff --git a/spec/requests/routes_spec.rb b/spec/requests/routes_spec.rb new file mode 100644 index 000000000..e94d4cc53 --- /dev/null +++ b/spec/requests/routes_spec.rb @@ -0,0 +1,56 @@ +# -*- coding: utf-8 -*- +require 'spec_helper' + +describe "Routes" do + login_user + + let!(:referential) { create(:referential).switch } + let!(:line) { referential; Factory(:line) } + let!(:route) { referential; Factory(:route, :line => line) } + let!(:route2) { referential; Factory(:route, :line => line) } + + describe "from lines page to a line page" do + it "display line's routes" do + visit referential_lines_path(referential) + click_link "#{line.name}" + page.should have_content(route.name) + page.should have_content(route2.name) + end + end + describe "from line's page to route's page" do + it "display route properties" do + visit referential_line_path(referential,line) + click_link "#{route.name}" + page.should have_content(route.name) + page.should have_content(route.number) + end + end + describe "from line's page, create a new route" do + it "return to line's page that display new route" do + visit referential_line_path(referential,line) + click_link "Ajouter une séquence d'arrêts" + fill_in "Nom", :with => "A to B" + fill_in "Indice", :with => "AB" + click_button("Créer Séquence d'arrêts") + page.should have_content("A to B") + end + end + describe "from line's page, select a route and edit it" do + it "return to line's page with changed name" do + visit referential_line_path(referential,line) + click_link "#{route.name}" + click_link "Modifier cette séquence d'arrêts" + fill_in "Nom", :with => "#{route.name}-changed" + click_button("Modifier Séquence d'arrêts") + page.should have_content("#{route.name}-changed") + end + end + describe "from line's page, select a route and delete it" do + it "return to line's page without route name" do + visit referential_line_path(referential,line) + click_link "#{route.name}" + #click_link "Supprimer cette séquence d'arrêts" + #page.should_not have_content(route.name) + end + end +end diff --git a/spec/requests/stop_points_spec.rb b/spec/requests/stop_points_spec.rb new file mode 100644 index 000000000..2c968a905 --- /dev/null +++ b/spec/requests/stop_points_spec.rb @@ -0,0 +1,29 @@ +# -*- coding: utf-8 -*- +require 'spec_helper' + +describe "StopPoints" do + login_user + + let!(:referential) { create(:referential).switch } + let!(:line) { referential; Factory(:line) } + let!(:route) { referential; Factory(:route, :line => line) } + let!(:route2) { referential; Factory(:route, :line => line) } + + describe "from route's page to a stop points page" do + it "display route's stop points" do + visit referential_line_route_path(referential,line,route) + click_link "Réordonner les arrêts de la séquence" + route.stop_areas.each do |sa| + page.should have_content(sa.name) + end + end + end + describe "from route's page, go to new stop point page" do + it "display route's stop points" do + visit referential_line_route_path(referential,line,route) + click_link "Réordonner les arrêts de la séquence" + click_link "Ajouter un arrêt à la séquence" + page.should have_content( "Sélectionner un arrêt") + end + end +end |
