diff --git a/spec/factories/badges.rb b/spec/factories/badges.rb index 0c81d0e36..c390a3a32 100644 --- a/spec/factories/badges.rb +++ b/spec/factories/badges.rb @@ -1,12 +1,9 @@ FactoryBot.define do - image = Rack::Test::UploadedFile.new( - Rails.root.join("spec", "support", "fixtures", "images", "image1.jpeg"), - "image/jpeg", - ) + image_path = Rails.root.join("spec", "support", "fixtures", "images", "image1.jpeg") factory :badge do - title { Faker::Book.title + " #{rand(1000)}" } + title { Faker::Book.title + " #{rand(1000)}" } description { Faker::Lorem.sentence } - badge_image { image } + badge_image { Rack::Test::UploadedFile.new(image_path, "image/jpeg") } end end diff --git a/spec/factories/podcasts.rb b/spec/factories/podcasts.rb index a6110e257..4002abb7a 100644 --- a/spec/factories/podcasts.rb +++ b/spec/factories/podcasts.rb @@ -1,14 +1,11 @@ FactoryBot.define do sequence(:podcast_slug) { |n| "slug-#{n}" } - image = Rack::Test::UploadedFile.new( - Rails.root.join("spec", "support", "fixtures", "images", "image1.jpeg"), - "image/jpeg", - ) + image_path = Rails.root.join("spec", "support", "fixtures", "images", "image1.jpeg") factory :podcast do title { Faker::Beer.name } - image { image } + image { Rack::Test::UploadedFile.new(image_path, "image/jpeg") } description { Faker::Hipster.paragraph(sentence_count: 1) } slug { generate :podcast_slug } feed_url { Faker::Internet.url } diff --git a/spec/factories/users.rb b/spec/factories/users.rb index 829604af9..56c65fdb6 100644 --- a/spec/factories/users.rb +++ b/spec/factories/users.rb @@ -4,26 +4,23 @@ FactoryBot.define do sequence(:twitter_username) { |n| "twitter#{n}" } sequence(:github_username) { |n| "github#{n}" } - image = Rack::Test::UploadedFile.new( - Rails.root.join("spec", "support", "fixtures", "images", "image1.jpeg"), - "image/jpeg", - ) + image_path = Rails.root.join("spec", "support", "fixtures", "images", "image1.jpeg") factory :user do - name { Faker::Name.name } - email { generate :email } - username { generate :username } - profile_image { image } - twitter_username { generate :twitter_username } - github_username { generate :github_username } - summary { Faker::Lorem.paragraph[0..rand(190)] } - website_url { Faker::Internet.url } - confirmed_at { Time.current } - saw_onboarding { true } - checked_code_of_conduct { true } + name { Faker::Name.name } + email { generate :email } + username { generate :username } + profile_image { Rack::Test::UploadedFile.new(image_path, "image/jpeg") } + twitter_username { generate :twitter_username } + github_username { generate :github_username } + summary { Faker::Lorem.paragraph[0..rand(190)] } + website_url { Faker::Internet.url } + confirmed_at { Time.current } + saw_onboarding { true } + checked_code_of_conduct { true } checked_terms_and_conditions { true } - signup_cta_variant { "navbar_basic" } - email_digest_periodic { false } + signup_cta_variant { "navbar_basic" } + email_digest_periodic { false } after(:create) do |user| create(:identity, user_id: user.id)