api: fix legacy /post/index and /tag/index endpoints.
Fixup for a1cd9d2b5. The route order matters here, the legacy endpoints
need to go first.
This commit is contained in:
@@ -271,6 +271,12 @@ Rails.application.routes.draw do
|
||||
end
|
||||
end
|
||||
|
||||
# Legacy Danbooru 1 API endpoints
|
||||
get "/tag/index.xml", :controller => "legacy", :action => "tags", :format => "xml"
|
||||
get "/tag/index.json", :controller => "legacy", :action => "tags", :format => "json"
|
||||
get "/post/index.xml", :controller => "legacy", :action => "posts", :format => "xml"
|
||||
get "/post/index.json", :controller => "legacy", :action => "posts", :format => "json"
|
||||
|
||||
# Legacy Danbooru 1 redirects.
|
||||
get "/artist" => redirect {|params, req| "/artists?page=#{req.params[:page]}&search[name]=#{CGI.escape(req.params[:name].to_s)}"}
|
||||
get "/artist/show/:id" => redirect("/artists/%{id}")
|
||||
@@ -294,12 +300,6 @@ Rails.application.routes.draw do
|
||||
get "/wiki/show" => redirect {|params, req| "/wiki_pages?title=#{CGI.escape(req.params[:title].to_s)}"}
|
||||
get "/help/:title" => redirect {|params, req| "/wiki_pages?title=#{CGI.escape('help:' + req.params[:title])}"}
|
||||
|
||||
# Legacy Danbooru 1 API endpoints
|
||||
get "/tag/index.xml", :controller => "legacy", :action => "tags", :format => "xml"
|
||||
get "/tag/index.json", :controller => "legacy", :action => "tags", :format => "json"
|
||||
get "/post/index.xml", :controller => "legacy", :action => "posts", :format => "xml"
|
||||
get "/post/index.json", :controller => "legacy", :action => "posts", :format => "json"
|
||||
|
||||
get "/login", to: "sessions#new", as: :login
|
||||
get "/logout", to: "sessions#sign_out", as: :logout
|
||||
get "/profile", to: "users#profile", as: :profile
|
||||
|
||||
25
test/functional/legacy_controller_test.rb
Normal file
25
test/functional/legacy_controller_test.rb
Normal file
@@ -0,0 +1,25 @@
|
||||
require 'test_helper'
|
||||
|
||||
class LegacyControllerTest < ActionDispatch::IntegrationTest
|
||||
context "The legacy controller" do
|
||||
context "post action" do
|
||||
should "work" do
|
||||
get "/post/index.xml"
|
||||
assert_response :success
|
||||
|
||||
get "/post/index.json"
|
||||
assert_response :success
|
||||
end
|
||||
end
|
||||
|
||||
context "tag action" do
|
||||
should "work" do
|
||||
get "/tag/index.xml"
|
||||
assert_response :success
|
||||
|
||||
get "/tag/index.json"
|
||||
assert_response :success
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user