<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>.gitignore</filename>
    </added>
    <added>
      <filename>test/active_record/event_finders_test.rb</filename>
    </added>
    <added>
      <filename>test/db/database.yml</filename>
    </added>
    <added>
      <filename>test/db/schema.rb</filename>
    </added>
    <added>
      <filename>test/fixtures/events.yml</filename>
    </added>
    <added>
      <filename>test/views/month.html.erb</filename>
    </added>
    <added>
      <filename>test/views/month_builder.html.erb</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -6,15 +6,15 @@ module CollectiveIdea
     end
     
     module SingletonMethods
-      def calendar_finders(options = {})
+      def event_finders(options = {})
         options = {
           :begin_at =&gt; 'begin_at',
           :end_at =&gt; 'end_at',
           :order =&gt; ''
         }.merge(options)
         
-        write_inheritable_attribute :calendar_finder_options, options
-        class_inheritable_reader :calendar_finder_options
+        write_inheritable_attribute :event_finder_options, options
+        class_inheritable_reader :event_finder_options
         
         include InstanceMethods
         include Helpers
@@ -27,15 +27,18 @@ module CollectiveIdea
       
       def find_for_date(date=Date.today, *args)
         # we call date.to_date to ensure it is a Date (not a Time or CalendarBuilder::Proxy)
-        find_approved_for_date_range((date.to_date..date.to_date), *args)
+        find_for_date_range((date.to_date..date.to_date), *args)
       end
 
       # Find for a range of dates
+      # We use the beginning of day for the first date and the end of day for the last date
+      # so that we get the full range.
       # The event's
       # * end is always after the beginning of the range
       # * Beginning is before the range and ends after the beginning of the range
       # OR
       # * Beginning is inside the range.
+      # MySQL treats BETWEEN() strangely with dates, so we don't use it.
       def find_for_date_range(range=(Date.today..Date.today), *args)
         with_scope(:find =&gt; {:conditions =&gt; [&quot;
           #{quoted_table_name}.#{quoted_end_at_column_name} &gt;= :begin_at AND (
@@ -43,24 +46,28 @@ module CollectiveIdea
               OR (#{quoted_table_name}.#{quoted_begin_at_column_name} &gt;= :begin_at AND :end_at &gt;= #{quoted_table_name}.#{quoted_begin_at_column_name} )
           )&quot;, {
           :begin_at =&gt; range.first.beginning_of_day, 
-          :end_at =&gt; range.last.end_of_day}]}) { find_scoped(*args) }
+          :end_at =&gt; range.last.end_of_day}]}) { find_ordered(*args) }
       end
 
       def find_for_month(date=Date.today, *args)
         # we call date.to_date to ensure it is a Date (not a Time or CalendarBuilder::Proxy)
         with_scope(:find =&gt; {:conditions =&gt; [&quot;DATE_FORMAT(#{quoted_table_name}.#{quoted_begin_at_column_name}, \&quot;%Y-%m\&quot;) = :date OR DATE_FORMAT(#{quoted_table_name}.#{quoted_end_at_column_name}, \&quot;%Y-%m\&quot;) = :date&quot;, {:date =&gt; date.strftime(&quot;%Y-%m&quot;)}]}) do 
-          find_scoped(*args)
+          find_ordered(*args)
         end
       end
 
       def find_upcoming(*args)
-        with_scope(:find =&gt; {:conditions =&gt; [&quot;#{quoted_table_name}.#{quoted_begin_at_column_name} &gt; ? &quot;, Time.now]}) { find_scoped(*args) }
+        with_scope(:find =&gt; {:conditions =&gt; [&quot;#{quoted_table_name}.#{quoted_begin_at_column_name} &gt; ?&quot;, Time.now]}) { find_ordered(*args) }
       end
 
       # Common ordering for all the other finders
       def find_ordered(*args)
-        with_scope(:find =&gt; {:order =&gt; calendar_finder_options[:order]}) do
+        if event_finder_options[:order].blank?
           find(*args)
+        else
+          with_scope(:find =&gt; {:order =&gt; event_finder_options[:order]}) do
+            find(*args)
+          end
         end
       end
     
@@ -72,11 +79,11 @@ module CollectiveIdea
     # Mixed into both classes and instances
     module Helpers
       def begin_at_column_name
-        calendar_finder_options[:begin_at]
+        event_finder_options[:begin_at]
       end
       
       def end_at_column_name
-        calendar_finder_options[:end_at]
+        event_finder_options[:end_at]
       end
       
       def quoted_begin_at_column_name</diff>
      <filename>lib/active_record/event_finders.rb</filename>
    </modified>
    <modified>
      <diff>@@ -20,7 +20,7 @@ class CalendarController &lt; ActionController::Base
   # Re-raise errors caught by the controller.
   def rescue_action(e) raise e end
 end
-CalendarController.view_paths = [File.expand_path(File.dirname(__FILE__) + &quot;/../fixtures&quot;)]
+CalendarController.view_paths = [File.expand_path(File.dirname(__FILE__) + &quot;/../views&quot;)]
 ActionController::Routing::Routes.draw {|m| m.connect ':controller/:action/:id' }
 
 class CalendarBuilderTest &lt; Test::Unit::TestCase</diff>
      <filename>test/calendar/calendar_builder_test.rb</filename>
    </modified>
    <modified>
      <diff>@@ -2,6 +2,8 @@ $:.unshift(File.dirname(__FILE__) + '/../lib')
 require 'rubygems'
 require 'action_controller'
 require 'action_view'
+gem 'activerecord', '&gt;= 1.99.1'
+require 'active_record'
 
 require File.dirname(__FILE__) + '/../init.rb'
 
@@ -9,3 +11,20 @@ require 'test/unit'
 require 'mocha'
 require 'action_controller/test_process'
 
+require 'active_record/fixtures'
+
+ActiveRecord::Base.logger = Logger.new(File.dirname(__FILE__) + &quot;/debug.log&quot;)
+
+ActiveRecord::Base.configurations = YAML::load(IO.read(File.dirname(__FILE__) + &quot;/db/database.yml&quot;))
+ActiveRecord::Base.establish_connection(ENV[&quot;DB&quot;] || &quot;sqlite3&quot;)
+ActiveRecord::Migration.verbose = false
+load(File.join(File.dirname(__FILE__), &quot;db&quot;, &quot;schema.rb&quot;))
+
+Dir[&quot;#{File.dirname(__FILE__)}/fixtures/*.rb&quot;].each {|file| require file }
+
+
+class Test::Unit::TestCase #:nodoc:
+  self.fixture_path = File.dirname(__FILE__) + &quot;/fixtures/&quot;
+  self.use_transactional_fixtures = true
+  self.use_instantiated_fixtures  = false
+end
\ No newline at end of file</diff>
      <filename>test/test_helper.rb</filename>
    </modified>
  </modified>
  <removed type="array">
    <removed>
      <filename>test/fixtures/month.html.erb</filename>
    </removed>
    <removed>
      <filename>test/fixtures/month_builder.html.erb</filename>
    </removed>
  </removed>
  <parents type="array">
    <parent>
      <id>f4e1c85a0584b7d1abf16d6e657fca85a8a945fb</id>
    </parent>
  </parents>
  <author>
    <name>Daniel Morrison</name>
    <email>daniel@collectiveidea.com</email>
  </author>
  <url>http://github.com/collectiveidea/calendar_builder/commit/e003ae845f35f38fcc2e1442d13fd2d67dc29d27</url>
  <id>e003ae845f35f38fcc2e1442d13fd2d67dc29d27</id>
  <committed-date>2008-02-26T13:27:00-08:00</committed-date>
  <authored-date>2008-02-26T13:27:00-08:00</authored-date>
  <message>Cleaned up and tested the event finders.</message>
  <tree>69c0923d09275941f50b1e5d5369e66051fb52a4</tree>
  <committer>
    <name>Daniel Morrison</name>
    <email>daniel@collectiveidea.com</email>
  </committer>
</commit>
