DEV: Make add_api_parameter_route parameter deprecations errors (#15198)

Since we said we would remove support in 2.7, this is overdue.
This commit is contained in:
Daniel Waterworth 2021-12-06 09:10:14 -06:00 committed by GitHub
parent 10cc082560
commit 3ebce550fe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 3 deletions

View File

@ -907,14 +907,14 @@ class Plugin::Instance
format: nil, formats: nil)
if Array(format).include?("*")
Discourse.deprecate("* is no longer a valid api_parameter_route format matcher. Use `nil` instead", drop_from: "2.7")
Discourse.deprecate("* is no longer a valid api_parameter_route format matcher. Use `nil` instead", drop_from: "2.7", raise_error: true)
# Old API used * as wildcard. New api uses `nil`
format = nil
end
# Backwards compatibility with old parameter names:
if method || route || format
Discourse.deprecate("method, route and format parameters for api_parameter_routes are deprecated. Use methods, actions and formats instead.", drop_from: "2.7")
Discourse.deprecate("method, route and format parameters for api_parameter_routes are deprecated. Use methods, actions and formats instead.", drop_from: "2.7", raise_error: true)
methods ||= method
actions ||= route
formats ||= format

View File

@ -51,7 +51,7 @@ describe 'api keys' do
context "with a plugin registered filter" do
before do
plugin = Plugin::Instance.new
plugin.add_api_parameter_route method: :get, route: "session#current", format: "*"
plugin.add_api_parameter_route methods: [:get], actions: ["session#current"]
end
it 'allows parameter access to the registered route' do