alphagov/signonotron2 — pull request #11 by jamiecobbett (2012-08-30 11:08:15+00:00)
Title: Prevent errors from inviting a user twice

This fix catches the scenario where you are attempting to invite an existing user and it fails ungracefully because it attempts to create duplicate permissions.

Unfortunately, accepts_nested_attributes doesn't pick up on existing records unless it is given their IDs, so it was trying to create duplicate permissions when updating an existing user.

The changes could resend the invitation email, but I imagine the admin is probably unaware they exist, so it's probably better not to confuse the new user with multiple emails.

Problem is very similar/related to that fixed by: 98a119665aedb16efa6613b0625a95c063ddcc2d