tap/spec/factories/products.rb

36 lines
930 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
name { Faker::Name.name }
price_cents { rand 120 }
2015-09-04 16:47:49 +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