Unable to remove host collection from activation key via hammer
Cloned from https://bugzilla.redhat.com/show_bug.cgi?id=1336716
Description of problem:
Can't remove host collection from activation key using hammer - operation succeeds but host collection remains associated.
Version-Release number of selected component (if applicable):
Sat 6.2.0 GA SNAP11
Steps to Reproduce:
1. Associate host collection with activation key.
2. Try to remove host collection from activation key via 'hammer activation-key remove-host-collection' command.
3. Check whether host collection was actually removed.
remove-host-collection command succeeds, but host collection remains associated:
2016-05-17 12:33:07 - robottelo.ssh - DEBUG - >>> [dell-t320-01.khw.lab.eng.bos.redhat.com] LANG=en_US.UTF-8 hammer -v -u admin -p changeme activation-key remove-host-collection --host-collection-id="1" --name="v6ncdpkpdL" --organization="X25dny"
2016-05-17 12:33:13 - robottelo.ssh - DEBUG - <<< stdout
The host collection has been removed
2016-05-17 12:33:13 - robottelo.ssh - DEBUG - >>> [dell-t320-01.khw.lab.eng.bos.redhat.com] LANG=en_US.UTF-8 hammer -v -u admin -p changeme activation-key info --id="1"
2016-05-17 12:33:18 - robottelo.ssh - DEBUG - <<< stdout
Host Limit: Unlimited
Auto Attach: true
1) ID: 1
Host collection should be removed from activation key.
Also some validation for `activation-key remove-host-collection` command should be present - it shouldn't say 'The host collection has been removed' and finish with 0 return code when operation's failed.
Works as expected via UI (and, basically, 'activation-key info' reflects the changes, so it's an issue with `activation-key remove-host-collection`, not `activation-key info` command)
Fixes #15162 - Host collections can be removed (#6063)
Allow the last host collection to be removed from an activation key.
This issue is caused by the deep_munge method in Rails 4. We use our API
to GET a record, update a collection of children, then PUT the updated
record to the API in order to update the DB. If the collection of
children is empty, deep munge in conjunction with strong parameters,
translates the empty array into nil, and the collection of children
This fix is a workaround and should be removed when upgrading Foretello
to Rails 5. I made a comment containing "Rails 5" so it can be addressed
during the upgrade with a global find.
Add a test for removing all host collections from an activation key.