Created
December 30, 2010 20:34
-
-
Save dougalcorn/760269 to your computer and use it in GitHub Desktop.
Non-trivial factory_girl with associations
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Factory.define(:kit) do |f| | |
| f.association :primary_palette, :factory => :palette # association doesn't match class name | |
| f.association :secondary_palette, :factory => :palette | |
| f.association :user, :factory => :user | |
| f.sequence(:name) { |i| "Kit#{i}" } | |
| f.bg_images { |images| [images.association(:attachment)] } # has_many assoc | |
| f.default false | |
| f.display_fonts { [Factory(:font), Factory(:font)] } | |
| f.body_font { Factory(:font) } | |
| end | |
| Factory.define(:default_kit, :parent => :kit) do |f| | |
| f.sequence(:name) { |i| "default #{i}" } | |
| f.default true | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment