From 6753f15fa45e242ad6859807eb8672160104f1cf Mon Sep 17 00:00:00 2001 From: Anton Khorev Date: Sun, 4 May 2025 05:57:33 +0300 Subject: [PATCH] Create directions resource --- .rubocop.yml | 1 - app/abilities/ability.rb | 2 +- app/controllers/directions_controller.rb | 10 +++++----- .../directions/{search.html.erb => show.html.erb} | 0 config/locales/en.yml | 2 +- config/routes.rb | 2 +- test/controllers/directions_controller_test.rb | 6 ++---- 7 files changed, 10 insertions(+), 13 deletions(-) rename app/views/directions/{search.html.erb => show.html.erb} (100%) diff --git a/.rubocop.yml b/.rubocop.yml index aa75d2d89..37fea4e48 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -142,7 +142,6 @@ Rails/SpecificActionNames: - 'app/controllers/confirmations_controller.rb' - 'app/controllers/diary_comments_controller.rb' - 'app/controllers/diary_entries_controller.rb' - - 'app/controllers/directions_controller.rb' - 'app/controllers/errors_controller.rb' - 'app/controllers/export_controller.rb' - 'app/controllers/issues_controller.rb' diff --git a/app/abilities/ability.rb b/app/abilities/ability.rb index b1c943812..673fe5afa 100644 --- a/app/abilities/ability.rb +++ b/app/abilities/ability.rb @@ -7,7 +7,7 @@ class Ability can :read, [:feature_query, :map_key] can :read, [Node, Way, Relation, OldNode, OldWay, OldRelation] can [:show, :create], Note - can :search, :direction + can :read, :directions can [:index, :permalink, :edit, :help, :fixthemap, :offline, :export, :about, :communities, :preview, :copyright, :id], :site can [:finish, :embed], :export can [:create, :read], :search diff --git a/app/controllers/directions_controller.rb b/app/controllers/directions_controller.rb index ec2327400..2fcae04f6 100644 --- a/app/controllers/directions_controller.rb +++ b/app/controllers/directions_controller.rb @@ -1,10 +1,10 @@ class DirectionsController < ApplicationController + layout :map_layout + before_action :authorize_web before_action :set_locale - before_action :require_oauth, :only => [:search] - authorize_resource :class => false + before_action :require_oauth + authorize_resource :class => :directions - def search - render :layout => map_layout - end + def show; end end diff --git a/app/views/directions/search.html.erb b/app/views/directions/show.html.erb similarity index 100% rename from app/views/directions/search.html.erb rename to app/views/directions/show.html.erb diff --git a/config/locales/en.yml b/config/locales/en.yml index 1500b2e6a..77930d3c0 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -1542,7 +1542,7 @@ en: no_results: "No results found" more_results: "More results" directions: - search: + show: title: Directions distance: "Distance" time: "Time" diff --git a/config/routes.rb b/config/routes.rb index 3aef845c4..badd02408 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -342,7 +342,7 @@ OpenStreetMap::Application.routes.draw do end # directions - get "/directions" => "directions#search" + resource :directions, :only => :show # export post "/export/finish" => "export#finish" diff --git a/test/controllers/directions_controller_test.rb b/test/controllers/directions_controller_test.rb index 31f57b9db..45c731385 100644 --- a/test/controllers/directions_controller_test.rb +++ b/test/controllers/directions_controller_test.rb @@ -6,13 +6,11 @@ class DirectionsControllerTest < ActionDispatch::IntegrationTest def test_routes assert_routing( { :path => "/directions", :method => :get }, - { :controller => "directions", :action => "search" } + { :controller => "directions", :action => "show" } ) end - ### - # test the search action - def test_search + def test_show get directions_path assert_response :success end -- 2.39.5