Merge branch 'mc-SCI-2704' of https://github.com/czbiohub/scinote-web-1 into czbiohub-mc-SCI-2704

Conflicts:
	spec/requests/api/v1/inventories_controller_spec.rb
This commit is contained in:
Luka Murn 2018-10-01 11:53:47 +02:00
commit 548cfb65e1

View file

@ -254,4 +254,36 @@ RSpec.describe "Api::V1::InventoriesController", type: :request do
expect(hash_body).to match({})
end
end
describe 'DELETE inventories, #destroy' do
it 'Destroys inventory' do
deleted_id = @teams.first.repositories.last.id
delete api_v1_team_inventory_path(
id: deleted_id,
team_id: @teams.first.id
), headers: @valid_headers
expect(response).to have_http_status(200)
expect(Repository.where(id: deleted_id)).to_not exist
expect(RepositoryRow.where(repository: deleted_id).count).to equal 0
expect(RepositoryColumn.where(repository: deleted_id).count).to equal 0
end
it 'Invalid request, non existing inventory' do
delete api_v1_team_inventory_path(
id: 123,
team_id: @teams.first.id
), headers: @valid_headers
expect(response).to have_http_status(404)
end
it 'When invalid request, repository from another team' do
deleted_id = @teams.first.repositories.last.id
delete api_v1_team_inventory_path(
id: deleted_id,
team_id: @teams.second.id
), headers: @valid_headers
expect(response).to have_http_status(403)
expect(Repository.where(id: deleted_id)).to exist
end
end
end