Rename comments_feed to index

This commit is contained in:
Andy Allan 2018-11-07 09:58:21 +01:00
parent b7e871cb46
commit 4b0d56f7e1
4 changed files with 19 additions and 19 deletions

View file

@ -1,16 +1,16 @@
class ChangesetCommentsController < ApplicationController class ChangesetCommentsController < ApplicationController
before_action :authorize_web, :only => [:comments_feed] before_action :authorize_web, :only => [:index]
before_action :set_locale, :only => [:comments_feed] before_action :set_locale, :only => [:index]
before_action :authorize, :only => [:create, :hide_comment, :unhide_comment] before_action :authorize, :only => [:create, :hide_comment, :unhide_comment]
before_action :require_moderator, :only => [:hide_comment, :unhide_comment] before_action :require_moderator, :only => [:hide_comment, :unhide_comment]
before_action :require_allow_write_api, :only => [:create, :hide_comment, :unhide_comment] before_action :require_allow_write_api, :only => [:create, :hide_comment, :unhide_comment]
before_action :require_public_data, :only => [:create] before_action :require_public_data, :only => [:create]
before_action :check_api_writable, :only => [:create, :hide_comment, :unhide_comment] before_action :check_api_writable, :only => [:create, :hide_comment, :unhide_comment]
before_action :check_api_readable, :except => [:create, :comments_feed] before_action :check_api_readable, :except => [:create, :index]
before_action(:only => [:comments_feed]) { |c| c.check_database_readable(true) } before_action(:only => [:index]) { |c| c.check_database_readable(true) }
around_action :api_call_handle_error, :except => [:comments_feed] around_action :api_call_handle_error, :except => [:index]
around_action :api_call_timeout, :except => [:comments_feed] around_action :api_call_timeout, :except => [:index]
around_action :web_timeout, :only => [:comments_feed] around_action :web_timeout, :only => [:index]
## ##
# Add a comment to a changeset # Add a comment to a changeset
@ -84,7 +84,7 @@ class ChangesetCommentsController < ApplicationController
## ##
# Get a feed of recent changeset comments # Get a feed of recent changeset comments
def comments_feed def index
if params[:id] if params[:id]
# Extract the arguments # Extract the arguments
id = params[:id].to_i id = params[:id].to_i

View file

@ -116,7 +116,7 @@ OpenStreetMap::Application.routes.draw do
get "/relation/:id" => "browse#relation", :id => /\d+/, :as => :relation get "/relation/:id" => "browse#relation", :id => /\d+/, :as => :relation
get "/relation/:id/history" => "browse#relation_history", :id => /\d+/ get "/relation/:id/history" => "browse#relation_history", :id => /\d+/
get "/changeset/:id" => "browse#changeset", :as => :changeset, :id => /\d+/ get "/changeset/:id" => "browse#changeset", :as => :changeset, :id => /\d+/
get "/changeset/:id/comments/feed" => "changeset_comments#comments_feed", :as => :changeset_comments_feed, :id => /\d*/, :defaults => { :format => "rss" } get "/changeset/:id/comments/feed" => "changeset_comments#index", :as => :changeset_comments_feed, :id => /\d*/, :defaults => { :format => "rss" }
get "/note/:id" => "browse#note", :id => /\d+/, :as => "browse_note" get "/note/:id" => "browse#note", :id => /\d+/, :as => "browse_note"
get "/note/new" => "browse#new_note" get "/note/new" => "browse#new_note"
get "/user/:display_name/history" => "changeset#index" get "/user/:display_name/history" => "changeset#index"
@ -152,7 +152,7 @@ OpenStreetMap::Application.routes.draw do
get "/about" => "site#about" get "/about" => "site#about"
get "/history" => "changeset#index" get "/history" => "changeset#index"
get "/history/feed" => "changeset#feed", :defaults => { :format => :atom } get "/history/feed" => "changeset#feed", :defaults => { :format => :atom }
get "/history/comments/feed" => "changeset_comments#comments_feed", :as => :changesets_comments_feed, :defaults => { :format => "rss" } get "/history/comments/feed" => "changeset_comments#index", :as => :changesets_comments_feed, :defaults => { :format => "rss" }
get "/export" => "site#export" get "/export" => "site#export"
match "/login" => "users#login", :via => [:get, :post] match "/login" => "users#login", :via => [:get, :post]
match "/logout" => "users#logout", :via => [:get, :post] match "/logout" => "users#logout", :via => [:get, :post]

View file

@ -18,11 +18,11 @@ class ChangesetCommentsControllerTest < ActionController::TestCase
) )
assert_routing( assert_routing(
{ :path => "/changeset/1/comments/feed", :method => :get }, { :path => "/changeset/1/comments/feed", :method => :get },
{ :controller => "changeset_comments", :action => "comments_feed", :id => "1", :format => "rss" } { :controller => "changeset_comments", :action => "index", :id => "1", :format => "rss" }
) )
assert_routing( assert_routing(
{ :path => "/history/comments/feed", :method => :get }, { :path => "/history/comments/feed", :method => :get },
{ :controller => "changeset_comments", :action => "comments_feed", :format => "rss" } { :controller => "changeset_comments", :action => "index", :format => "rss" }
) )
end end
@ -207,11 +207,11 @@ class ChangesetCommentsControllerTest < ActionController::TestCase
## ##
# test comments feed # test comments feed
def test_comments_feed def test_feed
changeset = create(:changeset, :closed) changeset = create(:changeset, :closed)
create_list(:changeset_comment, 3, :changeset => changeset) create_list(:changeset_comment, 3, :changeset => changeset)
get :comments_feed, :params => { :format => "rss" } get :index, :params => { :format => "rss" }
assert_response :success assert_response :success
assert_equal "application/rss+xml", @response.content_type assert_equal "application/rss+xml", @response.content_type
assert_select "rss", :count => 1 do assert_select "rss", :count => 1 do
@ -220,7 +220,7 @@ class ChangesetCommentsControllerTest < ActionController::TestCase
end end
end end
get :comments_feed, :params => { :format => "rss", :limit => 2 } get :index, :params => { :format => "rss", :limit => 2 }
assert_response :success assert_response :success
assert_equal "application/rss+xml", @response.content_type assert_equal "application/rss+xml", @response.content_type
assert_select "rss", :count => 1 do assert_select "rss", :count => 1 do
@ -229,7 +229,7 @@ class ChangesetCommentsControllerTest < ActionController::TestCase
end end
end end
get :comments_feed, :params => { :id => changeset.id, :format => "rss" } get :index, :params => { :id => changeset.id, :format => "rss" }
assert_response :success assert_response :success
assert_equal "application/rss+xml", @response.content_type assert_equal "application/rss+xml", @response.content_type
assert_select "rss", :count => 1 do assert_select "rss", :count => 1 do
@ -241,11 +241,11 @@ class ChangesetCommentsControllerTest < ActionController::TestCase
## ##
# test comments feed # test comments feed
def test_comments_feed_bad_limit def test_feed_bad_limit
get :comments_feed, :params => { :format => "rss", :limit => 0 } get :index, :params => { :format => "rss", :limit => 0 }
assert_response :bad_request assert_response :bad_request
get :comments_feed, :params => { :format => "rss", :limit => 100001 } get :index, :params => { :format => "rss", :limit => 100001 }
assert_response :bad_request assert_response :bad_request
end end
end end