by_star 0.4.0 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.4.0
1
+ 0.5.0
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{by_star}
8
- s.version = "0.4.0"
8
+ s.version = "0.5.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Ryan Bigg", "Mislav Marohni\304\207"]
12
- s.date = %q{2009-10-30}
12
+ s.date = %q{2009-11-04}
13
13
  s.description = %q{ActiveRecord extension for easier date scopes and time ranges}
14
14
  s.email = %q{radarlistener@gmail.com}
15
15
  s.extra_rdoc_files = [
@@ -3,6 +3,7 @@ require 'shared'
3
3
  require 'range_calculations'
4
4
  require 'time_ext'
5
5
  require 'vanilla'
6
+
6
7
  Dir[File.dirname(__FILE__) + '/calculations/*.rb'].each { |file| require file }
7
8
  require 'calculations'
8
9
  module ByStar
@@ -1,6 +1,6 @@
1
1
  module Shared
2
2
  def conditions_for_range(start_time, end_time, field="created_at")
3
- field = connection.quote_table_name(table_name) << '.' << connection.quote_column_name(field || "created_at")
3
+ field = table_name << '.' << (field || "created_at")
4
4
  ["#{field} >= ? AND #{field} <= ?", start_time.utc, end_time.utc]
5
5
  end
6
6
 
@@ -568,12 +568,21 @@ describe Post do
568
568
  end
569
569
 
570
570
  it "current month with blank block" do
571
- Post.count_by_month(:all, Time.zone.now) { }.should eql(16)
571
+ stub_time
572
+ Post.count_by_month(:all, Time.zone.now) { }.should eql(8)
572
573
  end
573
574
  end
574
575
  end
575
576
 
576
577
  end
578
+
579
+ describe "edge cases" do
580
+ # This method previously generated sql like: `day_entries`.`spent_at`.`spent_at`.`spent_at`.`spent_at`
581
+ # Which is *obviously* incorrect and #omg worthy.
582
+ it "should not spam the field name when using a different field" do
583
+ Invoice.first.day_entries.between((Time.zone.now - 3.days).to_date, Time.zone.now.to_date, :field => "spent_at")
584
+ end
585
+ end
577
586
 
578
587
  describe Time do
579
588
  it "should work out the beginning of a weekend (Friday 3pm)" do
@@ -16,11 +16,16 @@ class Event < ActiveRecord::Base
16
16
  end
17
17
 
18
18
  class Invoice < ActiveRecord::Base
19
+ has_many :day_entries
19
20
  def self.factory(value, created_at = nil)
20
21
  create!(:value => value, :created_at => created_at, :number => value)
21
22
  end
22
23
  end
23
24
 
25
+ class DayEntry < ActiveRecord::Base
26
+
27
+ end
28
+
24
29
  ## seed data:
25
30
 
26
31
  year = Time.zone.now.year
@@ -85,4 +90,6 @@ Event.create(:name => "Tomorrow", :start_time => Time.zone.now.tomorrow
85
90
  # For by_weekend test
86
91
  Event.create(:name => "1st of August", :start_time => "01-08-#{Time.zone.now.year}".to_time)
87
92
 
88
- Event.create(:name => "FBI meeting", :start_time => "02-03-#{Time.zone.now.year}".to_time, :public => false)
93
+ Event.create(:name => "FBI meeting", :start_time => "02-03-#{Time.zone.now.year}".to_time, :public => false)
94
+
95
+ Invoice.first.day_entries.create(:spent_at => Time.zone.now + 1.hour, :name => "Working harder, better, faster stronger.")
@@ -27,4 +27,10 @@ ActiveRecord::Schema.define do
27
27
  t.boolean :public, :default => true
28
28
  end
29
29
 
30
+ create_table :day_entries, :force => true do |t|
31
+ t.references :invoice
32
+ t.datetime :spent_at
33
+ t.string :name
34
+ end
35
+
30
36
  end
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.4.0
4
+ version: 0.5.0
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: 2009-10-30 00:00:00 +10:00
13
+ date: 2009-11-04 00:00:00 +10:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency