From: Andy Allan Date: Wed, 18 Apr 2018 03:22:37 +0000 (+0800) Subject: Pluralise user_preferences_controller X-Git-Tag: live~3082^2 X-Git-Url: https://git.openstreetmap.org/rails.git/commitdiff_plain/9408ed69466acd83d6c18f555d20eba41da9af2b Pluralise user_preferences_controller This is the rails convention for controllers and can make route generation easier. http://guides.rubyonrails.org/action_controller_overview.html#controller-naming-convention --- diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 2c8d29eb8..cdac8fd67 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -35,7 +35,7 @@ Lint/AssignmentInCondition: - 'app/controllers/notes_controller.rb' - 'app/controllers/trace_controller.rb' - 'app/controllers/user_controller.rb' - - 'app/controllers/user_preference_controller.rb' + - 'app/controllers/user_preferences_controller.rb' - 'app/helpers/application_helper.rb' - 'app/helpers/browse_helper.rb' - 'app/models/client_application.rb' diff --git a/app/controllers/user_preference_controller.rb b/app/controllers/user_preferences_controller.rb similarity index 97% rename from app/controllers/user_preference_controller.rb rename to app/controllers/user_preferences_controller.rb index 16165513a..0aa2e8d52 100644 --- a/app/controllers/user_preference_controller.rb +++ b/app/controllers/user_preferences_controller.rb @@ -1,5 +1,5 @@ # Update and read user preferences, which are arbitrayr key/val pairs -class UserPreferenceController < ApplicationController +class UserPreferencesController < ApplicationController skip_before_action :verify_authenticity_token before_action :authorize before_action :require_allow_read_prefs, :only => [:read_one, :read] diff --git a/config/routes.rb b/config/routes.rb index ca0c4ecf0..67deae7ed 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -68,11 +68,11 @@ OpenStreetMap::Application.routes.draw do get "user/details" => "user#api_details" get "user/gpx_files" => "user#api_gpx_files" - get "user/preferences" => "user_preference#read" - get "user/preferences/:preference_key" => "user_preference#read_one" - put "user/preferences" => "user_preference#update" - put "user/preferences/:preference_key" => "user_preference#update_one" - delete "user/preferences/:preference_key" => "user_preference#delete_one" + get "user/preferences" => "user_preferences#read" + get "user/preferences/:preference_key" => "user_preferences#read_one" + put "user/preferences" => "user_preferences#update" + put "user/preferences/:preference_key" => "user_preferences#update_one" + delete "user/preferences/:preference_key" => "user_preferences#delete_one" post "gpx/create" => "trace#api_create" get "gpx/:id" => "trace#api_read", :id => /\d+/ diff --git a/test/controllers/user_preference_controller_test.rb b/test/controllers/user_preferences_controller_test.rb similarity index 93% rename from test/controllers/user_preference_controller_test.rb rename to test/controllers/user_preferences_controller_test.rb index 7f614587d..3e5cbb369 100644 --- a/test/controllers/user_preference_controller_test.rb +++ b/test/controllers/user_preferences_controller_test.rb @@ -1,28 +1,28 @@ require "test_helper" -class UserPreferenceControllerTest < ActionController::TestCase +class UserPreferencesControllerTest < ActionController::TestCase ## # test all routes which lead to this controller def test_routes assert_routing( { :path => "/api/0.6/user/preferences", :method => :get }, - { :controller => "user_preference", :action => "read" } + { :controller => "user_preferences", :action => "read" } ) assert_routing( { :path => "/api/0.6/user/preferences", :method => :put }, - { :controller => "user_preference", :action => "update" } + { :controller => "user_preferences", :action => "update" } ) assert_routing( { :path => "/api/0.6/user/preferences/key", :method => :get }, - { :controller => "user_preference", :action => "read_one", :preference_key => "key" } + { :controller => "user_preferences", :action => "read_one", :preference_key => "key" } ) assert_routing( { :path => "/api/0.6/user/preferences/key", :method => :put }, - { :controller => "user_preference", :action => "update_one", :preference_key => "key" } + { :controller => "user_preferences", :action => "update_one", :preference_key => "key" } ) assert_routing( { :path => "/api/0.6/user/preferences/key", :method => :delete }, - { :controller => "user_preference", :action => "delete_one", :preference_key => "key" } + { :controller => "user_preferences", :action => "delete_one", :preference_key => "key" } ) end