From addf4cfe5e7b9c5e9ff548786244452470cfa96b Mon Sep 17 00:00:00 2001 From: Oleksii Kriuchykhin Date: Mon, 14 May 2018 15:34:23 +0200 Subject: [PATCH] Handle situation with smart annotations and zero inventories [SCI-2396] --- app/controllers/at_who_controller.rb | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/app/controllers/at_who_controller.rb b/app/controllers/at_who_controller.rb index 62ff98f85..beed49ab9 100644 --- a/app/controllers/at_who_controller.rb +++ b/app/controllers/at_who_controller.rb @@ -30,13 +30,18 @@ class AtWhoController < ApplicationController end def rep_items - res = SmartAnnotation.new(current_user, current_team, @query) repository = Repository.find_by_id(params[:repository_id]) - render_403 && return unless repository && can_read_team?(repository.team) + items = + if repository && can_read_team?(repository.team) + SmartAnnotation.new(current_user, current_team, @query) + .repository_rows(repository) + else + [] + end respond_to do |format| format.json do render json: { - res: res.repository_rows(repository), + res: items, status: :ok } end