diff --git a/app/abilities/ability.rb b/app/abilities/ability.rb index 9a8f193a1b5..aa9965001e9 100644 --- a/app/abilities/ability.rb +++ b/app/abilities/ability.rb @@ -4,7 +4,7 @@ class Ability include CanCan::Ability def initialize(user) - can :query, :browse + can :show, :feature_query can :show, [Node, Way, Relation] can [:index, :show], [OldNode, OldWay, OldRelation] can [:show, :create], Note diff --git a/app/controllers/browse_controller.rb b/app/controllers/browse_controller.rb deleted file mode 100644 index a3e65a1b7be..00000000000 --- a/app/controllers/browse_controller.rb +++ /dev/null @@ -1,13 +0,0 @@ -class BrowseController < ApplicationController - layout :map_layout - - before_action :authorize_web - before_action :set_locale - before_action -> { check_database_readable(:need_api => true) } - before_action :require_oauth - before_action :update_totp, :only => [:query] - around_action :web_timeout - authorize_resource :class => false - - def query; end -end diff --git a/app/controllers/features/queries_controller.rb b/app/controllers/features/queries_controller.rb new file mode 100644 index 00000000000..78b4088c2ee --- /dev/null +++ b/app/controllers/features/queries_controller.rb @@ -0,0 +1,15 @@ +module Features + class QueriesController < ApplicationController + layout :map_layout + + before_action :authorize_web + before_action :set_locale + before_action -> { check_database_readable(:need_api => true) } + before_action :require_oauth + before_action :update_totp + around_action :web_timeout + authorize_resource :class => :feature_query + + def show; end + end +end diff --git a/app/views/browse/query.html.erb b/app/views/features/queries/show.html.erb similarity index 100% rename from app/views/browse/query.html.erb rename to app/views/features/queries/show.html.erb diff --git a/config/locales/en.yml b/config/locales/en.yml index fc2ab125e42..02435a92d1f 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -398,11 +398,13 @@ en: telephone_link: "Call %{phone_number}" colour_preview: "Colour %{colour_value} preview" email_link: "Email %{email}" - query: - title: "Query Features" - introduction: "Click on the map to find nearby features." - nearby: "Nearby features" - enclosing: "Enclosing features" + features: + queries: + show: + title: "Query Features" + introduction: "Click on the map to find nearby features." + nearby: "Nearby features" + enclosing: "Enclosing features" nodes: timeout: sorry: "Sorry, the data for the node with the id %{id} took too long to retrieve." diff --git a/config/routes.rb b/config/routes.rb index 22c4ad64219..0e184851c70 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -179,7 +179,9 @@ get "/offline" => "site#offline" get "/key" => "site#key" get "/id" => "site#id" - get "/query" => "browse#query" + namespace :features, :path => "" do + resource :query, :only => :show + end get "/user/new" => "users#new" post "/user/new" => "users#create" get "/user/terms" => "users#terms" diff --git a/test/controllers/browse_controller_test.rb b/test/controllers/browse_controller_test.rb deleted file mode 100644 index 1844dcc6cc2..00000000000 --- a/test/controllers/browse_controller_test.rb +++ /dev/null @@ -1,18 +0,0 @@ -require "test_helper" - -class BrowseControllerTest < ActionDispatch::IntegrationTest - ## - # test all routes which lead to this controller - def test_routes - assert_routing( - { :path => "/query", :method => :get }, - { :controller => "browse", :action => "query" } - ) - end - - def test_query - get query_path - assert_response :success - assert_template "browse/query" - end -end diff --git a/test/controllers/features/queries_controller_test.rb b/test/controllers/features/queries_controller_test.rb new file mode 100644 index 00000000000..7d695c8eeb0 --- /dev/null +++ b/test/controllers/features/queries_controller_test.rb @@ -0,0 +1,20 @@ +require "test_helper" + +module Features + class QueriesControllerTest < ActionDispatch::IntegrationTest + ## + # test all routes which lead to this controller + def test_routes + assert_routing( + { :path => "/query", :method => :get }, + { :controller => "features/queries", :action => "show" } + ) + end + + def test_show + get features_query_path + assert_response :success + assert_template "features/queries/show" + end + end +end