by_star 0.6.1 → 0.6.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -28,26 +28,23 @@ end
28
28
 
29
29
  ## seed data:
30
30
 
31
- [Post, Event, Invoice, Tag, DayEntry].map(&:delete_all)
32
-
33
31
  year = Time.zone.now.year
34
32
 
35
33
  1.upto(12) do |month|
36
- month.times do |n|
37
- Post.factory "post #{month}-#{n}", Time.zone.now.beginning_of_year + (month - 1).months
38
- end
34
+ Post.factory "post #{month}", Time.zone.now.beginning_of_year + (month - 1).months
39
35
  end
40
36
 
41
37
  1.upto(12) do |month|
42
- month.times do |n|
43
- Invoice.factory n * 1000 + 1000, Time.zone.now.beginning_of_year + (month - 1).months
44
- end
38
+ Invoice.factory 10000, Time.zone.now.beginning_of_year + (month - 1).months
45
39
  end
46
40
 
41
+ # Inovice for 2nd January for sum_by_day
42
+ Invoice.factory 5500, Time.zone.now.beginning_of_year + 1.day
43
+
47
44
  # Invoice from last year
48
45
  Invoice.factory 10000, Time.local(Time.zone.now.year-1, 1, 1)
49
46
 
50
- # Invoice without a number
47
+ # Invoice without a number for count_by_year test
51
48
  Invoice.create!(:value => 10000, :number => nil)
52
49
 
53
50
  Post.factory "Today's post", Time.zone.now
@@ -58,12 +55,11 @@ Post.factory "That's it!", Time.zone.now.end_of_year
58
55
 
59
56
  # For by_weekend scoped test
60
57
  # We need to calculate the weekend.
61
- time = Time.zone.now.beginning_of_year
62
- while time.wday != 6
63
- time += 1.day
64
- end
58
+ weekend_time = Time.zone.now
59
+ weekend_time += 1.day while weekend_time.wday != 6
65
60
 
66
- post = Post.factory "Weekend of January", time
61
+ # For by_weekend scoped test
62
+ post = Post.factory "Weekend", weekend_time
67
63
  post.tags.create(:name => "weekend")
68
64
 
69
65
  # For by_day scoped test
@@ -81,11 +77,11 @@ post.tags.create(:name => "tomorrow")
81
77
  post = Post.factory "Last year", Time.zone.now.beginning_of_year - 1.year
82
78
  post.tags.create(:name => "ruby")
83
79
 
84
- post = Post.factory "The 'Current' Fortnight", Time.zone.now.beginning_of_year
85
- post.tags.create(:name => "may")
80
+ post = Post.factory "The 'Current' Fortnight", Time.zone.now
81
+ post.tags.create(:name => "fortnight")
86
82
 
87
- post = Post.factory "The 'Current' Week", Time.zone.now.beginning_of_year
88
- post.tags.create(:name => "may2")
83
+ post = Post.factory "The 'Current' Week", Time.zone.now
84
+ post.tags.create(:name => "week")
89
85
 
90
86
 
91
87
  Event.create(:name => "Ryan's birthday!", :start_time => "04-12-#{Time.zone.now.year}".to_time)
@@ -11,14 +11,21 @@ require 'active_support/core_ext/string/conversions'
11
11
  require 'by_star'
12
12
  require 'spec'
13
13
 
14
+ # Define time zone before loading test_helper
15
+ zone = "UTC"
16
+ Time.zone = zone
17
+ ActiveRecord::Base.default_timezone = zone
18
+
19
+ YAML::load_file(File.dirname(__FILE__) + "/database.yml").each do |key, connection|
20
+ ActiveRecord::Base.establish_connection(connection)
21
+ load File.dirname(__FILE__) + "/fixtures/schema.rb"
22
+ load File.dirname(__FILE__) + "/fixtures/models.rb"
23
+ end
24
+
14
25
  # bootstraping the plugin through init.rb
15
26
  # tests how it would load in a real application
16
27
  load File.dirname(__FILE__) + "/../rails/init.rb"
17
-
18
- ActiveRecord::Base.logger = Logger.new("tmp/activerecord.log")
19
-
20
28
  # Print the location of puts/p calls so you can find them later
21
-
22
29
  # def puts str
23
30
  # super caller.first if caller.first.index("shoulda.rb") == -1
24
31
  # super str
@@ -27,4 +34,6 @@ ActiveRecord::Base.logger = Logger.new("tmp/activerecord.log")
27
34
  # def p obj
28
35
  # puts caller.first
29
36
  # super obj
30
- # end
37
+ # end
38
+
39
+ ActiveRecord::Base.logger = Logger.new("tmp/activerecord.log")
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: by_star
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.1
4
+ version: 0.6.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Bigg
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2010-01-29 00:00:00 +10:00
13
+ date: 2010-02-19 00:00:00 +10:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency