Commit a9d19fa8 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets
Browse files

Merge branch 'master' of

parents 259a7d7b 8e9f740d
......@@ -204,12 +204,16 @@ def broadcast_message
# Returns an HTML-safe String
def time_ago_with_tooltip(time, placement: 'top', html_class: 'time_ago', skip_js: false)
element = content_tag :time, time.to_s,
class: "#{html_class} js-timeago",
class: "#{html_class} js-timeago js-timeago-pending",
datetime: time.getutc.iso8601,
title: time.in_time_zone.stamp('Aug 21, 2011 9:23pm'),
data: { toggle: 'tooltip', placement: placement, container: 'body' }
element += javascript_tag "$('.js-timeago').last().timeago()" unless skip_js
unless skip_js
element << javascript_tag(
......@@ -263,11 +263,12 @@ def element(*arguments)
it 'includes a default js-timeago class' do
expect(element.attr('class')).to eq 'time_ago js-timeago'
expect(element.attr('class')).to eq 'time_ago js-timeago js-timeago-pending'
it 'accepts a custom html_class' do
expect(element(html_class: 'custom_class').attr('class')).to eq 'custom_class js-timeago'
expect(element(html_class: 'custom_class').attr('class')).
to eq 'custom_class js-timeago js-timeago-pending'
it 'accepts a custom tooltip placement' do
......@@ -278,7 +279,7 @@ def element(*arguments)
el = element.next_element
expect( eq 'script'
expect(el.text).to include "$('.js-timeago').last().timeago()"
expect(el.text).to include "$('.js-timeago-pending').removeClass('js-timeago-pending').timeago()"
it 'allows the script tag to be excluded' do
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment