Merge pull request #1301 from okriuchykhin/ok_SCI_2693_v2

Fix CREATE inventory endpoint [SCI-2693]
This commit is contained in:
Alex Kriuchykhin 2018-09-24 10:51:13 +02:00 committed by GitHub
commit b38e85c282
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -5,7 +5,7 @@ module Api
class InventoriesController < BaseController
before_action :load_team
before_action :load_inventory, only: %i(show update destroy)
before_action :check_manage_permissions, only: %i(create update destroy)
before_action :check_manage_permissions, only: %i(update destroy)
def index
inventories = @team.repositories
@ -15,7 +15,12 @@ module Api
end
def create
inventory = @team.repositories.create!(inventory_params)
unless can_create_repositories?(@team)
return render body: nil, status: :forbidden
end
inventory = @team.repositories.create!(
inventory_params.merge(created_by: current_user)
)
render jsonapi: inventory,
serializer: InventorySerializer,
status: :created