diff options
author | Grzegorz Bizon <grzegorz@gitlab.com> | 2018-05-17 14:36:27 +0000 |
---|---|---|
committer | Grzegorz Bizon <grzegorz@gitlab.com> | 2018-05-17 14:36:27 +0000 |
commit | d9b78477000dafc4f8b8fd7e795e97649b8c6718 (patch) | |
tree | 76c45f0e0824269e146d6588380e91e093b2266c /app | |
parent | 2eb8099fb752a6fe4c751f739c2b5520d450ad4c (diff) | |
parent | 22d3e90ced30532ede17509d373c2e88257a7fe1 (diff) | |
download | gitlab-ce-d9b78477000dafc4f8b8fd7e795e97649b8c6718.tar.gz |
Merge branch '46177-fix-present-on-generic-commit-status' into 'master'
Resolve "NoMethodError: undefined method `present' for #<GenericCommitStatus:0x00007f6eacf34a40>"
Closes #46177
See merge request gitlab-org/gitlab-ce!18979
Diffstat (limited to 'app')
-rw-r--r-- | app/models/commit_status.rb | 1 | ||||
-rw-r--r-- | app/presenters/ci/build_presenter.rb | 25 | ||||
-rw-r--r-- | app/presenters/commit_status_presenter.rb | 24 | ||||
-rw-r--r-- | app/presenters/generic_commit_status_presenter.rb | 2 |
4 files changed, 28 insertions, 24 deletions
diff --git a/app/models/commit_status.rb b/app/models/commit_status.rb index 97d89422594..a7d05722287 100644 --- a/app/models/commit_status.rb +++ b/app/models/commit_status.rb @@ -2,6 +2,7 @@ class CommitStatus < ActiveRecord::Base include HasStatus include Importable include AfterCommitQueue + include Presentable self.table_name = 'ci_builds' diff --git a/app/presenters/ci/build_presenter.rb b/app/presenters/ci/build_presenter.rb index 4873d7ce662..e0aaa5cb736 100644 --- a/app/presenters/ci/build_presenter.rb +++ b/app/presenters/ci/build_presenter.rb @@ -1,16 +1,5 @@ module Ci - class BuildPresenter < Gitlab::View::Presenter::Delegated - CALLOUT_FAILURE_MESSAGES = { - unknown_failure: 'There is an unknown failure, please try again', - script_failure: 'There has been a script failure. Check the job log for more information', - api_failure: 'There has been an API failure, please try again', - stuck_or_timeout_failure: 'There has been a timeout failure or the job got stuck. Check your timeout limits or try again', - runner_system_failure: 'There has been a runner system failure, please try again', - missing_dependency_failure: 'There has been a missing dependency failure, check the job log for more information' - }.freeze - - presents :build - + class BuildPresenter < CommitStatusPresenter def erased_by_user? # Build can be erased through API, therefore it does not have # `erased_by` user assigned in that case. @@ -44,14 +33,6 @@ module Ci "#{subject.name} - #{detailed_status.status_tooltip}" end - def callout_failure_message - CALLOUT_FAILURE_MESSAGES[failure_reason.to_sym] - end - - def recoverable? - failed? && !unrecoverable? - end - private def tooltip_for_badge @@ -61,9 +42,5 @@ module Ci def detailed_status @detailed_status ||= subject.detailed_status(user) end - - def unrecoverable? - script_failure? || missing_dependency_failure? - end end end diff --git a/app/presenters/commit_status_presenter.rb b/app/presenters/commit_status_presenter.rb new file mode 100644 index 00000000000..c7f7aa836bd --- /dev/null +++ b/app/presenters/commit_status_presenter.rb @@ -0,0 +1,24 @@ +class CommitStatusPresenter < Gitlab::View::Presenter::Delegated + CALLOUT_FAILURE_MESSAGES = { + unknown_failure: 'There is an unknown failure, please try again', + script_failure: 'There has been a script failure. Check the job log for more information', + api_failure: 'There has been an API failure, please try again', + stuck_or_timeout_failure: 'There has been a timeout failure or the job got stuck. Check your timeout limits or try again', + runner_system_failure: 'There has been a runner system failure, please try again', + missing_dependency_failure: 'There has been a missing dependency failure, check the job log for more information' + }.freeze + + presents :build + + def callout_failure_message + CALLOUT_FAILURE_MESSAGES[failure_reason.to_sym] + end + + def recoverable? + failed? && !unrecoverable? + end + + def unrecoverable? + script_failure? || missing_dependency_failure? + end +end diff --git a/app/presenters/generic_commit_status_presenter.rb b/app/presenters/generic_commit_status_presenter.rb new file mode 100644 index 00000000000..da09df29a37 --- /dev/null +++ b/app/presenters/generic_commit_status_presenter.rb @@ -0,0 +1,2 @@ +class GenericCommitStatusPresenter < CommitStatusPresenter +end |