Skip to content

Commit

Permalink
Render the proper value so that the table sorts correctly by last edi…
Browse files Browse the repository at this point in the history
…ted (#443)

* Render the proper value so that the table sorts correctly by last edited

* Add pointer to Dataset documentation for future reference
  • Loading branch information
hectorcorrea committed Sep 27, 2022
1 parent 3f66d7f commit 85cb196
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
3 changes: 2 additions & 1 deletion app/views/collections/_dataset_table.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
<span title="<%= ds.curator&.display_name %>"><%= ds.curator&.uid %></span>
</td>
<td><%= ds.state %></td>
<td>
<!-- see https://datatables.net/manual/data/orthogonal-data for sorting options -->
<td class="last-edited" data-sort="<%= ds.updated_at %>">
<span title="<%= ds.updated_at.localtime %>"><%= distance_of_time_in_words_to_now(ds.updated_at) %></span>
</td>
</tr>
Expand Down
3 changes: 2 additions & 1 deletion app/views/users/_dataset_table.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
<span title="<%= ds.curator&.display_name %>"><%= ds.curator&.uid %></span>
</td>
<td><%= ds.state %></td>
<td>
<!-- see https://datatables.net/manual/data/orthogonal-data for sorting options -->
<td class="last-edited" data-sort="<%= ds.updated_at %>">
<span title="<%= ds.updated_at.localtime %>"><%= distance_of_time_in_words_to_now(ds.updated_at) %></span>
</td>
</tr>
Expand Down
16 changes: 16 additions & 0 deletions spec/system/user_show_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# frozen_string_literal: true
require "rails_helper"
RSpec.describe "User dashboard" do
describe "Sort by last edited uses the proper value" do
let(:user_admin) { FactoryBot.create :super_admin_user }
let(:work) { FactoryBot.create(:draft_work) }

it "renders the proper date value for sorting by last edited", js: true do
work_last_edited = work.updated_at.strftime("%Y-%m-%d %H:%M:%S %Z")
sort_value = '<td class="last-edited" data-sort="' + work_last_edited + '">'
sign_in user_admin
visit user_path(user_admin)
expect(page.html.include?(sort_value)).to be true
end
end
end

0 comments on commit 85cb196

Please sign in to comment.