9587: sort order issue
authorradhika <radhika@curoverse.com>
Fri, 2 Jun 2017 21:31:04 +0000 (17:31 -0400)
committerradhika <radhika@curoverse.com>
Fri, 2 Jun 2017 21:31:04 +0000 (17:31 -0400)
apps/workbench/app/controllers/trash_items_controller.rb
apps/workbench/app/views/trash_items/_show_trash_items.html.erb
apps/workbench/app/views/trash_items/_show_trash_rows.html.erb
apps/workbench/app/views/trash_items/_untrash_item.html.erb
services/api/test/functional/arvados/v1/collections_controller_test.rb

index bbc0b26c8354742a1bc445c2a7d8557e5b5a47fa..db3457cc30c5ea52397158282ceb92bf4c5b4e61 100644 (file)
@@ -12,6 +12,7 @@ class TrashItemsController < ApplicationController
     trashed_items
 
     if @objects.any?
+      @objects = @objects.sort_by { |obj| obj.created_at }.reverse
       @next_page_filters = next_page_filters('<=')
       @next_page_href = url_for(partial: :trash_rows,
                                 filters: @next_page_filters.to_json)
index 153d7d033397d93d58dddb7fba1c022c5ea5b20b..6776e7a815fb96fbe60f83e0186c58afda4404fe 100644 (file)
       <colgroup>
         <col width="5%" />
         <col width="20%" />
+        <col width="15%" />
+        <col width="15%" />
         <col width="10%" />
-        <col width="10%" />
-        <col width="10%" />
-        <col width="40%" />
+        <col width="30%" />
         <col width="5%" />
       </colgroup>
 
index d617d8d2ea0c4a139daa00f45db6eb2e74387421..8db21ed75a10aa2fd213d282ee0859d5ca2b0555 100644 (file)
@@ -1,4 +1,4 @@
-<% @objects.sort_by { |obj| obj.created_at }.reverse.each do |obj| %>
+<% @objects.each do |obj| %>
     <tr data-object-uuid="<%= obj.uuid %>" data-kind="<%= obj.kind %>" >
       <td>
         <% if obj.editable? %>
@@ -8,9 +8,9 @@
       <td>
         <%= if !obj.name.blank? then obj.name else obj.uuid end %>
       <td>
-        <%= obj.created_at.to_s if obj.created_at %>
+        <%= render_localized_date(obj.created_at) if obj.created_at %>
       <td>
-        <%= obj.trash_at.to_s if obj.trash_at %>
+        <%= render_localized_date(obj.trash_at) if obj.trash_at %>
       </td>
       <td>
         <%= link_to_if_arvados_object obj.owner_uuid, friendly_name: true %>
@@ -22,7 +22,7 @@
           <%= file_path %><br />
         <% end %>
         <% if obj.files.length > 3 %>
-          &vellip;
+          <%= "(#{obj.files.length-3} more files)" %>
         <% end %>
       </td>
       <td>
index 2ba9dc93f189bf5840a6f4ab11daa3b037412f43..8732531747ace263811412bf35381e72e97cb9c8 100644 (file)
@@ -1,7 +1,7 @@
 <% if object.editable? %>
-  <% msg = "Un-trash '" + if !object.name.blank? then object.name else object.uuid end + "'?" %>
+  <% msg = "Untrash '" + if !object.name.blank? then object.name else object.uuid end + "'?" %>
   <%= link_to({action: 'untrash_items', selection: [object.uuid]}, remote: true, method: :post,
-      data: {confirm: msg}) do %>
+      title: "Untrash", data: {confirm: msg}) do %>
     <i class="fa fa-fw fa-recycle"></i>
   <% end %>
 <% end %>
index a31ad8af03b09fd54dd80360ad8eefa65328e298..761898560a7caa60cf1c9610ea02851493240393 100644 (file)
@@ -1024,4 +1024,22 @@ EOS
       assert_operator c.delete_at, :>=, time_before_trashing + Rails.configuration.default_trash_lifetime
     end
   end
+
+  test 'untrash a trashed collection' do
+    authorize_with :active
+    post :untrash, {
+      id: collections(:expired_collection).uuid,
+    }
+    assert_response 200
+    assert_equal false, json_response['is_trashed']
+    assert_nil json_response['trash_at']
+  end
+
+  test 'untrash error on not trashed collection' do
+    authorize_with :active
+    post :untrash, {
+      id: collections(:collection_owned_by_active).uuid,
+    }
+    assert_response 422
+  end
 end