diff options
author | Jarka Kadlecova <jarka@gitlab.com> | 2017-08-08 09:41:27 +0200 |
---|---|---|
committer | Jarka Kadlecova <jarka@gitlab.com> | 2017-08-08 12:43:55 +0200 |
commit | 947c09c2a6f8cc9c4b3606efb326aa4912095e7d (patch) | |
tree | 525e28346942d9bd857a9d17dc671243ea9d360f /app/workers/concerns | |
parent | 9e7ac48bc11141762816f157247baaf9e61618b3 (diff) | |
download | gitlab-ce-947c09c2a6f8cc9c4b3606efb326aa4912095e7d.tar.gz |
Simplify checking if objects exist code in new issaubles workers36119-issuable-workers
Diffstat (limited to 'app/workers/concerns')
-rw-r--r-- | app/workers/concerns/new_issuable.rb | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/app/workers/concerns/new_issuable.rb b/app/workers/concerns/new_issuable.rb index 3fd472bf0c1..eb0d6c9c36c 100644 --- a/app/workers/concerns/new_issuable.rb +++ b/app/workers/concerns/new_issuable.rb @@ -1,20 +1,23 @@ module NewIssuable attr_reader :issuable, :user - def ensure_objects_found(issuable_id, user_id) - @issuable = issuable_class.find_by(id: issuable_id) - unless @issuable - log_error(issuable_class, issuable_id) - return false - end + def objects_found?(issuable_id, user_id) + set_user(user_id) + set_issuable(issuable_id) + + user && issuable + end + def set_user(user_id) @user = User.find_by(id: user_id) - unless @user - log_error(User, user_id) - return false - end - true + log_error(User, user_id) unless @user + end + + def set_issuable(issuable_id) + @issuable = issuable_class.find_by(id: issuable_id) + + log_error(issuable_class, issuable_id) unless @issuable end def log_error(record_class, record_id) |