Merge pull request #1320 from biosistemika/lm-mc-sci-2697

UPDATE Inventory item endpoint - unit tests [SCI-2697] (v2)
This commit is contained in:
Luka Murn 2018-10-11 15:20:37 +02:00 committed by GitHub
commit 2b7a94025e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -245,4 +245,30 @@ RSpec.describe 'Api::V1::InventoryItemsController', type: :request do
expect(hash_body).to match({})
end
end
describe 'PATCH inventory_items, #update' do
before :all do
@valid_headers['Content-Type'] = 'application/json'
@inventory_item = ActiveModelSerializers::SerializableResource.new(
RepositoryRow.last,
serializer: Api::V1::InventoryItemSerializer,
include: :inventory_cells
)
end
it 'Response with correctly updated inventory item for name field' do
hash_body = nil
updated_inventory_item = @inventory_item.as_json[:data]
updated_inventory_item[:attributes][:name] = Faker::Name.unique.name
patch api_v1_team_inventory_item_path(
id: RepositoryRow.last.id,
team_id: @teams.first.id,
inventory_id: @valid_inventory.id
), params: { data: updated_inventory_item }.to_json,
headers: @valid_headers
expect(response).to have_http_status 200
expect { hash_body = json }.not_to raise_exception
expect(hash_body[:data].to_json).to match(updated_inventory_item.to_json)
end
end
end