Assign Suites button still visible when no possible suites to assign
In suite selection, if there are no available suites of a certain size for the current group selecting, you will see this message:
There are not enough suites of size <%= group.size %> available. You must disband a group to proceed and its members will have to regroup following this draw.
In this case you should either disband the group or go Back To Draw to figure it out. Yet the 'Assign suites' button is still present and if clicked will cause a ParameterMissing Error because no form is submitted.
Ideally if there are no suites available to assign, there should be no 'Assign suites' button to click.
This requires a policy guard to be put on the Assign suites
button in app/views/suite_assignments/_form.html.erb
that contains the same logic that we use to display the There are not enough suites of size ...
text.
Therefore,
- Update the suite_assignments#create policy to contain this logic
- Add this logic to two spots in the
_form.html.erb
- once as a replacement for theThere are not enough suites of size ...
logic and again around the "Assign Suites" button
Tests-
- Test the updated policy changes
- Write a view spec that tests that this button no longer shows when there are no suites left to assign