tap/spec/factories/products.rb

37 lines
996 B
Ruby
Raw Normal View History

# == Schema Information
#
# Table name: products
#
# id :integer not null, primary key
# name :string not null
# price_cents :integer default("0"), not null
2015-02-09 17:06:24 +01:00
# created_at :datetime
# updated_at :datetime
# avatar_file_name :string
# avatar_content_type :string
# avatar_file_size :integer
# avatar_updated_at :datetime
# category :integer default("0")
# stock :integer default("0"), not null
# calories :integer
# deleted :boolean default("f")
#
require 'faker'
require 'identicon'
2014-11-24 21:45:32 +01:00
FactoryGirl.define do
factory :product do
2015-09-17 14:05:33 +02:00
name { Faker::Name.name }
2015-09-18 16:49:41 +02:00
price_cents { 1 + rand(120) }
price { price_cents / 100.0 }
2015-09-17 14:05:33 +02:00
stock { 30 + rand(30) }
calories { rand 20 }
avatar { Identicon.data_url_for name }
2015-09-07 14:26:07 +02:00
factory :invalid_product do
name nil
end
2015-03-03 17:41:53 +01:00
end
2014-11-24 21:45:32 +01:00
end