Sha256: bfcb85cfddfad381810982f30022b104e06161b454a51f374b6285c89250a5e5

Contents?: true

Size: 696 Bytes

Versions: 15

Compression:

Stored size: 696 Bytes

Contents

FactoryGirl.define do
  # to_create do |instance|
  #   raise "Save failed for #{instance.class} (#{instance.errors.full_messages.inspect})" if !instance.save
  # end

  factory :polygallery_gallery, :class => Polygallery::Gallery do
    title 'gallery'

    trait :with_photo do
      photos_attributes { generate_photo_attributes } end
    trait :with_photos do
      photos_attributes { generate_photo_attributes 3 } end
    trait :with_tons_of_photos do
      photos_attributes { generate_photo_attributes 10 } end
  end
end
def generate_photo_attributes(count=1, attrs={})
  if count.is_a? Hash; attrs = count; count = 1 end
  (1..count).map{ attributes_for :polygallery_photo, attrs } 
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
polygallery-0.4.8 lib/polygallery/factories/polygallery/galleries.rb
polygallery-0.4.7 lib/polygallery/factories/polygallery/galleries.rb
polygallery-0.4.6 lib/polygallery/factories/polygallery/galleries.rb
polygallery-0.4.5 lib/polygallery/factories/polygallery/galleries.rb
polygallery-0.4.4 lib/polygallery/factories/polygallery/galleries.rb
polygallery-0.4.2 lib/polygallery/factories/polygallery/galleries.rb
polygallery-0.4.1 lib/polygallery/factories/polygallery/galleries.rb
polygallery-0.4.0 lib/polygallery/factories/polygallery/galleries.rb
polygallery-0.3.6 lib/polygallery/factories/polygallery/galleries.rb
polygallery-0.3.5 lib/polygallery/factories/polygallery/galleries.rb
polygallery-0.3.4 lib/polygallery/factories/polygallery/galleries.rb
polygallery-0.3.3 lib/polygallery/factories/polygallery/galleries.rb
polygallery-0.3.2 lib/polygallery/factories/polygallery/galleries.rb
polygallery-0.3.1 lib/polygallery/factories/polygallery/galleries.rb
polygallery-0.3.0 lib/polygallery/factories/polygallery/galleries.rb