Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 3 commits into from
Sep 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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