current version
This commit is contained in:
parent
9e3fdcd868
commit
7a412d4e7e
12
db/seeds.rb
12
db/seeds.rb
|
@ -28,6 +28,8 @@ file = ["1.png", "5.pdf", "2.png", "6.pdf", "3.png", "7.pdf", "4.png"]
|
||||||
|
|
||||||
level = ["SCI", "SCIE", "SSCI", "AH & HCI", "EI", "CSCI", "CSSCI", "TSCI", "TSSCI", "THCI"]
|
level = ["SCI", "SCIE", "SSCI", "AH & HCI", "EI", "CSCI", "CSSCI", "TSCI", "TSSCI", "THCI"]
|
||||||
|
|
||||||
|
rand = Random.new
|
||||||
|
|
||||||
FactoryGirl.define do
|
FactoryGirl.define do
|
||||||
factory(:journal_level, class: "JournalLevelType") do |f|
|
factory(:journal_level, class: "JournalLevelType") do |f|
|
||||||
f.sequence(:title_translations) do |n|
|
f.sequence(:title_translations) do |n|
|
||||||
|
@ -38,10 +40,10 @@ FactoryGirl.define do
|
||||||
|
|
||||||
factory(:upload_file, class: "WritingJournalFile") do |f|
|
factory(:upload_file, class: "WritingJournalFile") do |f|
|
||||||
f.sequence(:file) do |n|
|
f.sequence(:file) do |n|
|
||||||
File.new(File.join(Rails.root, "db" ,"files", file[Random.rand(0..6)]))
|
File.new(File.join(Rails.root, "db" ,"files", file[rand.rand(0..6)]))
|
||||||
end
|
end
|
||||||
f.sequence(:title) do |n|
|
f.sequence(:title) do |n|
|
||||||
"#{file_desc[Random.rand(0..6)]}"
|
"#{file_desc[rand.rand(0..6)]}"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -112,16 +114,16 @@ FactoryGirl.define do
|
||||||
|
|
||||||
f.sequence(:journal_level_types) do |n|
|
f.sequence(:journal_level_types) do |n|
|
||||||
level = []
|
level = []
|
||||||
total_levels = Random.rand(1..JournalLevelType.count)
|
total_levels = rand.rand(1..JournalLevelType.count)
|
||||||
total_levels.times do
|
total_levels.times do
|
||||||
level << JournalLevelType.all[Random.rand(0..JournalLevelType.count-1)]
|
level << JournalLevelType.all[rand.rand(0..JournalLevelType.count-1)]
|
||||||
end
|
end
|
||||||
level.uniq
|
level.uniq
|
||||||
end
|
end
|
||||||
|
|
||||||
f.sequence(:writing_journal_files) do |n|
|
f.sequence(:writing_journal_files) do |n|
|
||||||
files = []
|
files = []
|
||||||
total_files = Random.rand(1..7)
|
total_files = rand.rand(1..7)
|
||||||
total_files.times do files << FactoryGirl.create(:upload_file) end
|
total_files.times do files << FactoryGirl.create(:upload_file) end
|
||||||
files
|
files
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue