Skip to content

Commit

Permalink
fix: prevent time helper conflicts
Browse files Browse the repository at this point in the history
Closes #790
  • Loading branch information
mhenrixon committed Feb 7, 2024
1 parent cddcc08 commit 392c753
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions lib/sidekiq_unique_jobs/web/helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ def redirect_to(subpath)
#
# @return [String] a html safe string with relative time information
#
def relative_time(time)
def _relative_time(time)
stamp = time.getutc.iso8601
%(<time class="ltr" dir="ltr" title="#{stamp}" datetime="#{stamp}">#{time}</time>)
end
Expand All @@ -145,12 +145,12 @@ def relative_time(time)
#
# @return [String] a html safe string with relative time information
#
def safe_relative_time(time)
def _safe_relative_time(time)
return unless time

time = parse_time(time)

relative_time(time)
_relative_time(time)
end

#
Expand Down
2 changes: 1 addition & 1 deletion lib/sidekiq_unique_jobs/web/views/changelogs.erb
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
<tbody>
<% @changelogs.each do |changelog| %>
<tr class="changelog-row">
<td><%= safe_relative_time(changelog['time']) || "bogus" %></td>
<td><%= _safe_relative_time(changelog['time']) || "bogus" %></td>
<td><%= changelog["digest"] %></td>
<td><%= changelog["script"] %></td>
<td><%= changelog["job_id"] %></td>
Expand Down
4 changes: 2 additions & 2 deletions lib/sidekiq_unique_jobs/web/views/lock.erb
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
<% @lock.locked_jids(with_values: true).each do |job_id, time| %>
<tr>
<td><%= job_id %></td>
<td><%= safe_relative_time(time.to_f) %></td>
<td><%= _safe_relative_time(time.to_f) %></td>
<td>
<form action="<%= root_path %>locks/<%= @lock.key %>/jobs/<%= job_id %>/delete" method="get">
<%= csrf_tag %>
Expand All @@ -92,7 +92,7 @@
<tbody>
<% @lock.changelogs.each do |entry| %>
<tr>
<td scope="row"><%= safe_relative_time(entry["time"].to_f) %></td>
<td scope="row"><%= _safe_relative_time(entry["time"].to_f) %></td>
<td><%= entry["job_id"] %></td>
<td><%= entry["message"] %></td>
<td><%= entry["script"] %></td>
Expand Down
2 changes: 1 addition & 1 deletion lib/sidekiq_unique_jobs/web/views/locks.erb
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
<td><a href="<%= root_path %>locks/<%= lock.key %>"><%= lock.key %></a></td>
<td><%= lock.info["lock"] %></td>
<td><%= lock.locked.count %></td>
<td><%= safe_relative_time(lock.created_at) %></td>
<td><%= _safe_relative_time(lock.created_at) %></td>
</tr>
</tbody>
<% end %>
Expand Down
4 changes: 2 additions & 2 deletions spec/sidekiq_unique_jobs/web/helpers_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ def params

let(:helper) { SidekiqUniqueJobs::WebHelpers.new }

describe "#safe_relative_time" do
subject(:safe_relative_time) { helper.safe_relative_time(time) }
describe "#_safe_relative_time" do
subject(:safe_relative_time) { helper._safe_relative_time(time) }

let(:frozen_time) { Time.new(1982, 6, 8, 14, 15, 34) }
let(:time) { Time.now.to_f }
Expand Down

0 comments on commit 392c753

Please sign in to comment.