add proposal image on dev_seeds task
This commit is contained in:
Binary file not shown.
|
After Width: | Height: | Size: 146 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 183 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 37 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 89 KiB |
@@ -1,3 +1,26 @@
|
|||||||
|
IMAGE_FILES = %w{
|
||||||
|
firdouss-ross-414668-unsplash_846x475.jpg
|
||||||
|
nathan-dumlao-496190-unsplash_713x475.jpg
|
||||||
|
steve-harvey-597760-unsplash_713x475.jpg
|
||||||
|
tim-mossholder-302931-unsplash_713x475.jpg
|
||||||
|
}.map do |filename|
|
||||||
|
File.new(Rails.root.join("db",
|
||||||
|
"dev_seeds",
|
||||||
|
"images",
|
||||||
|
"proposals", filename))
|
||||||
|
end
|
||||||
|
|
||||||
|
def add_image_to( imageable )
|
||||||
|
# imageable should respond to #title & #author
|
||||||
|
imageable.image = Image.create!({
|
||||||
|
imageable: imageable,
|
||||||
|
title: imageable.title,
|
||||||
|
attachment: IMAGE_FILES.sample,
|
||||||
|
user: imageable.author
|
||||||
|
})
|
||||||
|
imageable.save
|
||||||
|
end
|
||||||
|
|
||||||
section "Creating Proposals" do
|
section "Creating Proposals" do
|
||||||
tags = Faker::Lorem.words(25)
|
tags = Faker::Lorem.words(25)
|
||||||
30.times do
|
30.times do
|
||||||
@@ -15,6 +38,7 @@ section "Creating Proposals" do
|
|||||||
geozone: Geozone.all.sample,
|
geozone: Geozone.all.sample,
|
||||||
skip_map: "1",
|
skip_map: "1",
|
||||||
terms_of_service: "1")
|
terms_of_service: "1")
|
||||||
|
add_image_to proposal
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -35,6 +59,7 @@ section "Creating Archived Proposals" do
|
|||||||
skip_map: "1",
|
skip_map: "1",
|
||||||
terms_of_service: "1",
|
terms_of_service: "1",
|
||||||
created_at: Setting["months_to_archive_proposals"].to_i.months.ago)
|
created_at: Setting["months_to_archive_proposals"].to_i.months.ago)
|
||||||
|
add_image_to proposal
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -56,6 +81,7 @@ section "Creating Successful Proposals" do
|
|||||||
skip_map: "1",
|
skip_map: "1",
|
||||||
terms_of_service: "1",
|
terms_of_service: "1",
|
||||||
cached_votes_up: Setting["votes_for_proposal_success"])
|
cached_votes_up: Setting["votes_for_proposal_success"])
|
||||||
|
add_image_to proposal
|
||||||
end
|
end
|
||||||
|
|
||||||
tags = ActsAsTaggableOn::Tag.where(kind: 'category')
|
tags = ActsAsTaggableOn::Tag.where(kind: 'category')
|
||||||
@@ -74,6 +100,7 @@ section "Creating Successful Proposals" do
|
|||||||
geozone: Geozone.all.sample,
|
geozone: Geozone.all.sample,
|
||||||
skip_map: "1",
|
skip_map: "1",
|
||||||
terms_of_service: "1")
|
terms_of_service: "1")
|
||||||
|
add_image_to proposal
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user