Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added support for nil date input. #56

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/i18n_alchemy/date_parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ def valid_for_localization?(value)
end

def valid_for_parsing?(value)
return false if value.nil?
!valid_for_localization?(value)
end
end
Expand Down
1 change: 0 additions & 1 deletion lib/i18n_alchemy/proxy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ def try(*a, &b)
def method_missing(*args, **kwargs, &block)
@target.send(*args, **kwargs, &block)
end
ruby2_keywords :method_missing
else
def method_missing(*args, &block)
@target.send(*args, &block)
Expand Down
4 changes: 4 additions & 0 deletions test/i18n_alchemy/date_parser_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ def setup
@date = Date.new(2011, 12, 31)
end

def test_does_not_convert_nil
assert_nil @parser.parse(nil)
end

def test_does_not_convert_non_string_objects
assert_equal @date, @parser.parse(@date)
end
Expand Down