From 9baa458f88fca34d8e4762317f02590fca3c91fe Mon Sep 17 00:00:00 2001 From: Tim Harper Date: Mon, 24 Mar 2008 10:13:11 -0600 Subject: [PATCH] patch applied to fix issue #92: nil object option causes CalendarDateSelect.calendar_date_select(object, method, options) to not use object. Thanks, sskirby! --- CHANGELOG | 4 ++++ lib/calendar_date_select.rb | 2 +- test/functional/calendar_date_select_test.rb | 8 ++++++++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index cdd1017..28a3949 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -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! diff --git a/lib/calendar_date_select.rb b/lib/calendar_date_select.rb index d1e379e..5ed6960 100644 --- a/lib/calendar_date_select.rb +++ b/lib/calendar_date_select.rb @@ -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) diff --git a/test/functional/calendar_date_select_test.rb b/test/functional/calendar_date_select_test.rb index 080de0c..cbae3e0 100644 --- a/test/functional/calendar_date_select_test.rb +++ b/test/functional/calendar_date_select_test.rb @@ -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 + +