oaken icon indicating copy to clipboard operation
oaken copied to clipboard

Race condition when used with Faker

Open ahmgeek opened this issue 5 months ago • 3 comments

Good work overall with the Oaken. Although I am sure I am using it in a twisted way, but this Code results in a race condition:

# Create some users and asooociated articles

require "faker"

puts "Creating users..."

20.times do |i|
  puts "Creating user #{i + 1}"

  User.create!(
      email: Faker::Internet.unique.email,
      name: Faker::Name.unique.name[0..20],
      bio: Faker::Lorem.paragraph[0..200],
      last_sign_in_at: Time.zone.now,
      slug: Faker::Internet.unique.slug[0..20],
      confirmed: true,
      featured: false,
      avatar: Rails.root.join("spec", "fixtures", "files", "avatar-#{rand(1..6)}.jpeg").open
  )
end

When I read the code I realized I am using it wrong. But just in case this helps with the development, the error is with the file uploading, it randomly miss uploading files with active_storage in local development. Resulting in:

web    | ActiveStorage::FileNotFoundError (ActiveStorage::FileNotFoundError):
web    |
web    | Causes:
web    | Errno::ENOENT (No such file or directory @ rb_sysopen 

ahmgeek avatar Aug 31 '24 10:08 ahmgeek