From f6c2141a1672acb7010f2e7b961e53b0e34a21cb Mon Sep 17 00:00:00 2001 From: cedricnjanga Date: Wed, 23 May 2018 17:21:03 -0700 Subject: Refs #6860 Remove all call of referential_stop_areas_path & referential_stop_area_path --- app/controllers/stop_area_copies_controller.rb | 2 +- app/views/connection_links/_connection_link.slim | 4 ++-- app/views/referential_stop_areas/_stop_area.html.slim | 4 ++-- app/views/referential_stop_areas/edit.html.slim | 2 +- app/views/referential_stop_areas/index.html.slim | 6 +++--- app/views/referential_stop_areas/new.html.slim | 2 +- app/views/referential_stop_areas/show.html.slim | 2 +- app/views/routing_constraint_zones/_stop_points.html.slim | 2 +- app/views/routing_constraint_zones/show.html.slim | 2 +- app/views/shared/_header.html.slim | 2 +- config/breadcrumbs.rb | 10 ---------- spec/features/referential_stop_areas_spec.rb | 8 ++++---- 12 files changed, 18 insertions(+), 28 deletions(-) diff --git a/app/controllers/stop_area_copies_controller.rb b/app/controllers/stop_area_copies_controller.rb index 992a2bb08..aaa08620e 100644 --- a/app/controllers/stop_area_copies_controller.rb +++ b/app/controllers/stop_area_copies_controller.rb @@ -19,7 +19,7 @@ class StopAreaCopiesController < ChouetteController @stop_area_copy = StopAreaCopy.new(params[:stop_area_copy]) @stop_area = parent if @stop_area_copy.save - redirect_to referential_stop_area_path( @referential,@stop_area_copy.copy ), notice: I18n.t("stop_area_copies.new.success") + redirect_to stop_area_referential_stop_area_path(@stop_area.stop_area_referential, @stop_area_copy.copy), notice: I18n.t("stop_area_copies.new.success") else flash[:error] = I18n.t("stop_area_copies.errors.copy_aborted") + "
" + @stop_area_copy.errors.full_messages.join("
") render :action => :new diff --git a/app/views/connection_links/_connection_link.slim b/app/views/connection_links/_connection_link.slim index 44ed5093f..9de04ba12 100644 --- a/app/views/connection_links/_connection_link.slim +++ b/app/views/connection_links/_connection_link.slim @@ -20,14 +20,14 @@ = t('.from') - if connection_link.departure.present? - = link_to_if connection_link.departure, truncate(connection_link.departure.name, :length => 15) , referential_stop_area_path(@referential, connection_link.departure), :title => "#{connection_link.human_attribute_name('departure')} #{connection_link.departure.name}" + = link_to_if connection_link.departure, truncate(connection_link.departure.name, :length => 15) , stop_area_referential_stop_area_path(connection_link.departure.stop_area_referential, connection_link.departure), :title => "#{connection_link.human_attribute_name('departure')} #{connection_link.departure.name}" - else = connection_link.human_attribute_name('undefined') = t('.to') - if connection_link.arrival.present? - = link_to_if( connection_link.arrival, truncate(connection_link.arrival.name, :length => 15), referential_stop_area_path(@referential, connection_link.arrival), :title => "#{connection_link.human_attribute_name('arrival')} #{connection_link.arrival.name}" ) + = link_to_if( connection_link.arrival, truncate(connection_link.arrival.name, :length => 15), stop_area_referential_stop_area_path(connection_link.arrival.stop_area_referential, connection_link.arrival), :title => "#{connection_link.human_attribute_name('arrival')} #{connection_link.arrival.name}" ) - else = connection_link.human_attribute_name("undefined") p diff --git a/app/views/referential_stop_areas/_stop_area.html.slim b/app/views/referential_stop_areas/_stop_area.html.slim index bb9ed7ce3..e4dfe63fa 100644 --- a/app/views/referential_stop_areas/_stop_area.html.slim +++ b/app/views/referential_stop_areas/_stop_area.html.slim @@ -3,11 +3,11 @@ .panel-title.clearfix span.pull-right - if policy(stop_area).update? - = link_to edit_referential_stop_area_path(@referential, stop_area), class: 'btn btn-default btn-sm' do + = link_to edit_stop_area_referential_stop_area_path(stop_area.stop_area_referential, stop_area), class: 'btn btn-default btn-sm' do span.fa.fa-pencil - if policy(stop_area).destroy? - = link_to referential_stop_area_path(@referential, stop_area), method: :delete, :data => {:confirm => t('stop_areas.actions.destroy_confirm')}, class: 'btn btn-danger btn-sm' do + = link_to stop_area_referential_stop_area_path(stop_area.stop_area_referential, stop_area), method: :delete, :data => {:confirm => t('stop_areas.actions.destroy_confirm')}, class: 'btn btn-danger btn-sm' do span.fa.fa-trash-o h5 diff --git a/app/views/referential_stop_areas/edit.html.slim b/app/views/referential_stop_areas/edit.html.slim index d88230b58..4641cf0be 100644 --- a/app/views/referential_stop_areas/edit.html.slim +++ b/app/views/referential_stop_areas/edit.html.slim @@ -1,3 +1,3 @@ -- breadcrumb :referential_stop_area, @referential, @stop_area +- breadcrumb :stop_area, @stop_area.stop_area_referential, @stop_area - page_header_content_for @stop_area = render 'form' diff --git a/app/views/referential_stop_areas/index.html.slim b/app/views/referential_stop_areas/index.html.slim index ad04fb02e..39073540d 100644 --- a/app/views/referential_stop_areas/index.html.slim +++ b/app/views/referential_stop_areas/index.html.slim @@ -1,6 +1,6 @@ -- breadcrumb :referential_stop_areas, @referential +- breadcrumb :stop_areas, @referential.workbench.stop_area_referential -= search_form_for @q, :url => referential_stop_areas_path(@referential), remote: true, :html => {:method => :get, class: "form-inline", :id => "search", role: "form"} do |f| += search_form_for @q, :url => stop_area_referential_stop_areas_path(@referential.workbench.stop_area_referential), remote: true, :html => {:method => :get, class: "form-inline", :id => "search", role: "form"} do |f| .panel.panel-default .panel-heading .input-group.col-md-9.col-sm-9 @@ -29,6 +29,6 @@ ul.actions - if policy(Chouette::StopArea).create? li - = link_to t('stop_areas.actions.new'), new_referential_stop_area_path(@referential), class: 'add' + = link_to t('stop_areas.actions.new'), new_stop_area_referential_stop_area_path(@referential.workbench.stop_area_referential), class: 'add' li / = link_to t('stop_areas.actions.default_geometry'), default_geometry_referential_stop_areas_path(@referential), :method => :put, :class => "calculator" diff --git a/app/views/referential_stop_areas/new.html.slim b/app/views/referential_stop_areas/new.html.slim index 9342b673b..8fbef33de 100644 --- a/app/views/referential_stop_areas/new.html.slim +++ b/app/views/referential_stop_areas/new.html.slim @@ -1,2 +1,2 @@ -- breadcrumb :referential_stop_areas, @referential +- breadcrumb :stop_areas, @referential.workbench.stop_area_referential = render 'form' diff --git a/app/views/referential_stop_areas/show.html.slim b/app/views/referential_stop_areas/show.html.slim index 06096bbaa..d464eb438 100644 --- a/app/views/referential_stop_areas/show.html.slim +++ b/app/views/referential_stop_areas/show.html.slim @@ -1,4 +1,4 @@ -- breadcrumb :referential_stop_area, @referential, @stop_area +- breadcrumb :stop_area, @stop_area.stop_area_referential, @stop_area - page_header_content_for @stop_area .page_content diff --git a/app/views/routing_constraint_zones/_stop_points.html.slim b/app/views/routing_constraint_zones/_stop_points.html.slim index 4e85ba8b2..c2da4bb2d 100644 --- a/app/views/routing_constraint_zones/_stop_points.html.slim +++ b/app/views/routing_constraint_zones/_stop_points.html.slim @@ -1,7 +1,7 @@ - stop_points.each do |stop_point| .wrapper div - = link_to referential_stop_area_path(@referential, stop_point.stop_area.id), class: 'navlink', title: "Voir l'arrĂȘt" do + = link_to stop_area_referential_stop_area_path(stop_point.stop_area.stop_are_referential, stop_point.stop_area.id), class: 'navlink', title: "Voir l'arrĂȘt" do span = stop_point.stop_area.name div diff --git a/app/views/routing_constraint_zones/show.html.slim b/app/views/routing_constraint_zones/show.html.slim index 55c952ae6..2d444fe90 100644 --- a/app/views/routing_constraint_zones/show.html.slim +++ b/app/views/routing_constraint_zones/show.html.slim @@ -19,7 +19,7 @@ name: t('.route_stop_points'), \ attribute: 'name', \ link_to: lambda do |stop_point| \ - referential_stop_area_path(@referential, stop_point.stop_area) \ + stop_area_referential_stop_area_path(stop_point.stop_area.stop_area_referential, stop_point.stop_area) \ end \ ), TableBuilderHelper::Column.new( \ diff --git a/app/views/shared/_header.html.slim b/app/views/shared/_header.html.slim index afe802b49..b59be2b08 100644 --- a/app/views/shared/_header.html.slim +++ b/app/views/shared/_header.html.slim @@ -67,7 +67,7 @@ nav.navbar.navbar-default.navbar-fixed-top role="navigation" = Referential.human_attribute_name("lines") li - = link_to referential_stop_areas_path(@referential) do + = link_to stop_area_referential_stop_areas_path(@referential.workbench.stop_area_referential) do span.badge.pull-right = @referential.stop_areas.size = Referential.human_attribute_name("stop_areas") diff --git a/config/breadcrumbs.rb b/config/breadcrumbs.rb index 28a117d52..d2edb7d5e 100644 --- a/config/breadcrumbs.rb +++ b/config/breadcrumbs.rb @@ -271,16 +271,6 @@ crumb :journey_patterns do |referential, route| parent :route, referential, route end -crumb :referential_stop_areas do |referential| - link I18n.t('stop_areas.index.title'), referential_stop_areas_path(referential) - parent :referential, referential -end - -crumb :referential_stop_area do |referential, stop_area| - link breadcrumb_name(stop_area), referential_stop_area_path(referential, stop_area) - parent :referential_stop_areas, referential -end - crumb :vehicle_journeys do |referential, route| link I18n.t('vehicle_journeys.index.title', route: route.name), referential_line_route_vehicle_journeys_path(referential, route.line, route) parent :route, referential, route diff --git a/spec/features/referential_stop_areas_spec.rb b/spec/features/referential_stop_areas_spec.rb index 5e70857e7..14da3a725 100644 --- a/spec/features/referential_stop_areas_spec.rb +++ b/spec/features/referential_stop_areas_spec.rb @@ -9,7 +9,7 @@ describe 'ReferentialStopAreas', type: :feature do let!(:stop_areas) { Array.new(2) { create :stop_area, stop_area_referential: stop_area_referential } } describe 'index' do - before(:each) { visit referential_stop_areas_path(referential) } + before(:each) { visit stop_area_referential_stop_areas_path(referential.workbench.stop_area_referential) } it 'displays referential stop_areas' do expect(page).to have_content(stop_areas.first.name) @@ -18,14 +18,14 @@ describe 'ReferentialStopAreas', type: :feature do context 'filtering' do it 'supports filtering by name' do - fill_in 'q[name_or_objectid_cont]', with: stop_areas.first.name + fill_in 'q[name_or_objectid_or_registration_number_cont]', with: stop_areas.first.name click_button 'search-btn' expect(page).to have_content(stop_areas.first.name) expect(page).not_to have_content(stop_areas.last.name) end it 'supports filtering by objectid' do - fill_in 'q[name_or_objectid_cont]', with: stop_areas.first.objectid + fill_in 'q[name_or_objectid_or_registration_number_cont]', with: stop_areas.first.objectid click_button 'search-btn' expect(page).to have_content(stop_areas.first.name) expect(page).not_to have_content(stop_areas.last.name) @@ -35,7 +35,7 @@ describe 'ReferentialStopAreas', type: :feature do describe 'show' do it 'displays referential stop area' do - visit referential_stop_area_path(referential, stop_areas.first) + visit stop_area_referential_stop_area_path(stop_areas.first.stop_area_referential, stop_areas.first) expect(page).to have_content(stop_areas.first.name) end end -- cgit v1.2.3