From 54474b2bba7d7d916b3790683440e5ab39abca27 Mon Sep 17 00:00:00 2001 From: ajugo Date: Tue, 19 Apr 2022 16:05:17 +0200 Subject: [PATCH] API GET repository stock column output fix [SCI-6550] (#4030) * Add include stock unit items to Stock column get [SCI-6550] * Fix stock column test [SCI-6550] * Fix hound [SCI-6550] --- app/controllers/api/v1/inventory_columns_controller.rb | 2 +- config/initializers/extends.rb | 2 +- spec/requests/api/v1/inventory_columns_controller_spec.rb | 7 ++++--- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/app/controllers/api/v1/inventory_columns_controller.rb b/app/controllers/api/v1/inventory_columns_controller.rb index 600a040db..a1221f596 100644 --- a/app/controllers/api/v1/inventory_columns_controller.rb +++ b/app/controllers/api/v1/inventory_columns_controller.rb @@ -34,7 +34,7 @@ module Api def show render jsonapi: @inventory_column, serializer: InventoryColumnSerializer, - include: :inventory_list_items + include: %i(inventory_list_items repository_stock_unit_items) end def update diff --git a/config/initializers/extends.rb b/config/initializers/extends.rb index bdf5db741..18fe2f59f 100644 --- a/config/initializers/extends.rb +++ b/config/initializers/extends.rb @@ -165,7 +165,7 @@ class Extends 'RepositoryChecklistValue' => 'checklist', 'RepositoryAssetValue' => 'file', 'RepositoryStatusValue' => 'status', - 'RepositoryStockValue' => 'stock_value' } + 'RepositoryStockValue' => 'stock' } OMNIAUTH_PROVIDERS = %i(linkedin customazureactivedirectory okta) diff --git a/spec/requests/api/v1/inventory_columns_controller_spec.rb b/spec/requests/api/v1/inventory_columns_controller_spec.rb index 80819a9da..3b21490e6 100644 --- a/spec/requests/api/v1/inventory_columns_controller_spec.rb +++ b/spec/requests/api/v1/inventory_columns_controller_spec.rb @@ -235,7 +235,7 @@ RSpec.describe 'Api::V1::InventoryColumnsController', type: :request do { type: 'inventory_columns', attributes: { name: Faker::Name.unique.name, - data_type: 'stock_value', + data_type: 'stock', metadata: { decimals: 3 } @@ -434,8 +434,9 @@ RSpec.describe 'Api::V1::InventoryColumnsController', type: :request do team_id: @teams.first.id, inventory_id: @teams.first.repositories.second.id ), headers: @valid_headers - expect(response).to have_http_status(400) - expect(RepositoryColumn.where(id: deleted_id)).to exist + expect(response).to have_http_status(200) + expect(RepositoryColumn.where(id: deleted_id)).to_not exist + expect(RepositoryCell.where(repository_column: deleted_id).count).to equal 0 end end