devise_invitable icon indicating copy to clipboard operation
devise_invitable copied to clipboard

Inviting a new user with identical params is wrongly `persisted`

Open Kosmin opened this issue 7 years ago • 1 comments

Inviting a new user with identical params wrongly returns .persisted? true but created_at nil

attributes = {
  name: 'Cosmin',
  email: '[email protected]'
}

first_user = User.invite!(attributes)

puts first_user.persisted? # => true
puts first_user.created_at # => Wed, 29 Mar 2017 11:42:46 -0700

# let's try inviting the same user
second_user = User.invite!(attributes)

puts second_user.persisted? # => true
puts second_user.created_at # => nil ?!

This looks like a bug, because the second_user was not persisted, since it wasn't actually saved, yet persisted? returns true. If a new user hasn't been added to the database, then second_user.persisted? shouldn't return true.

Kosmin avatar Mar 29 '17 18:03 Kosmin

Could you post sql queries or send pull request with failing test? I can't reproduce it

scambra avatar Mar 30 '17 11:03 scambra