mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-10-09 21:36:44 +08:00
Filter out non active repositories and rows
This commit is contained in:
parent
30de400cf9
commit
c565cbe579
4 changed files with 37 additions and 1 deletions
|
@ -11,6 +11,7 @@ module Api
|
||||||
|
|
||||||
def index
|
def index
|
||||||
inventories = @team.repositories
|
inventories = @team.repositories
|
||||||
|
.active
|
||||||
.page(params.dig(:page, :number))
|
.page(params.dig(:page, :number))
|
||||||
.per(params.dig(:page, :size))
|
.per(params.dig(:page, :size))
|
||||||
render jsonapi: inventories, each_serializer: InventorySerializer
|
render jsonapi: inventories, each_serializer: InventorySerializer
|
||||||
|
|
|
@ -13,6 +13,7 @@ module Api
|
||||||
def index
|
def index
|
||||||
items =
|
items =
|
||||||
@inventory.repository_rows
|
@inventory.repository_rows
|
||||||
|
.active
|
||||||
.preload(repository_cells: :repository_column)
|
.preload(repository_cells: :repository_column)
|
||||||
.preload(repository_cells: @inventory.cell_preload_includes)
|
.preload(repository_cells: @inventory.cell_preload_includes)
|
||||||
.page(params.dig(:page, :number))
|
.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 = json }.not_to raise_exception
|
||||||
expect(hash_body['errors'][0]).to include('status': 403)
|
expect(hash_body['errors'][0]).to include('status': 403)
|
||||||
end
|
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
|
end
|
||||||
|
|
||||||
describe 'GET inventory, #show' do
|
describe 'GET inventory, #show' do
|
||||||
|
|
|
@ -150,6 +150,25 @@ RSpec.describe 'Api::V1::InventoryItemsController', type: :request do
|
||||||
expect { hash_body = json }.not_to raise_exception
|
expect { hash_body = json }.not_to raise_exception
|
||||||
expect(hash_body['errors'][0]).to include('status': 404)
|
expect(hash_body['errors'][0]).to include('status': 404)
|
||||||
end
|
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
|
end
|
||||||
|
|
||||||
describe 'DELETE inventory_items, #destroy' do
|
describe 'DELETE inventory_items, #destroy' do
|
||||||
|
|
Loading…
Add table
Reference in a new issue