docbrown/spec/factories/suspended_usernames.rb
Michael Kohl 0af8fc1866
Prevent suspended users from self-deleting and returning (#12503)
* Add new table and model

* Store banned user username hash on delete

* Prevent previously banned user from signing up again

* Update method name

* Refactor code and add more specs

* Test improvements

* Don't override existing global flash

* Fix typo

* Update spec description

* Update schema.rb

* More schema.rb fixes

* Simplify spec

* Update migration

* Clean up migration

* Rename method

* Add DataDog counter

* Revisit error handling

* Remove spurious empty line

* Make model name more explicit
2021-02-11 09:28:59 +07:00

11 lines
309 B
Ruby

FactoryBot.define do
factory :suspended_username, class: "Users::SuspendedUsername" do
transient do
username { Faker::Internet.unique.username }
end
after(:build) do |user, evaluator|
user.username_hash = Users::SuspendedUsername.hash_username(evaluator.username)
end
end
end