diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-02-28 18:11:48 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-02-28 18:11:48 +0300 |
commit | baed745d21710f1d78ece03558873acd6fd7d358 (patch) | |
tree | 628622c816195894985d03ab01f55abe7c6ac7ca /app/presenters | |
parent | 22ecb1e3fc02bb923c3e9941b1baa849348a036f (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/presenters')
-rw-r--r-- | app/presenters/README.md | 12 | ||||
-rw-r--r-- | app/presenters/ci/build_runner_presenter.rb | 2 |
2 files changed, 7 insertions, 7 deletions
diff --git a/app/presenters/README.md b/app/presenters/README.md index e2461580107..5b600e8f2b2 100644 --- a/app/presenters/README.md +++ b/app/presenters/README.md @@ -165,15 +165,15 @@ however, there is a risk that it accidentally overrides important logic. For example, [this production incident](https://gitlab.com/gitlab-com/gl-infra/production/-/issues/5498) was caused by [including `ActionView::Helpers::UrlHelper` in a presenter](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/69537/diffs#4b581cff00ef3cc9780efd23682af383de302e7d_3_3). -The `tag` accesor in `Ci::Build` was accidentally overridden by `ActionView::Helpers::TagHelper#tag`, -and as a conseuqence, a wrong `tag` value was persited into database. +The `tag` accessor in `Ci::Build` was accidentally overridden by `ActionView::Helpers::TagHelper#tag`, +and as a consequence, a wrong `tag` value was persisted into database. -Starting from GitLab 14.4, we validate the presenters (specifically all of the subclasses of `Gitlab::View::Presenter::Delegated`) +Starting from GitLab 14.4, we [validate](../../lib/gitlab/utils/delegator_override/validator.rb) the presenters (specifically all of the subclasses of `Gitlab::View::Presenter::Delegated`) that they do not accidentally override core/backend logic. In such case, a pipeline in merge requests fails with an error message, here is an example: ```plaintext -We've detected that a presetner is overriding a specific method(s) on a subject model. +We've detected that a presenter is overriding a specific method(s) on a subject model. There is a risk that it accidentally modifies the backend/core logic that leads to production incident. Please follow https://gitlab.com/gitlab-org/gitlab/-/blob/master/app/presenters/README.md#validate-accidental-overrides to resolve this error with caution. @@ -193,7 +193,7 @@ Here are the potential solutions: ### How to use the `Gitlab::Utils::DelegatorOverride` validator -If a presenter class inhertis from `Gitlab::View::Presenter::Delegated`, +If a presenter class inherits from `Gitlab::View::Presenter::Delegated`, you should define what object class is presented: ```ruby @@ -201,7 +201,7 @@ class WebHookLogPresenter < Gitlab::View::Presenter::Delegated presents ::WebHookLog, as: :web_hook_log # This defines that the presenter presents `WebHookLog` Active Record model. ``` -These presenters are validated not to accidentaly override the methods in the presented object. +These presenters are validated not to accidentally override the methods in the presented object. You can run the validation locally with: ```shell diff --git a/app/presenters/ci/build_runner_presenter.rb b/app/presenters/ci/build_runner_presenter.rb index 9a586a1733f..5da0655d21a 100644 --- a/app/presenters/ci/build_runner_presenter.rb +++ b/app/presenters/ci/build_runner_presenter.rb @@ -58,7 +58,7 @@ module Ci # rubocop: disable CodeReuse/ActiveRecord def all_dependencies dependencies = super - ActiveRecord::Associations::Preloader.new.preload(dependencies, :job_artifacts_archive) + ActiveRecord::Associations::Preloader.new(records: dependencies, associations: :job_artifacts_archive).call dependencies end # rubocop: enable CodeReuse/ActiveRecord |