mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-01-31 20:19:05 +08:00
merge core-api and handle merge issues
This commit is contained in:
parent
3a2740604d
commit
2f99904000
1 changed files with 74 additions and 0 deletions
|
@ -259,4 +259,78 @@ RSpec.describe 'Api::V1::InventoryColumnsController', type: :request do
|
|||
expect(RepositoryColumn.where(id: deleted_id)).to exist
|
||||
end
|
||||
end
|
||||
|
||||
describe 'PATCH inventory_column, #update' do
|
||||
before :all do
|
||||
@valid_headers['Content-Type'] = 'application/json'
|
||||
@inventory_column = ActiveModelSerializers::SerializableResource.new(
|
||||
RepositoryColumn.last,
|
||||
serializer: Api::V1::InventoryColumnSerializer
|
||||
)
|
||||
end
|
||||
|
||||
it 'Response with correctly updated inventory column' do
|
||||
hash_body = nil
|
||||
updated_inventory_column = @inventory_column.as_json
|
||||
updated_inventory_column[:data][:attributes][:name] =
|
||||
Faker::Name.unique.name
|
||||
patch api_v1_team_inventory_column_path(
|
||||
id: RepositoryColumn.last.id,
|
||||
team_id: @teams.first.id,
|
||||
inventory_id: @teams.first.repositories.first.id
|
||||
), params: updated_inventory_column.to_json,
|
||||
headers: @valid_headers
|
||||
expect(response).to have_http_status 200
|
||||
expect { hash_body = json }.not_to raise_exception
|
||||
expect(hash_body.to_json).to match(updated_inventory_column.to_json)
|
||||
end
|
||||
|
||||
it 'Invalid request, wrong team' do
|
||||
hash_body = nil
|
||||
updated_inventory_column = @inventory_column.as_json
|
||||
updated_inventory_column[:data][:attributes][:name] =
|
||||
Faker::Name.unique.name
|
||||
patch api_v1_team_inventory_column_path(
|
||||
id: RepositoryColumn.last.id,
|
||||
team_id: @teams.second.id,
|
||||
inventory_id: @teams.first.repositories.first.id
|
||||
), params: updated_inventory_column.to_json,
|
||||
headers: @valid_headers
|
||||
expect(response).to have_http_status 403
|
||||
expect { hash_body = json }.not_to raise_exception
|
||||
expect(hash_body).to match({})
|
||||
end
|
||||
|
||||
it 'Invalid request, wrong inventory' do
|
||||
hash_body = nil
|
||||
updated_inventory_column = @inventory_column.as_json
|
||||
updated_inventory_column[:data][:attributes][:name] =
|
||||
Faker::Name.unique.name
|
||||
patch api_v1_team_inventory_column_path(
|
||||
id: RepositoryColumn.last.id,
|
||||
team_id: @teams.second.id,
|
||||
inventory_id: @teams.second.repositories.first.id
|
||||
), params: updated_inventory_column.to_json,
|
||||
headers: @valid_headers
|
||||
expect(response).to have_http_status 403
|
||||
expect { hash_body = json }.not_to raise_exception
|
||||
expect(hash_body).to match({})
|
||||
end
|
||||
|
||||
it 'Invalid request, non-existent inventory' do
|
||||
hash_body = nil
|
||||
updated_inventory_column = @inventory_column.as_json
|
||||
updated_inventory_column[:data][:attributes][:name] =
|
||||
Faker::Name.unique.name
|
||||
patch api_v1_team_inventory_column_path(
|
||||
id: RepositoryColumn.last.id,
|
||||
team_id: @teams.first.id,
|
||||
inventory_id: 123
|
||||
), params: updated_inventory_column.to_json,
|
||||
headers: @valid_headers
|
||||
expect(response).to have_http_status 404
|
||||
expect { hash_body = json }.not_to raise_exception
|
||||
expect(hash_body).to match({})
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue