diff options
author | 2011-03-13 00:10:41 +0200 | |
---|---|---|
committer | 2011-03-13 00:10:41 +0200 | |
commit | f59f0e7c0d5a040e9c66bd189e0b544ed0e5910e (patch) | |
tree | 4be5cf779ad2e6a745a285356cffec374f608a06 | |
parent | Update used email_spec version (diff) | |
download | recruiting-webapp-f59f0e7c0d5a040e9c66bd189e0b544ed0e5910e.tar.gz recruiting-webapp-f59f0e7c0d5a040e9c66bd189e0b544ed0e5910e.tar.bz2 recruiting-webapp-f59f0e7c0d5a040e9c66bd189e0b544ed0e5910e.zip |
Fix seeds to work with new schema
-rw-r--r-- | db/fixtures/questions-email.yml | 2 | ||||
-rw-r--r-- | db/fixtures/questions-multichoice.yml | 2 | ||||
-rw-r--r-- | db/fixtures/questions.yml | 22 | ||||
-rw-r--r-- | db/seeds.rb | 19 |
4 files changed, 25 insertions, 20 deletions
diff --git a/db/fixtures/questions-email.yml b/db/fixtures/questions-email.yml index 4d4c800..3273bbf 100644 --- a/db/fixtures/questions-email.yml +++ b/db/fixtures/questions-email.yml @@ -1,7 +1,7 @@ email_q1: title: Gentoo-dev-announce posting documentation: - category: ebuild + categories: [ebuild] content: "Email a major eclass change announcement. Replace all @gentoo.org addresses with @localhost addresses. Remember to sign the email. The from field should match email you set in the application. diff --git a/db/fixtures/questions-multichoice.yml b/db/fixtures/questions-multichoice.yml index ae1af23..255aab4 100644 --- a/db/fixtures/questions-multichoice.yml +++ b/db/fixtures/questions-multichoice.yml @@ -1,6 +1,6 @@ multichoice_q1: title: Fake multiple choice documentation: Fake - category: ebuild + categories: [ebuild] content: Some question options: Option 1; Option 2; Option 3 diff --git a/db/fixtures/questions.yml b/db/fixtures/questions.yml index 7ff29e1..1baee35 100644 --- a/db/fixtures/questions.yml +++ b/db/fixtures/questions.yml @@ -1,7 +1,7 @@ ebuild_q1: title: Big changes in Gentoo documentation: GLEPs - category: ebuild + categories: [ebuild] content: What is the proper method for suggesting a wide-ranging feature or enhancement to Gentoo? Describe the process for getting this feature approved and implemented. @@ -9,21 +9,21 @@ ebuild_q1: ebuild_q2: title: Responsibilities documentation: devrel policy - category: ebuild + categories: [ebuild] content: Who should be contacted with complaints about specific developers or projects? ebuild_q3: title: Gentoo mailing lists documentation: gentoo.org - category: ebuild + categories: [ebuild] content: "When is it appropriate to post to the following mailing lists: gentoo-core, gentoo-dev, gentoo-dev-announce, gentoo-project?" ebuild_q4: title: src_install documentation: GLEPs - category: ebuild + categories: [ebuild] question_group: ebuild_group1 content: "\n src_install () { \n dobin uvconvert/${PN} @@ -35,7 +35,7 @@ ebuild_q4: ebuild_q5: title: src_install documentation: devmanual - category: ebuild + categories: [ebuild] question_group: ebuild_group1 content: "\n src_install() { \n dobin utrac @@ -47,7 +47,7 @@ ebuild_q5: ebuild_q6: title: src_install documentation: handbook - category: ebuild + categories: [ebuild] question_group: ebuild_group1 content: "\n src_install() { \n dobin tree @@ -58,13 +58,13 @@ ebuild_q6: mentor_q1: title: Scopes in ebuild documentation: handbook - category: mentoring + categories: [mentoring] content: "What's the difference between local and global scope in an ebuild?" mentor_q2: title: Optional SSL support in ebuild documentation: devmanual - category: mentoring + categories: [mentoring] content: 'You have a patch for foomatic which enables SSL support that is optional at build time. Assuming that foomatic uses an autotools based build system provide most probable changes required in an `EAPI="0"` ebuild. @@ -73,7 +73,7 @@ mentor_q2: mentor_q3: title: Improve maintainability of ebuild documentation: devmanual - category: mentoring + categories: [mentoring] content: "You are writing an ebuild for the foomatic package. Upstream calls the current version \"1.3-7b\" (but this is _not_ a beta release). How would the ebuild be named? What's wrong with the ebuild snippet below and how should this @@ -84,12 +84,12 @@ mentor_q3: non_q1: title: Gentoo Foundation documentation: gentoo.org - category: non_ebuild + categories: [non_ebuild] content: What is the Gentoo Foundation? How does one apply for membership and who are eligible? non_q2: title: Gentoo Council documentation: GLEPs - category: non_ebuild + categories: [non_ebuild] content: What is the purpose of the Gentoo Council? diff --git a/db/seeds.rb b/db/seeds.rb index 352cc18..7f3e937 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -19,7 +19,12 @@ class SeedHelper hash = item_array[1] for field in replace_with_objects - hash[field] = @objects[hash[field]] + val = hash[field] + if val.is_a?(Array) + hash[field] = val.map { |n| @objects[n] } + else + hash[field] = @objects[val] + end end if block.nil? @@ -56,21 +61,21 @@ User.destroy_all seeder = SeedHelper.new # Question categories -seeder.objects['ebuild'] = Category.create! :name => 'Ebuild quiz' -seeder.objects['mentoring'] = Category.create! :name => 'End of mentoring quiz' -seeder.objects['non'] = Category.create! :name => 'Non-ebuild staff quiz' +seeder.objects['ebuild'] = Category.create! :name => 'Ebuild quiz' +seeder.objects['mentoring'] = Category.create! :name => 'End of mentoring quiz' +seeder.objects['non_ebuild'] = Category.create! :name => 'Non-ebuild staff quiz' # Question groups seeder.objects['ebuild_group1'] = QuestionGroup.create! :name => 'ebuild_group1', :description => 'src_install implementations to comment on' # Questions with text content - load from YAML file -seeder.read_yaml('db/fixtures/questions.yml', Question, ['category', 'question_group']) do |name, hash, objects, klass| +seeder.read_yaml('db/fixtures/questions.yml', Question, ['categories', 'question_group']) do |name, hash, objects, klass| objects[name] = klass.create! (hash - {'content' => nil}) objects["#{name}-content"] = QuestionContentText.create! :question => objects[name], :content => hash['content'] end # Questions with multiple choice content - load from YAML file -seeder.read_yaml('db/fixtures/questions-multichoice.yml', Question, ['category', 'question_group']) do |name, hash, objects, klass| +seeder.read_yaml('db/fixtures/questions-multichoice.yml', Question, ['categories', 'question_group']) do |name, hash, objects, klass| objects[name] = klass.create!(hash - {'options' => nil, 'content' => nil}) objects["#{name}-content"] = QuestionContentMultipleChoice.create! :question => objects[name], :content => hash['content'] for opt in hash['options'].split(';') @@ -80,7 +85,7 @@ seeder.read_yaml('db/fixtures/questions-multichoice.yml', Question, ['category', end # Questions with email content - load from YAML file -seeder.read_yaml('db/fixtures/questions-email.yml', Question, ['category', 'question_group']) do |name, hash, objects, klass| +seeder.read_yaml('db/fixtures/questions-email.yml', Question, ['categories', 'question_group']) do |name, hash, objects, klass| objects[name] = klass.create!(hash - {'content' => nil, 'req_text' => nil}) objects["#{name}-content"] = QuestionContentEmail.create! :question => objects[name], :description=> hash['content'], :req_text => hash['req_text'] end |