<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -9,12 +9,12 @@ require &quot;redcloth&quot;
 require 'date'
 require 'time'
 
-# Commented the following line because of #744. It prevented rake db:migrate to 
+# Commented the following line because of #744. It prevented rake db:migrate to
 # run because this tag went looking for the taggings table that did not exist
-# when you feshly create a new database
-# Old comment: We need this in development mode, or you get 'method missing' errors
+# when you feshly create a new database Old comment: We need this in development
+# mode, or you get 'method missing' errors
 # 
-# Tag 
+# Tag
 
 class ApplicationController &lt; ActionController::Base
 
@@ -160,7 +160,34 @@ class ApplicationController &lt; ActionController::Base
       response.content_type = 'text/html'
     end
   end
-   
+  
+  def create_todo_from_recurring_todo(rt, date=nil)
+    # create todo and initialize with data from recurring_todo rt
+    todo = current_user.todos.build( { :description =&gt; rt.description, :notes =&gt; rt.notes, :project_id =&gt; rt.project_id, :context_id =&gt; rt.context_id})
+    
+    # set dates
+    todo.recurring_todo_id = rt.id
+    todo.due = rt.get_due_date(date)
+    # make sure that show_from is not in the past
+    show_from_date = rt.get_show_from_date(date)
+    todo.show_from = show_from_date &lt; Time.now.utc ? nil : show_from_date
+    
+    saved = todo.save
+    if saved
+      todo.tag_with(rt.tag_list, current_user)
+      todo.tags.reload 
+    end
+
+    # increate number of occurences created from recurring todo
+    rt.inc_occurences
+    
+    # mark recurring todo complete if there are no next actions left
+    checkdate = todo.due.nil? ? todo.show_from : todo.due
+    rt.toggle_completion! unless rt.has_next_todo(checkdate)
+    
+    return saved ? todo : nil
+  end
+     
   protected
   
   def admin_login_required
@@ -192,7 +219,7 @@ class ApplicationController &lt; ActionController::Base
   def openid_enabled?
     self.class.openid_enabled?
   end
-  
+
   private
         
   def parse_date_per_user_prefs( s )
@@ -231,29 +258,5 @@ class ApplicationController &lt; ActionController::Base
   def set_time_zone
     Time.zone = current_user.prefs.time_zone if logged_in?
   end
-
-  def create_todo_from_recurring_todo(rt, date=nil)
-    # create todo and initialize with data from recurring_todo rt
-    todo = current_user.todos.build( { :description =&gt; rt.description, :notes =&gt; rt.notes, :project_id =&gt; rt.project_id, :context_id =&gt; rt.context_id})
-    
-    # set dates
-    todo.due = rt.get_due_date(date)
-    todo.show_from = rt.get_show_from_date(date)
-    todo.recurring_todo_id = rt.id
-    saved = todo.save
-    if saved
-      todo.tag_with(rt.tag_list, current_user)
-      todo.tags.reload 
-    end
-
-    # increate number of occurences created from recurring todo
-    rt.inc_occurences
-    
-    # mark recurring todo complete if there are no next actions left
-    checkdate = todo.due.nil? ? todo.show_from : todo.due
-    rt.toggle_completion! unless rt.has_next_todo(checkdate)
-    
-    return saved ? todo : nil
-  end
   
 end</diff>
      <filename>app/controllers/application.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,113 +1,113 @@
-module AuthenticatedTestHelper
-  # Sets the current user in the session from the user fixtures.
-  def login_as(user)
-    @request.session['user_id'] = user ? users(user).id : nil
-  end
-
-  def content_type(type)
-    @request.env['Content-Type'] = type
-  end
-
-  def accept(accept)
-    @request.env[&quot;HTTP_ACCEPT&quot;] = accept
-  end
-
-  def authorize_as(user)
-    if user
-      @request.env[&quot;HTTP_AUTHORIZATION&quot;] = &quot;Basic #{Base64.encode64(&quot;#{users(user).login}:test&quot;)}&quot;
-      accept       'application/xml'
-      content_type 'application/xml'
-    else
-      @request.env[&quot;HTTP_AUTHORIZATION&quot;] = nil
-      accept       nil
-      content_type nil
-    end
-  end
-
-  # http://project.ioni.st/post/217#post-217
-  #
-  #  def test_new_publication
-  #    assert_difference(Publication, :count) do
-  #      post :create, :publication =&gt; {...}
-  #      # ...
-  #    end
-  #  end
-  # 
-  def assert_difference(object, method = nil, difference = 1)
-    initial_value = object.send(method)
-    yield
-    assert_equal initial_value + difference, object.send(method), &quot;#{object}##{method}&quot;
-  end
-
-  def assert_no_difference(object, method, &amp;block)
-    assert_difference object, method, 0, &amp;block
-  end
-
-  # Assert the block redirects to the login
-  # 
-  #   assert_requires_login(:bob) { |c| c.get :edit, :id =&gt; 1 }
-  #
-  def assert_requires_login(login = nil)
-    yield HttpLoginProxy.new(self, login)
-  end
-
-  def assert_http_authentication_required(login = nil)
-    yield XmlLoginProxy.new(self, login)
-  end
-
-  def reset!(*instance_vars)
-    instance_vars = [:controller, :request, :response] unless instance_vars.any?
-    instance_vars.collect! { |v| &quot;@#{v}&quot;.to_sym }
-    instance_vars.each do |var|
-      instance_variable_set(var, instance_variable_get(var).class.new)
-    end
-  end
-end
-
-class BaseLoginProxy
-  attr_reader :controller
-  attr_reader :options
-  def initialize(controller, login)
-    @controller = controller
-    @login      = login
-  end
-
-  private
-    def authenticated
-      raise NotImplementedError
-    end
-    
-    def check
-      raise NotImplementedError
-    end
-    
-    def method_missing(method, *args)
-      @controller.reset!
-      authenticate
-      @controller.send(method, *args)
-      check
-    end
-end
-
-class HttpLoginProxy &lt; BaseLoginProxy
-  protected
-    def authenticate
-      @controller.login_as @login if @login
-    end
-    
-    def check
-      @controller.assert_redirected_to :controller =&gt; 'account', :action =&gt; 'login'
-    end
-end
-
-class XmlLoginProxy &lt; BaseLoginProxy
-  protected
-    def authenticate
-      @controller.accept 'application/xml'
-      @controller.authorize_as @login if @login
-    end
-    
-    def check
-      @controller.assert_response 401
-    end
+module AuthenticatedTestHelper
+  # Sets the current user in the session from the user fixtures.
+  def login_as(user)
+    @request.session['user_id'] = user ? users(user).id : nil
+  end
+  
+  def content_type(type)
+    @request.env['Content-Type'] = type
+  end
+
+  def accept(accept)
+    @request.env[&quot;HTTP_ACCEPT&quot;] = accept
+  end
+
+  def authorize_as(user)
+    if user
+      @request.env[&quot;HTTP_AUTHORIZATION&quot;] = &quot;Basic #{Base64.encode64(&quot;#{users(user).login}:test&quot;)}&quot;
+      accept       'application/xml'
+      content_type 'application/xml'
+    else
+      @request.env[&quot;HTTP_AUTHORIZATION&quot;] = nil
+      accept       nil
+      content_type nil
+    end
+  end
+
+  # http://project.ioni.st/post/217#post-217
+  #
+  #  def test_new_publication
+  #    assert_difference(Publication, :count) do
+  #      post :create, :publication =&gt; {...}
+  #      # ...
+  #    end
+  #  end
+  # 
+  def assert_difference(object, method = nil, difference = 1)
+    initial_value = object.send(method)
+    yield
+    assert_equal initial_value + difference, object.send(method), &quot;#{object}##{method}&quot;
+  end
+
+  def assert_no_difference(object, method, &amp;block)
+    assert_difference object, method, 0, &amp;block
+  end
+
+  # Assert the block redirects to the login
+  # 
+  #   assert_requires_login(:bob) { |c| c.get :edit, :id =&gt; 1 }
+  #
+  def assert_requires_login(login = nil)
+    yield HttpLoginProxy.new(self, login)
+  end
+
+  def assert_http_authentication_required(login = nil)
+    yield XmlLoginProxy.new(self, login)
+  end
+
+  def reset!(*instance_vars)
+    instance_vars = [:controller, :request, :response] unless instance_vars.any?
+    instance_vars.collect! { |v| &quot;@#{v}&quot;.to_sym }
+    instance_vars.each do |var|
+      instance_variable_set(var, instance_variable_get(var).class.new)
+    end
+  end
+end
+
+class BaseLoginProxy
+  attr_reader :controller
+  attr_reader :options
+  def initialize(controller, login)
+    @controller = controller
+    @login      = login
+  end
+
+  private
+    def authenticated
+      raise NotImplementedError
+    end
+    
+    def check
+      raise NotImplementedError
+    end
+    
+    def method_missing(method, *args)
+      @controller.reset!
+      authenticate
+      @controller.send(method, *args)
+      check
+    end
+end
+
+class HttpLoginProxy &lt; BaseLoginProxy
+  protected
+    def authenticate
+      @controller.login_as @login if @login
+    end
+    
+    def check
+      @controller.assert_redirected_to :controller =&gt; 'account', :action =&gt; 'login'
+    end
+end
+
+class XmlLoginProxy &lt; BaseLoginProxy
+  protected
+    def authenticate
+      @controller.accept 'application/xml'
+      @controller.authorize_as @login if @login
+    end
+    
+    def check
+      @controller.assert_response 401
+    end
 end
\ No newline at end of file</diff>
      <filename>lib/authenticated_test_helper.rb</filename>
    </modified>
    <modified>
      <diff>@@ -18,5 +18,5 @@ class RecurringTodosControllerTest &lt; ActionController::TestCase
     xhr :post, :destroy, :id =&gt; 1, :_source_view =&gt; 'todo'
     assert_rjs :page, &quot;recurring_todo_1&quot;, :remove
   end
-    
+
 end</diff>
      <filename>test/functional/recurring_todos_controller_test.rb</filename>
    </modified>
    <modified>
      <diff>@@ -174,12 +174,14 @@ class RecurringTodoTest &lt; Test::Rails::TestCase
   def test_yearly_pattern
     # beginning of same year
     due_date = @yearly.get_due_date(Time.utc(2008,2,10)) # feb 10th
-    assert_equal @sunday, due_date # june 8th    
+    assert_equal @sunday, due_date # june 8th   
+    
     # same month, previous date
     due_date = @yearly.get_due_date(@saturday) # june 7th
     show_from_date = @yearly.get_show_from_date(@saturday) # june 7th
     assert_equal @sunday, due_date # june 8th
     assert_equal @sunday-5.days, show_from_date
+
     # same month, day after
     due_date = @yearly.get_due_date(@monday) # june 9th
     assert_equal Time.utc(2009,6,8), due_date # june 8th next year
@@ -197,7 +199,7 @@ class RecurringTodoTest &lt; Test::Rails::TestCase
     due_date = @yearly.get_due_date(Time.utc(2008,6,12)) # june 7th
     assert_equal Time.utc(2009,6,10), due_date # june 10th    
     
-    # test handling of nil 
+    # test handling of nil
     due_date1 = @yearly.get_due_date(nil) 
     due_date2 = @yearly.get_due_date(Time.now.utc + 1.day)
     assert_equal due_date1, due_date2
@@ -207,7 +209,7 @@ class RecurringTodoTest &lt; Test::Rails::TestCase
     due_date = @yearly.get_due_date(nil) 
     assert_equal due_date.year, this_year+2
   end
-
+  
   def test_toggle_completion
     t = @yearly
     assert_equal :active, t.current_state</diff>
      <filename>test/unit/recurring_todo_test.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>223cf93597cd7e0876015b1665bfe7e53d48e796</id>
    </parent>
  </parents>
  <author>
    <name>Reinier Balt</name>
    <email>lrbalt@gmail.com</email>
  </author>
  <url>http://github.com/bsag/tracks/commit/065f543a83657a555523e59cdfc1cbd44de0bd2b</url>
  <id>065f543a83657a555523e59cdfc1cbd44de0bd2b</id>
  <committed-date>2008-08-19T05:33:09-07:00</committed-date>
  <authored-date>2008-08-19T05:33:09-07:00</authored-date>
  <message>fix corner case where recurring todo with due in future and show_from in past did not create corresponding todo

you cannot add todos with show_from in the past</message>
  <tree>2df364320fe4f57392ab6c46ae7349ab1b982e5b</tree>
  <committer>
    <name>Reinier Balt</name>
    <email>lrbalt@gmail.com</email>
  </committer>
</commit>
