diff options
| -rw-r--r-- | app/views/vehicle_journeys/index.html.slim | 4 | ||||
| -rw-r--r-- | config/locales/routes.en.yml | 1 | ||||
| -rw-r--r-- | config/locales/routes.fr.yml | 1 | ||||
| -rw-r--r-- | spec/factories/chouette_routes.rb | 7 | ||||
| -rw-r--r-- | spec/support/integration_spec_helper.rb | 6 | ||||
| -rw-r--r-- | spec/views/vehicle_journeys/index.html.slim_spec.rb | 30 | 
6 files changed, 48 insertions, 1 deletions
| diff --git a/app/views/vehicle_journeys/index.html.slim b/app/views/vehicle_journeys/index.html.slim index 52c1a9728..f9df1f30c 100644 --- a/app/views/vehicle_journeys/index.html.slim +++ b/app/views/vehicle_journeys/index.html.slim @@ -1,5 +1,9 @@  - breadcrumb :vehicle_journeys, @referential, @route  - content_for :page_header_title, t('vehicle_journeys.index.title', route: @route.name) +- if @route.opposite_route.present? +  - content_for :page_header_actions do +    = link_to(t('routes.actions.opposite_route_timetable'), [@referential, @route.line, @route.opposite_route, :vehicle_journeys], class: 'btn btn-default') +  .page_content    .container-fluid diff --git a/config/locales/routes.en.yml b/config/locales/routes.en.yml index d82ba98dd..7b82e788b 100644 --- a/config/locales/routes.en.yml +++ b/config/locales/routes.en.yml @@ -13,6 +13,7 @@ en:        export_hub_all: "Export HUB routes"        add_stop_point: "Add stop point"        new_stop_point: "Create new stop" +      opposite_route_timetable: "Timetable back"      new:        title: "Add a new route"      edit: diff --git a/config/locales/routes.fr.yml b/config/locales/routes.fr.yml index 457345ae8..1d151e60b 100644 --- a/config/locales/routes.fr.yml +++ b/config/locales/routes.fr.yml @@ -13,6 +13,7 @@ fr:        export_hub_all: "Export HUB des itinéraires"        add_stop_point: "Ajouter un arrêt"        new_stop_point: "Créer un arrêt pour l'ajouter" +      opposite_route_timetable: "Horaires retour"      new:        title: "Ajouter un itinéraire"      edit: diff --git a/spec/factories/chouette_routes.rb b/spec/factories/chouette_routes.rb index 4e20059fe..7443d08bc 100644 --- a/spec/factories/chouette_routes.rb +++ b/spec/factories/chouette_routes.rb @@ -31,6 +31,13 @@ FactoryGirl.define do          end        end + +      trait :with_opposite do +        after(:create) do |route| +          opposite = create :route +          route.opposite_route = opposite +        end +      end      end      factory :route_with_after_commit do diff --git a/spec/support/integration_spec_helper.rb b/spec/support/integration_spec_helper.rb index 78efb9027..1bf211fe1 100644 --- a/spec/support/integration_spec_helper.rb +++ b/spec/support/integration_spec_helper.rb @@ -1,7 +1,11 @@  module IntegrationSpecHelper    def paginate_collection klass, decorator, page=1 -    ModelDecorator.decorate( klass.page(page), with: decorator ) +    coll = klass.page(page) +    if decorator +      coll = ModelDecorator.decorate( coll, with: decorator ) +    end +    coll    end    def build_paginated_collection factory, decorator, opts={} diff --git a/spec/views/vehicle_journeys/index.html.slim_spec.rb b/spec/views/vehicle_journeys/index.html.slim_spec.rb new file mode 100644 index 000000000..07fc2419d --- /dev/null +++ b/spec/views/vehicle_journeys/index.html.slim_spec.rb @@ -0,0 +1,30 @@ +require 'spec_helper' + +describe "/vehicle_journeys/index", :type => :view do + +  let!(:referential) { assign :referential, create(:referential) } +  let!(:line) { assign :line, create(:line) } +  let!(:route) { assign :route, create(:route, line: line) } +  let!(:vehicle_journeys) do +    assign :vehicle_journeys, build_paginated_collection(:vehicle_journey, nil, route: route) +  end + +  before :each do +    allow(view).to receive(:link_with_search).and_return("#") +    allow(view).to receive(:collection).and_return(vehicle_journeys) +    allow(view).to receive(:current_referential).and_return(referential) +    controller.request.path_parameters[:referential_id] = referential.id +    render +  end + +  context "with an opposite_route" do +    let!(:route) { assign :route, create(:route, :with_opposite, line: line) } + +    it "should have an 'oppposite route timetable' button" do +      href = view.referential_line_route_vehicle_journeys_path(referential, line, route.opposite_route) +      oppposite_button_selector = "a[href=\"#{href}\"]" + +      expect(view.content_for(:page_header_actions)).to have_selector oppposite_button_selector +    end +  end +end | 
