[openSUSE/open-build-service] 87b68e: Simplify require_request method in Webui::RequestC...
Branch: refs/heads/master Home: https://github.com/openSUSE/open-build-service Commit: 87b68eab269aad08195727785d6f71bc023af33b https://github.com/openSUSE/open-build-service/commit/87b68eab269aad08195727... Author: Dany Marcoux <dmarcoux@posteo.de> Date: 2022-07-25 (Mon, 25 Jul 2022) Changed paths: M src/api/app/controllers/webui/request_controller.rb M src/api/config/brakeman.ignore M src/api/spec/controllers/webui/request_controller_spec.rb Log Message: ----------- Simplify require_request method in Webui::RequestController `require_request` is used in a before_filter callback for `changerequest`, `show` and `request_action` actions. The request number has to be passed in the `show` and `request_action` routes, so it's impossible to not have `number` in the `params`. As for `changerequest`, the request number is also passed in the `params` via a hidden field when the form is submitted. So unless a user changes the HTML, it's always going to be there. And if this happens, there's nothing we can do. This explains why relying on required_parameters and all this custom code is not needed. We can instead do it the Rails way and rely on `find_by!`, which raises `ActiveRecord::RecordNotFound` if the request isn't found, then the controller responds with 404. Commit: e2e75ca3d953d6a09224cad66940d7cf8286e262 https://github.com/openSUSE/open-build-service/commit/e2e75ca3d953d6a09224ca... Author: Dany Marcoux <dmarcoux@posteo.de> Date: 2022-07-26 (Tue, 26 Jul 2022) Changed paths: M src/api/app/controllers/webui/request_controller.rb M src/api/config/brakeman.ignore M src/api/spec/controllers/webui/request_controller_spec.rb Log Message: ----------- Merge pull request #12842 from dmarcoux/refactor-require_request Simplify require_request method in Webui::RequestController Compare: https://github.com/openSUSE/open-build-service/compare/98c47b7af79c...e2e75c...
participants (1)
-
Dany Marcoux