This provides more structure than just a simple span.
end
def friendly_date(date)
- tag.span(time_ago_in_words(date), :title => l(date, :format => :friendly))
+ tag.time(time_ago_in_words(date), :title => l(date, :format => :friendly), :datetime => date.xmlschema)
end
def friendly_date_ago(date)
- tag.span(time_ago_in_words(date, :scope => :"datetime.distance_in_words_ago"), :title => l(date, :format => :friendly))
+ tag.time(time_ago_in_words(date, :scope => :"datetime.distance_in_words_ago"), :title => l(date, :format => :friendly), :datetime => date.xmlschema)
end
def body_class
def test_friendly_date
date = friendly_date(Time.utc(2014, 3, 5, 18, 58, 23))
- assert_match %r{^<span title=" *5 March 2014 at 18:58">.*</span>$}, date
+ assert_match %r{^<time title=" *5 March 2014 at 18:58" datetime="2014-03-05T18:58:23Z">.*</time>$}, date
date = friendly_date(Time.now.utc - 1.hour)
- assert_match %r{^<span title=".*">about 1 hour</span>$}, date
+ assert_match %r{^<time title=".*">about 1 hour</time>$}, date
date = friendly_date(Time.now.utc - 2.days)
- assert_match %r{^<span title=".*">2 days</span>$}, date
+ assert_match %r{^<time title=".*">2 days</time>$}, date
date = friendly_date(Time.now.utc - 3.weeks)
- assert_match %r{^<span title=".*">21 days</span>$}, date
+ assert_match %r{^<time title=".*">21 days</time>$}, date
date = friendly_date(Time.now.utc - 4.months)
- assert_match %r{^<span title=".*">4 months</span>$}, date
+ assert_match %r{^<time title=".*">4 months</time>$}, date
end
def test_body_class; end
date = Time.utc(2014, 3, 5, 21, 37, 45)
user = create(:user)
- assert_match %r{^Created by anonymous <abbr title="Wed, 05 Mar 2014 21:37:45 \+0000"><span title=" 5 March 2014 at 21:37">.* ago</span></abbr>$}, note_event("opened", date, nil)
- assert_match %r{^Resolved by <a href="/user/#{ERB::Util.u(user.display_name)}">#{user.display_name}</a> <abbr title="Wed, 05 Mar 2014 21:37:45 \+0000"><span title=" 5 March 2014 at 21:37">.* ago</span></abbr>$}, note_event("closed", date, user)
+ assert_match %r{^Created by anonymous <abbr title="Wed, 05 Mar 2014 21:37:45 \+0000"><time title=" 5 March 2014 at 21:37" datetime="2014-03-05T21:37:45Z">.* ago</time></abbr>$}, note_event("opened", date, nil)
+ assert_match %r{^Resolved by <a href="/user/#{ERB::Util.u(user.display_name)}">#{user.display_name}</a> <abbr title="Wed, 05 Mar 2014 21:37:45 \+0000"><time title=" 5 March 2014 at 21:37" datetime="2014-03-05T21:37:45Z">.* ago</time></abbr>$}, note_event("closed", date, user)
end
def test_note_author
assert_equal "Active until the user logs in.", block_status(block)
block = create(:user_block, :needs_view, :ends_at => Time.now.utc + 1.hour)
- assert_match %r{^Ends in <span title=".*">about 1 hour</span> and after the user has logged in\.$}, block_status(block)
+ assert_match %r{^Ends in <time title=".*" datetime=".*">about 1 hour</time> and after the user has logged in\.$}, block_status(block)
block = create(:user_block, :ends_at => Time.now.utc + 1.hour)
- assert_match %r{^Ends in <span title=".*">about 1 hour</span>\.$}, block_status(block)
+ assert_match %r{^Ends in <time title=".* datetime=".*">about 1 hour</time>\.$}, block_status(block)
end
def test_block_duration_in_words