MidnightRiders / MemberPortal

Members-only application for the Midnight Riders
MIT License
2 stars 0 forks source link

Fix bug persisting old card; fix bbug ontinuing after error; add ErrorNotifier service #38

Closed bensaufley closed 7 years ago

bensaufley commented 7 years ago

37 revealed that we were trying to charge an old card if a user added a new card and purchased a membership: it went like this:

The next issue is that rather than seeing the error, users were being allowed to continue. We were even getting notified of new memberships. This is because validation would be re-applied with save! so the error we added to :base with the StripeError got wiped out and everything went along just fine. I've removed the catch that caught the StripeError and applied a :base error; now the StripeError bubbles up to the save! call, which in turn bubbles up to the Controller, which catches it and redisplays the "new" page. Still need more feature specs there, but just our luck we've had three people today stumble across this bug so let's get this in.

Also added an ErrorNotifier service (with specs!) since we're doing the same few things almost everywhere and this will let us do more with errors in the future if we want. For now it just extracts a few lines of repeated code. Should be applied throughout.