Skip to content

Commit

Permalink
Render the proper value so that the table sorts correctly by last edited
Browse files Browse the repository at this point in the history
  • Loading branch information
hectorcorrea committed Sep 27, 2022
1 parent aca0bf4 commit aa55dbc
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
2 changes: 1 addition & 1 deletion app/views/collections/_dataset_table.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<span title="<%= ds.curator&.display_name %>"><%= ds.curator&.uid %></span>
</td>
<td><%= ds.state %></td>
<td>
<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
2 changes: 1 addition & 1 deletion app/views/users/_dataset_table.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<span title="<%= ds.curator&.display_name %>"><%= ds.curator&.uid %></span>
</td>
<td><%= ds.state %></td>
<td>
<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 aa55dbc

Please sign in to comment.