aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--app/controllers/routes_controller.rb7
-rw-r--r--app/views/routes/edit_boarding_alighting.html.erb2
-rw-r--r--spec/features/journey_pattern_spec.rb22
-rw-r--r--spec/features/routes_spec.rb37
4 files changed, 49 insertions, 19 deletions
diff --git a/app/controllers/routes_controller.rb b/app/controllers/routes_controller.rb
index 9f9d66ba5..afaa8adba 100644
--- a/app/controllers/routes_controller.rb
+++ b/app/controllers/routes_controller.rb
@@ -22,8 +22,7 @@ class RoutesController < ChouetteController
def save_boarding_alighting
@route = route
-
- if @route.update_attributes(params[:route])
+ if @route.update_attributes!(route_params)
redirect_to referential_line_route_path(@referential, @line, @route)
else
render "edit_boarding_alighting"
@@ -78,8 +77,8 @@ class RoutesController < ChouetteController
private
def route_params
- params.require(:route).permit( :direction_code, :wayback_code, :line_id, :objectid, :object_version, :creation_time, :creator_id, :name, :comment, :opposite_route_id, :published_name, :number, :direction, :wayback, { stop_points_attributes: [ :id, :_destroy, :position, :stop_area_id ] } )
- end
+ params.require(:route).permit( :direction_code, :wayback_code, :line_id, :objectid, :object_version, :creation_time, :creator_id, :name, :comment, :opposite_route_id, :published_name, :number, :direction, :wayback, { stop_points_attributes: [ :id, :_destroy, :position, :stop_area_id, :for_boarding, :for_alighting ] } )
+ end
end
diff --git a/app/views/routes/edit_boarding_alighting.html.erb b/app/views/routes/edit_boarding_alighting.html.erb
index fc3378425..1b46cda5a 100644
--- a/app/views/routes/edit_boarding_alighting.html.erb
+++ b/app/views/routes/edit_boarding_alighting.html.erb
@@ -1,6 +1,6 @@
<%= title_tag t('routes.edit_boarding_alighting.title', :route => @route.name ) %>
-<%= simple_form_for ["save_boarding_alighting", @referential, @line, @route] do |form| %>
+<%= simple_form_for ["save_boarding_alighting", @referential, @line, @route], :method => :PUT do |form| %>
<table class="table table-hover">
<thead>
<th><%= t(".stop_area_name") %></th>
diff --git a/spec/features/journey_pattern_spec.rb b/spec/features/journey_pattern_spec.rb
index 9bddcf3bc..470d74a99 100644
--- a/spec/features/journey_pattern_spec.rb
+++ b/spec/features/journey_pattern_spec.rb
@@ -11,7 +11,7 @@ describe "JourneyPatterns", :type => :feature do
describe "from routes page to a journey_pattern page" do
it "display route's journey_patterns" do
visit referential_line_route_path(referential,line,route)
- click_link "Liste des missions"
+ click_link I18n.t('routes.show.journey_patterns')
expect(page).to have_content(journey_pattern.name)
end
end
@@ -19,8 +19,8 @@ describe "JourneyPatterns", :type => :feature do
describe "from route's page to journey_pattern's page" do
it "display journey_pattern properties" do
visit referential_line_route_path(referential,line,route)
- click_link "Liste des missions"
- click_link "#{journey_pattern.name}"
+ click_link I18n.t('routes.show.journey_patterns')
+ click_link journey_pattern.name
expect(page).to have_content(journey_pattern.published_name)
expect(page).to have_content(journey_pattern.comment)
expect(page).to have_content(journey_pattern.registration_number)
@@ -30,10 +30,10 @@ describe "JourneyPatterns", :type => :feature do
describe "from route's page, create a new journey_pattern" do
it "return to route's page that display new journey_pattern" do
visit referential_line_route_path(referential,line,route)
- click_link "Ajouter une mission"
- fill_in "Nom", :with => "A to B"
- fill_in "Comment", :with => "AB"
- click_button("Créer mission")
+ click_link I18n.t("journey_patterns.actions.new")
+ fill_in "journey_pattern[name]", :with => "A to B"
+ fill_in "journey_pattern[comment]", :with => "AB"
+ click_button(I18n.t('formtastic.create',model: I18n.t('activerecord.models.journey_pattern.one')))
expect(page).to have_content("A to B")
end
end
@@ -41,10 +41,10 @@ describe "JourneyPatterns", :type => :feature do
describe "from route's page, select a journey_pattern and delete it" do
it "return to route's page without journey_pattern name" do
visit referential_line_route_path(referential,line,route)
- click_link "Liste des missions"
- click_link "#{journey_pattern.name}"
- click_link "Supprimer cette mission"
- click_link "Liste des missions"
+ click_link I18n.t('routes.show.journey_patterns')
+ click_link journey_pattern.name
+ click_link I18n.t('journey_patterns.actions.destroy')
+ click_link I18n.t('routes.show.journey_patterns')
expect(page).not_to have_content(journey_pattern.name)
end
end
diff --git a/spec/features/routes_spec.rb b/spec/features/routes_spec.rb
index 538c6a969..f512e6a83 100644
--- a/spec/features/routes_spec.rb
+++ b/spec/features/routes_spec.rb
@@ -4,9 +4,12 @@ require 'spec_helper'
describe "Routes", :type => :feature do
login_user
- let!(:line) { Factory(:line) }
- let!(:route) { Factory(:route, :line => line) }
- let!(:route2) { Factory(:route, :line => line) }
+ let!(:line) { create(:line) }
+ let!(:route) { create(:route, :line => line) }
+ let!(:route2) { create(:route, :line => line) }
+ #let!(:stop_areas) { Array.new(4) { create(:stop_area) } }
+ let!(:stop_points) { Array.new(4) { create(:stop_point, :route => route) } }
+
describe "from lines page to a line page" do
it "display line's routes" do
@@ -58,4 +61,32 @@ describe "Routes", :type => :feature do
expect(page).not_to have_content(route.name)
end
end
+
+ describe "from route's page, select edit boarding/alighting and update it" do
+ it "Edits boarding/alighting properties on route stops" do
+ visit referential_line_route_path(referential, line, route)
+ click_link I18n.t('routes.actions.edit_boarding_alighting')
+ expect(page).to have_content(I18n.t('routes.edit_boarding_alighting.title'))
+ stop_points.each do |sp|
+ expect(page).to have_content(sp.stop_area.name)
+ expect(page).to have_content(sp.for_boarding)
+ expect(page).to have_content(sp.for_alighting)
+ end
+ end
+ end
+
+ describe "Modifies boarding/alighting properties on route stops" do
+ it "Puts (http) an update request" do
+ #visit edit_boarding_alighting_referential_line_route_path(referential, line, route)
+ visit referential_line_route_path(referential, line, route)
+ click_link I18n.t('routes.actions.edit_boarding_alighting')
+ #select('', :from => '')
+ # Changes the boarding of the first stop
+ # Changes the alighting of the last stop
+ # save
+ #click_button(I18n.t('helpers.submit.update', model: I18n.t('activerecord.models.route.one')))
+ click_button(I18n.t('helpers.submit.update', model: I18n.t('activerecord.models.route.one')))
+ end
+ end
+
end