From 005749a616c19b90d6ec0415df9ae5e35151e33c Mon Sep 17 00:00:00 2001 From: Tiago Botelho Date: Wed, 1 Mar 2017 16:59:03 +0000 Subject: apply codestyle and implementation changes to the respective feature code --- .../admin/impersonation_tokens_controller.rb | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) (limited to 'app/controllers/admin') diff --git a/app/controllers/admin/impersonation_tokens_controller.rb b/app/controllers/admin/impersonation_tokens_controller.rb index 448f2c881a1..d26004539b5 100644 --- a/app/controllers/admin/impersonation_tokens_controller.rb +++ b/app/controllers/admin/impersonation_tokens_controller.rb @@ -1,12 +1,12 @@ class Admin::ImpersonationTokensController < Admin::ApplicationController - before_action :user, :finder + before_action :user def index set_index_vars end def create - @impersonation_token = finder.execute.build(impersonation_token_params) + @impersonation_token = finder.build(impersonation_token_params) if @impersonation_token.save flash[:impersonation_token] = @impersonation_token.token @@ -18,7 +18,7 @@ class Admin::ImpersonationTokensController < Admin::ApplicationController end def revoke - @impersonation_token = finder.execute(id: params[:id]) + @impersonation_token = finder.find(params[:id]) if @impersonation_token.revoke! flash[:notice] = "Revoked impersonation token #{@impersonation_token.name}!" @@ -35,8 +35,8 @@ class Admin::ImpersonationTokensController < Admin::ApplicationController @user ||= User.find_by!(username: params[:user_id]) end - def finder - @finder ||= PersonalAccessTokensFinder.new(user: user, impersonation: true) + def finder(options = {}) + PersonalAccessTokensFinder.new({ user: user, impersonation: true }.merge(options)) end def impersonation_token_params @@ -44,12 +44,10 @@ class Admin::ImpersonationTokensController < Admin::ApplicationController end def set_index_vars - finder.params[:state] = 'active' - @impersonation_token ||= finder.execute.build @scopes = Gitlab::Auth::SCOPES - finder.params[:order] = :expires_at - @active_impersonation_tokens = finder.execute - finder.params[:state] = 'inactive' - @inactive_impersonation_tokens = finder.execute + + @impersonation_token ||= finder.build + @inactive_impersonation_tokens = finder(state: 'inactive').execute + @active_impersonation_tokens = finder(state: 'active').execute.order(:expires_at) end end -- cgit v1.2.1