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).
This commit is contained in:
Daniel Uber 2021-10-13 11:18:54 -05:00 committed by GitHub
parent 82a0035e8c
commit 3167ff44d7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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: "<h1>This is an add</h1>",
placement_area: "sidebar_left",
published: true,