Skip to content

Commit

Permalink
patch applied to fix issue #92: nil object option causes CalendarDate…
Browse files Browse the repository at this point in the history
…Select.calendar_date_select(object, method, options) to not use object. Thanks, sskirby!
  • Loading branch information
timcharper committed Mar 24, 2008
1 parent 7c39ee6 commit 9baa458
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
4 changes: 4 additions & 0 deletions 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!
Expand Down
2 changes: 1 addition & 1 deletion lib/calendar_date_select.rb
Expand Up @@ -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)
Expand Down
8 changes: 8 additions & 0 deletions test/functional/calendar_date_select_test.rb
Expand Up @@ -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.