Commit a29cb0b0cba752db36f8472310153840943523fa
1 parent
87ca5e8a
Exists in
master
and in
28 other branches
ActionItem26: displaying periods
git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@1879 3f533792-8f58-4932-b0fe-aaf55b0a4547
Showing
2 changed files
with
30 additions
and
0 deletions
Show diff stats
app/helpers/application_helper.rb
... | ... | @@ -475,6 +475,14 @@ module ApplicationHelper |
475 | 475 | end |
476 | 476 | end |
477 | 477 | |
478 | + def show_period(date1, date2 = nil) | |
479 | + if (date1 == date2) || (date2.nil?) | |
480 | + show_date(date1) | |
481 | + else | |
482 | + _('from %s to %s') % [show_date(date1), show_date(date2)] | |
483 | + end | |
484 | + end | |
485 | + | |
478 | 486 | def gravatar_url_for(email, options = {}) |
479 | 487 | # Ta dando erro de roteamento |
480 | 488 | url_for( { :gravatar_id => Digest::MD5.hexdigest(email), | ... | ... |
test/unit/application_helper_test.rb
... | ... | @@ -100,6 +100,28 @@ class ApplicationHelperTest < Test::Unit::TestCase |
100 | 100 | assert_not_nil theme_javascript |
101 | 101 | end |
102 | 102 | |
103 | + should 'generate period with two dates' do | |
104 | + date1 = mock | |
105 | + expects(:show_date).with(date1).returns('XXX') | |
106 | + date2 = mock | |
107 | + expects(:show_date).with(date2).returns('YYY') | |
108 | + expects(:_).with('from %s to %s').returns('from %s to %s') | |
109 | + assert_equal 'from XXX to YYY', show_period(date1, date2) | |
110 | + end | |
111 | + | |
112 | + should 'generate period with two equal dates' do | |
113 | + date1 = mock | |
114 | + expects(:show_date).with(date1).returns('XXX') | |
115 | + assert_equal 'XXX', show_period(date1, date1) | |
116 | + end | |
117 | + | |
118 | + should 'generate period with one date only' do | |
119 | + date1 = mock | |
120 | + expects(:show_date).with(date1).returns('XXX') | |
121 | + assert_equal 'XXX', show_period(date1) | |
122 | + end | |
123 | + | |
124 | + | |
103 | 125 | protected |
104 | 126 | |
105 | 127 | def content_tag(tag, content, options) | ... | ... |