Skip to content

Commit

Permalink
[434] fix error when account not found
Browse files Browse the repository at this point in the history
  • Loading branch information
moklidia committed Jun 30, 2023
1 parent 00377dd commit 46b1123
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ def index
# @response [object<account: <object<id: integer, name: string, projects: Array<object<id: integer, slug: string>>>> >] 200 OK
# @response 401 Not authorized
def show
raise ActiveRecord::NotFound if resource_account.blank?

respond_with resource_account
end

Expand All @@ -38,6 +36,10 @@ def policy_context
end

def resource_account
@resource_account ||= current_user.accounts.find_by(name: params[:name])
@resource_account ||= if params[:name]
current_user.accounts.find_by!(name: params[:name])
else
current_user.default_account
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,8 @@ class UffizziCore::Api::Cli::V1::AccountsControllerTest < ActionController::Test
end

test '#show' do
account = @user.personal_account
get :show, params: { name: 'wrong' }, format: :json

get :show, params: { name: account.name }, format: :json

assert_response(:success)
assert_response(:not_found)
end
end

0 comments on commit 46b1123

Please sign in to comment.