Refactor consumer factory
This commit is contained in:

committed by
Sebastian Serth

parent
6ad5274e67
commit
e3018c1847
@ -3,12 +3,15 @@
|
||||
FactoryBot.define do
|
||||
factory :consumer do
|
||||
name { 'openHPI' }
|
||||
oauth_key { SecureRandom.hex }
|
||||
oauth_secret { SecureRandom.hex }
|
||||
singleton_consumer
|
||||
end
|
||||
|
||||
trait :singleton_consumer do
|
||||
initialize_with { Consumer.where(name: name).first_or_create }
|
||||
initialize_with do
|
||||
Consumer.find_or_initialize_by(name: name) do |consumer|
|
||||
consumer.oauth_key = SecureRandom.hex
|
||||
consumer.oauth_secret = SecureRandom.hex
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Reference in New Issue
Block a user