The test was failing because a validation was failing on the
authorization generated by find_or_create_by_client_id. The reason is
that you validate_presence_of :client, but you are doing
find_or_create_by_client_id, so the :client attribute is not set and
validation fails.
Solution is to just set the client and owner in the find_or_create block
that ActiveRecord provides.
The test was failing because a validation was failing on the authorization generated by find_or_create_by_client_id. The reason is that you validate_presence_of :client, but you are doing find_or_create_by_client_id, so the :client attribute is not set and validation fails.
Solution is to just set the client and owner in the find_or_create block that ActiveRecord provides.