diff --git a/db/seeds.rb b/db/seeds.rb index a0458dd1..efcbb274 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -5,54 +5,4 @@ FactoryGirl.definition_file_paths = Dir["#{Rails.root}/vendor/built_in_modules/* FactoryGirl.find_definitions - -ConferenceCoAuthorRelation.destroy_all -ConferenceCoAuthor.destroy_all -ConferencePaperType.destroy_all -WritingConferenceFile.destroy_all -WritingConference.destroy_all -#Dir[Rails.root.join("spec/factories/*.rb")].each {|f| require f} - - -2.times do - FactoryGirl.create(:conference_paper_type) -end - -10.times do - FactoryGirl.create(:conference_co_author_relation) -end - -50.times do - FactoryGirl.create(:conference_co_author) -end - -50.times do - FactoryGirl.create(:writing_conference) -end - -puts "Success!" - -# ======= -# -#CoAuthorRelation.destroy_all -#CoAuthor.destroy_all -#JournalLevelType.destroy_all -#WritingJournalFile.destroy_all -#WritingJournal.destroy_all -# -#10.size.times do -# FactoryGirl.create(:journal_level) -#end -# -#10.times do -# FactoryGirl.create(:journal_relation) -#end -# -#50.times do -# FactoryGirl.create(:journal) -#end -# -#50.times do -# FactoryGirl.create(:journal_co_author) -#end -#puts "Success!" +Dir["#{Rails.root}/vendor/built_in_modules/*/db/seeds.rb"].each { |seed| load seed } diff --git a/vendor/built_in_modules/personal_journal/db/seeds.rb b/vendor/built_in_modules/personal_journal/db/seeds.rb new file mode 100644 index 00000000..2562f00f --- /dev/null +++ b/vendor/built_in_modules/personal_journal/db/seeds.rb @@ -0,0 +1,23 @@ + +JournalCoAuthorRelation.destroy_all +JournalCoAuthor.destroy_all +JournalLevelType.destroy_all +WritingJournalFile.destroy_all +WritingJournal.destroy_all + +10.size.times do + FactoryGirl.create(:journal_level) +end + +10.times do + FactoryGirl.create(:journal_co_author_relation) +end + +50.times do + FactoryGirl.create(:writing_journal) +end + +50.times do + FactoryGirl.create(:journal_co_author) +end +puts "Journal sample data import success!" diff --git a/vendor/built_in_modules/personal_journal/spec/factories/journal_co_author_relations.rb b/vendor/built_in_modules/personal_journal/spec/factories/journal_co_author_relations.rb index 4badc8a2..ca7cfbe2 100644 --- a/vendor/built_in_modules/personal_journal/spec/factories/journal_co_author_relations.rb +++ b/vendor/built_in_modules/personal_journal/spec/factories/journal_co_author_relations.rb @@ -2,7 +2,7 @@ types = ["friend", "teacher", "student", "schoolmate", "parent", "best friend", "instructor", "labmate", "TA", "mate"] FactoryGirl.define do - factory(:journal_co_author_relation, class: "CoAuthorRelation") do |f| + factory(:journal_co_author_relation, class: "JournalCoAuthorRelation") do |f| f.sequence(:relation_translations) do |n| { zh_tw: "#{types[n%types.size]}", en: "#{types[n%types.size]}" } diff --git a/vendor/built_in_modules/personal_journal/spec/factories/journal_co_authors.rb b/vendor/built_in_modules/personal_journal/spec/factories/journal_co_authors.rb index ebfbded6..17d15dd3 100644 --- a/vendor/built_in_modules/personal_journal/spec/factories/journal_co_authors.rb +++ b/vendor/built_in_modules/personal_journal/spec/factories/journal_co_authors.rb @@ -8,13 +8,13 @@ email = Array.new 51,"" email= email.map do |p| Faker::Internet.email end FactoryGirl.define do - factory(:journal_co_author, class: "CoAuthor") do |f| + factory(:journal_co_author, class: "JournalCoAuthor") do |f| f.sequence(:co_author_translations) do |n| { zh_tw: "#{name_tw[n]}", en: "#{name_en[n]}" } end - f.sequence(:co_author_relations_id) do |n| "#{CoAuthorRelation.all[n%CoAuthorRelation.count].id}" end + f.sequence(:journal_co_author_relations_id) do |n| "#{JournalCoAuthorRelation.all[n%JournalCoAuthorRelation.count].id}" end f.sequence(:email) do |n| "#{email[n]}" end f.name_id BSON::ObjectId('4f45f3b9e9d02c5db9000067') #user_id, this is Chris' account end diff --git a/vendor/built_in_modules/personal_journal/spec/factories/writing_journals.rb b/vendor/built_in_modules/personal_journal/spec/factories/writing_journals.rb index bad765bb..a402a91d 100644 --- a/vendor/built_in_modules/personal_journal/spec/factories/writing_journals.rb +++ b/vendor/built_in_modules/personal_journal/spec/factories/writing_journals.rb @@ -7,7 +7,7 @@ data_json = JSON.parse(data) rand = Random.new FactoryGirl.define do - factory :journal, class: "WritingJournal" do |f| + factory :writing_journal, class: "WritingJournal" do |f| f.sequence(:paper_title_translations) do |n| { zh_tw: "#{data_json[n]["paper_title"]}_tw", en: "#{data_json[n]["paper_title"]}_en" }