spec/fixtures/models.rb in by_star-0.2.5 vs spec/fixtures/models.rb in by_star-0.3.0

- old
+ new

@@ -13,18 +13,36 @@ class Event < ActiveRecord::Base named_scope :private, :conditions => { :public => false } end +class Invoice < ActiveRecord::Base + def self.factory(value, created_at = nil) + create!(:value => value, :created_at => created_at, :number => value) + end +end + ## seed data: year = Time.zone.now.year 1.upto(12) do |month| month.times do |n| Post.factory "post #{n}", Time.local(year, month, 1) end end + +1.upto(12) do |month| + month.times do |n| + Invoice.factory n * 1000 + 1000, Time.local(year, month, 1) + end +end + +# Invoice from last year +Invoice.factory 10000, Time.local(Time.now.year-1, 1, 1) + +# Invoice without a number +Invoice.create!(:value => 10000, :number => nil) Post.factory "Today's post", Time.zone.now Post.factory "Yesterday's post", Time.zone.now - 1.day Post.factory "Tomorrow's post", Time.zone.now + 1.day \ No newline at end of file