spec/fixtures/models.rb in by_star-0.6.1 vs spec/fixtures/models.rb in by_star-0.6.2
- old
+ new
@@ -26,46 +26,42 @@
end
## seed data:
-[Post, Event, Invoice, Tag, DayEntry].map(&:delete_all)
-
year = Time.zone.now.year
1.upto(12) do |month|
- month.times do |n|
- Post.factory "post #{month}-#{n}", Time.zone.now.beginning_of_year + (month - 1).months
- end
+ Post.factory "post #{month}", Time.zone.now.beginning_of_year + (month - 1).months
end
1.upto(12) do |month|
- month.times do |n|
- Invoice.factory n * 1000 + 1000, Time.zone.now.beginning_of_year + (month - 1).months
- end
+ Invoice.factory 10000, Time.zone.now.beginning_of_year + (month - 1).months
end
+# Inovice for 2nd January for sum_by_day
+Invoice.factory 5500, Time.zone.now.beginning_of_year + 1.day
+
# Invoice from last year
Invoice.factory 10000, Time.local(Time.zone.now.year-1, 1, 1)
-# Invoice without a number
+# Invoice without a number for count_by_year test
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
Post.factory "That's it!", Time.zone.now.end_of_year
# For by_weekend scoped test
# We need to calculate the weekend.
-time = Time.zone.now.beginning_of_year
-while time.wday != 6
- time += 1.day
-end
+weekend_time = Time.zone.now
+weekend_time += 1.day while weekend_time.wday != 6
-post = Post.factory "Weekend of January", time
+# For by_weekend scoped test
+post = Post.factory "Weekend", weekend_time
post.tags.create(:name => "weekend")
# For by_day scoped test
post = Post.factory "Today", Time.zone.now
post.tags.create(:name => "today")
@@ -79,14 +75,14 @@
post.tags.create(:name => "tomorrow")
post = Post.factory "Last year", Time.zone.now.beginning_of_year - 1.year
post.tags.create(:name => "ruby")
-post = Post.factory "The 'Current' Fortnight", Time.zone.now.beginning_of_year
-post.tags.create(:name => "may")
+post = Post.factory "The 'Current' Fortnight", Time.zone.now
+post.tags.create(:name => "fortnight")
-post = Post.factory "The 'Current' Week", Time.zone.now.beginning_of_year
-post.tags.create(:name => "may2")
+post = Post.factory "The 'Current' Week", Time.zone.now
+post.tags.create(:name => "week")
Event.create(:name => "Ryan's birthday!", :start_time => "04-12-#{Time.zone.now.year}".to_time)
Event.create(:name => "Ryan's birthday, last year!", :start_time => "04-12-#{Time.zone.now.year-1}".to_time)
Event.create(:name => "Dad's birthday!", :start_time => "05-07-#{Time.zone.now.year}".to_time)
\ No newline at end of file