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 | |
| parent | 7bcb93aff46042a8fd229f6c78b3e8bbb4431f5c (diff) | |
| download | chouette-core-9485e4ddc7afc5c481b066dfc8bb315f296d0023.tar.bz2 | |
add some spec on route and stop_points
| -rw-r--r-- | app/controllers/stop_points_controller.rb | 4 | ||||
| -rw-r--r-- | app/views/routes/show.html.erb | 2 | ||||
| -rw-r--r-- | app/views/stop_points/new.html.erb | 5 | ||||
| -rw-r--r-- | config/locales/routes.yml | 2 | ||||
| -rw-r--r-- | config/locales/stop_points.yml | 24 | ||||
| -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 |
8 files changed, 112 insertions, 19 deletions
diff --git a/app/controllers/stop_points_controller.rb b/app/controllers/stop_points_controller.rb index a6833eb06..22b23cff5 100644 --- a/app/controllers/stop_points_controller.rb +++ b/app/controllers/stop_points_controller.rb @@ -23,9 +23,7 @@ class StopPointsController < ChouetteController else flash[:alert] = t("stop_points.reorder_failure") end - respond_to do |format| - format.html { redirect_to :action => :index } - end + redirect_to :action => :index end end diff --git a/app/views/routes/show.html.erb b/app/views/routes/show.html.erb index b98bab92a..f248ba595 100644 --- a/app/views/routes/show.html.erb +++ b/app/views/routes/show.html.erb @@ -83,7 +83,7 @@ <li><%= link_to t('routes.actions.edit'), edit_referential_line_route_path(@referential, @line, @route), :class => "edit" %></li> <li><%= link_to t('routes.actions.destroy'), referential_line_route_path(@referential, @line, @route), :method => :delete, :confirm => t('routes.actions.destroy_confirm'), :class => "remove" %></li> <li> - <%= link_to t('stop_points.actions.index'), referential_line_route_stop_points_path(@referential, @line, @route), :class => "edit" %> + <%= link_to t('stop_points.actions.sort'), referential_line_route_stop_points_path(@referential, @line, @route), :class => "edit" %> </li> </ul> <% end %> diff --git a/app/views/stop_points/new.html.erb b/app/views/stop_points/new.html.erb index a69840bf6..3b2e86c41 100644 --- a/app/views/stop_points/new.html.erb +++ b/app/views/stop_points/new.html.erb @@ -7,8 +7,9 @@ <% end %> <%= form.buttons do %> - <%= form.commit_button %> - ou <%= link_to "revenir", referential_line_route_stop_points_path(@referential, @line, @route) %> + <%= form.commit_button true %> + <li><%= t('or') %></li> + <li><%= link_to t('cancel'), :back %></li> <% end %> </div> <% end %> diff --git a/config/locales/routes.yml b/config/locales/routes.yml index e9422d2db..35bc2cd12 100644 --- a/config/locales/routes.yml +++ b/config/locales/routes.yml @@ -49,7 +49,7 @@ fr: title: "Modifier la séquence d'arrêts %{route}" show: title: "Séquence d'arrêts %{route} de la ligne %{line}" - stop_areas: "Liste des arrêts de la séquence d'arrêts" + stop_points: "Liste des arrêts de la séquence d'arrêts" no_opposite_route: "Aucune séquence d'arrêts associée en sens opposé" undefined: Non défini index: diff --git a/config/locales/stop_points.yml b/config/locales/stop_points.yml index 70f477d8e..cc40ba10a 100644 --- a/config/locales/stop_points.yml +++ b/config/locales/stop_points.yml @@ -3,6 +3,7 @@ en: reorder_success: "Reordering saved" reorder_failure: "Fail in reordering" actions: + sort: Reorder stop on route show: Show index: Stops on route list new: Add a new stop on route @@ -29,23 +30,24 @@ fr: reorder_success: "L'ordre a été mis à jour" reorder_failure: "Echec de la mise à jour" actions: + sort: Réordonner les arrêts de la séquence show: Consulter - index: Liste des arrêts sur itinéraire - new: Ajouter un arrêt sur itinéraire - edit: Modifier cet arrêt sur itinéraire - destroy: Supprimer cet arrêt sur itinéraire - destroy_confirm: Etes vous sûr de détruire cet arrêt sur itinéraire ? + index: Liste des arrêts de la séquence + new: Ajouter un arrêt à la séquence + edit: Modifier cet arrêt de la séquence + destroy: Supprimer cet arrêt de la séquence + destroy_confirm: Etes vous sûr de retirer cet arrêt de la séquence ? new: - title: "Ajouter un arrêt à l'itinéraire %{route}" + title: "Ajouter un arrêt à la séquence %{route}" select_area: "Sélectionner un arrêt" index: - reorder_button: "Mettre à jour l'ordre de parcours" - title: "Liste des arrêts de l'itinéraire %{route}" - subtitle: "Arrêts dans l'ordre " + reorder_button: "Mettre à jour l'ordre" + title: "Liste ordonnée des arrêts de la séquence d'arrêts %{route}" + subtitle: "Arrêts dans l'ordre de parcours" move: Déplacer - no_stop_point: Aucun arrêt sur itinéraire + no_stop_point: Aucun arrêt dans la séquence activerecord: models: - stop_point: Arrêt sur itinéraire + stop_point: "Arrêt sur séquence d'arrêts" attributes: stop_point: 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 |
