Skip to content

Commit 4cd7905

Browse files
committed
fix timeago.
1 parent 07e1a65 commit 4cd7905

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

app/helpers/application_helper.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,9 @@ def owner?(item)
7575
end
7676

7777
def timeago(time, options = {})
78-
options[:class]
7978
options[:class] = options[:class].blank? ? "timeago" : [options[:class],"timeago"].join(" ")
80-
content_tag(:abbr, "", options.merge(:title => time.iso8601)) if time
79+
options.merge!(title: time.iso8601)
80+
content_tag(:abbr, "", class: options[:class], title: time.iso8601) if time
8181
end
8282

8383
def render_page_title

spec/helpers/application_helper_spec.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,4 +94,11 @@
9494
expect(helper.owner?(item)).to be_falsey
9595
end
9696
end
97+
98+
describe 'timeago' do
99+
it 'should work' do
100+
t = Time.now
101+
expect(helper.timeago(t, class: "foo")).to eq "<abbr class=\"foo timeago\" title=\"#{t.iso8601}\"></abbr>"
102+
end
103+
end
97104
end

0 commit comments

Comments
 (0)