From 6820a3f580c1a2e435eafa29541e9d285901bab9 Mon Sep 17 00:00:00 2001 From: Antonio Terceiro Date: Mon, 25 May 2009 12:52:13 -0300 Subject: [PATCH] ActionItem1050: better time formatting --- app/helpers/dates_helper.rb | 2 +- test/unit/dates_helper_test.rb | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/helpers/dates_helper.rb b/app/helpers/dates_helper.rb index c833455..3771905 100644 --- a/app/helpers/dates_helper.rb +++ b/app/helpers/dates_helper.rb @@ -35,7 +35,7 @@ module DatesHelper # formats a datetime for displaying. def show_time(time) if time - time.strftime(_('%d %B %Y, %H:%M')) + _('%{day} %{month} %{year}, %{hour}:%{minutes}') % { :year => time.year, :month => month_name(time.month), :day => time.day, :hour => time.hour, :minutes => time.min } else '' end diff --git a/test/unit/dates_helper_test.rb b/test/unit/dates_helper_test.rb index a002adc..fe3894e 100644 --- a/test/unit/dates_helper_test.rb +++ b/test/unit/dates_helper_test.rb @@ -131,9 +131,9 @@ class DatesHelperTest < Test::Unit::TestCase end should 'translate time' do - time = mock - expects(:_).with('%d %B %Y, %H:%M').returns('the time') - time.expects(:strftime).with('the time').returns('translated time') + time = Time.parse('25 May 2009, 12:47') + expects(:_).with('%{day} %{month} %{year}, %{hour}:%{minutes}').returns('translated time') + stubs(:_).with('May').returns("Maio") assert_equal 'translated time', show_time(time) end -- libgit2 0.21.2