1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2024-12-01 12:24:28 +01:00
fab-manager/test/integration/availabilities/update_test.rb
2023-03-22 10:58:22 +01:00

37 lines
924 B
Ruby

# frozen_string_literal: true
require 'test_helper'
# module definition
module Availabilities; end
class Availabilities::UpdateTest < ActionDispatch::IntegrationTest
setup do
admin = User.with_role(:admin).first
login_as(admin, scope: :user)
end
test 'update an availability to remove an associated machine' do
availability = Availability.find(4)
machine = Machine.find(2)
patch "/api/availabilities/#{availability.id}",
params: {
availability: {
machines_attributes: [
{ id: machine.id, _destroy: true }
]
}
}
assert_response :success
assert_match Mime[:json].to_s, response.content_type
res = json_response(response.body)
assert_not_includes res[:machine_ids], machine.id
availability.reload
assert_empty availability.machines_availabilities.where(machine: machine)
end
end