Permalink
Browse files

patch applied to fix issue #92: nil object option causes CalendarDate…

…Select.calendar_date_select(object, method, options) to not use object. Thanks, sskirby!
  • Loading branch information...
1 parent 7c39ee6 commit 9baa458f88fca34d8e4762317f02590fca3c91fe @timcharper committed Mar 24, 2008
Showing with 13 additions and 1 deletion.
  1. +4 −0 CHANGELOG
  2. +1 −1 lib/calendar_date_select.rb
  3. +8 −0 test/functional/calendar_date_select_test.rb
View
@@ -1,3 +1,7 @@
+== Version 1.10.4 ==
+Mar 24, 2008
+ * patch applied to fix issue #92: nil object option causes CalendarDateSelect.calendar_date_select(object, method, options) to not use object. Thanks, sskirby!
+
== Version 1.10.3 ==
Mar 24. 2008
* Fixed active scaffold integration bug. Thanks tapajos!
@@ -139,7 +139,7 @@ def calendar_date_select_process_options(options)
end
def calendar_date_select(object, method, options={})
- obj = options.include?(:object) ? options[:object] : instance_eval("@#{object}")
+ obj = options[:object] || instance_variable_get("@#{object}")
if !options.include?(:time) && obj.class.respond_to?("columns_hash")
column_type = (obj.class.columns_hash[method.to_s].type rescue nil)
@@ -145,5 +145,13 @@ def test__tag__formats_text_correctly_time_with_format
assert_no_match(/12:01 AM/, output, "Should not have outputted a time")
assert_match('2007-01-02', output, "Should have outputted a correctly formatted time")
end
+
+ def test__nil_object_option__should_disregard
+ @model.start_datetime = Time.parse("January 2, 2007 12:00 AM")
+ output = calendar_date_select(:model, :start_datetime, :time => true, :object => nil)
+ assert_match(CalendarDateSelect.format_date(@model.start_datetime), output, "Should have outputted a time")
+ end
end
+
+

0 comments on commit 9baa458

Please sign in to comment.