From 3167ff44d78bcf195cdaf3bb09bb4dd5c921b922 Mon Sep 17 00:00:00 2001 From: Daniel Uber Date: Wed, 13 Oct 2021 11:18:54 -0500 Subject: [PATCH] Change fixed organization id to fixed organization slug (#15067) * Remove hard coded organization id from seed Since we create (hopefully) an organization with a known slug, use find_by here to set the organization_id on the seeded DisplayAd. * Since the DisplayAd looks by slug, create org if slug not found Change the seed guard to ensure an organization with slug "bachmanity" is present - we'll find by slug in DisplayAd (rather than assuming this is id 1). --- spec/support/seeds/seeds_e2e.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/spec/support/seeds/seeds_e2e.rb b/spec/support/seeds/seeds_e2e.rb index 0c280f21b..1c5b3a92f 100644 --- a/spec/support/seeds/seeds_e2e.rb +++ b/spec/support/seeds/seeds_e2e.rb @@ -88,7 +88,7 @@ end ############################################################################## -seeder.create_if_none(Organization) do +seeder.create_if_doesnt_exist(Organization, "slug", "bachmanity") do organization = Organization.create!( name: "Bachmanity", summary: Faker::Company.bs, @@ -626,8 +626,9 @@ end ############################################################################## seeder.create_if_none(DisplayAd) do + org_id = Organization.find_by(slug: "bachmanity").id DisplayAd.create!( - organization_id: 1, + organization_id: org_id, body_markdown: "

This is an add

", placement_area: "sidebar_left", published: true,