mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2024-09-20 06:35:56 +08:00
Merge pull request #2679 from urbanrotnik/ur-sci-4741-api-endopints-update
Filter out non active repositories and rows [SCI-4741]
This commit is contained in:
commit
e1b862a332
|
@ -11,6 +11,7 @@ module Api
|
|||
|
||||
def index
|
||||
inventories = @team.repositories
|
||||
.active
|
||||
.page(params.dig(:page, :number))
|
||||
.per(params.dig(:page, :size))
|
||||
render jsonapi: inventories, each_serializer: InventorySerializer
|
||||
|
|
|
@ -13,6 +13,7 @@ module Api
|
|||
def index
|
||||
items =
|
||||
@inventory.repository_rows
|
||||
.active
|
||||
.preload(repository_cells: :repository_column)
|
||||
.preload(repository_cells: @inventory.cell_preload_includes)
|
||||
.page(params.dig(:page, :number))
|
||||
|
|
|
@ -46,6 +46,21 @@ RSpec.describe 'Api::V1::InventoriesController', type: :request do
|
|||
expect { hash_body = json }.not_to raise_exception
|
||||
expect(hash_body['errors'][0]).to include('status': 403)
|
||||
end
|
||||
|
||||
context 'when have some archived inventories' do
|
||||
before do
|
||||
create(:repository, :archived, name: Faker::Name.unique.name, created_by: @user, team: @teams.first)
|
||||
end
|
||||
|
||||
it 'will ignore them' do
|
||||
hash_body = nil
|
||||
|
||||
get api_v1_team_inventories_path(team_id: @teams.first.id), headers: @valid_headers
|
||||
|
||||
expect { hash_body = json }.not_to raise_exception
|
||||
expect(hash_body['data'].count).to be_eql 2
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe 'GET inventory, #show' do
|
||||
|
|
|
@ -50,7 +50,7 @@ RSpec.describe 'Api::V1::InventoryItemsController', type: :request do
|
|||
attributes: {
|
||||
name: Faker::Name.unique.name
|
||||
} },
|
||||
included: [
|
||||
included: [
|
||||
{ type: 'inventory_cells',
|
||||
attributes: {
|
||||
column_id: text_column.id,
|
||||
|
@ -150,6 +150,25 @@ RSpec.describe 'Api::V1::InventoryItemsController', type: :request do
|
|||
expect { hash_body = json }.not_to raise_exception
|
||||
expect(hash_body['errors'][0]).to include('status': 404)
|
||||
end
|
||||
|
||||
context 'when have some archived rows' do
|
||||
before do
|
||||
create(:repository_row, :archived,
|
||||
name: Faker::Name.unique.name, created_by: @user, repository: @teams.first.repositories.first)
|
||||
end
|
||||
|
||||
it 'will ignore them' do
|
||||
hash_body = nil
|
||||
|
||||
get api_v1_team_inventory_items_path(
|
||||
team_id: @teams.first.id,
|
||||
inventory_id: @teams.first.repositories.first.id
|
||||
), params: { page: { size: 200 } }, headers: @valid_headers
|
||||
|
||||
expect { hash_body = json }.not_to raise_exception
|
||||
expect(hash_body['data'].count).to be_eql 100
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe 'DELETE inventory_items, #destroy' do
|
||||
|
|
Loading…
Reference in a new issue