Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Changeset 9058

Show
Ignore:
Timestamp:
03/18/08 22:31:19 (4 months ago)
Author:
rick
Message:

[tz_time plugin] fix previous attempt at fixing #10058

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • plugins/tztime/lib/tz_time_helpers/active_record_methods.rb

    r8815 r9058  
    1919            end 
    2020          end 
    21         end 
    22          
    23         define_method "#{attribute}=" do |local_time| 
    24           fixed = (local_time.acts_like?(:time) || local_time.acts_like?(:date)) ? TzTime.at(local_time) : nil 
    25           write_attribute(attribute, fixed) 
     21 
     22          define_method "#{attribute}=" do |local_time| 
     23            fixed = (local_time.acts_like?(:time) || local_time.acts_like?(:date)) ? TzTime.at(local_time) : nil  
     24            write_attribute attribute, fixed 
     25          end 
    2626        end 
    2727      end 
  • plugins/tztime/test/active_record_methods_test.rb

    r8815 r9058  
    3535      TzTime.zone = TimeZone["Central Time (US & Canada)"] 
    3636      @record = MockRecord.new 
     37      @record.instance_variable_set(:@due_on, Time.utc(2006, 1, 1)) 
    3738    end 
    3839     
    3940    def test_should_access_utc_time_as_local_with_getter_method 
    40       @record.due_on = Time.utc(2006, 1, 1) 
    4141      assert_equal TzTime.local(2005, 12, 31, 18), @record.due_on 
    4242    end 
     
    4444    def test_should_fix_local_timezones 
    4545      @record.due_on = Time.utc(2006, 1, 1) 
    46       assert_equal TzTime.local(2005, 12, 31, 18), @record.due_on 
    47       @record.send :fix_timezone 
    48       assert_equal Time.utc(2006, 1, 1), @record[:due_on] 
     46      assert_equal TzTime.local(2006, 1, 1), @record.due_on 
     47      assert_equal TzTime.local(2006, 1, 1), @record[:due_on] 
    4948    end 
    5049     
    5150    def test_should_not_fix_utc_timezones 
    52       @record.due_on = Time.utc(2006, 1, 1) 
    53       @record.send :fix_timezone 
    5451      assert_equal Time.utc(2006, 1, 1), @record[:due_on] 
    5552    end 
    56      
    5753    def test_should_only_fix_timezones_that_have_been_written 
    58       @record.instance_variable_set(:@due_on, Time.utc(2006, 1, 1)) 
    59       @record.send :fix_timezone 
    6054      assert_equal TzTime.utc(2006, 1, 1), @record.due_on 
    6155    end