diff --git a/app/controllers/admin/signature_sheets_controller.rb b/app/controllers/admin/signature_sheets_controller.rb
index 60299c5a6..4a6777695 100644
--- a/app/controllers/admin/signature_sheets_controller.rb
+++ b/app/controllers/admin/signature_sheets_controller.rb
@@ -1,7 +1,7 @@
class Admin::SignatureSheetsController < Admin::BaseController
def index
- @signature_sheets = SignatureSheet.all
+ @signature_sheets = SignatureSheet.all.order(created_at: :desc)
end
def new
@@ -29,4 +29,4 @@ class Admin::SignatureSheetsController < Admin::BaseController
params.require(:signature_sheet).permit(:signable_type, :signable_id, :document_numbers)
end
-end
\ No newline at end of file
+end
diff --git a/app/views/admin/signature_sheets/index.html.erb b/app/views/admin/signature_sheets/index.html.erb
index 74241b5b0..be35d8b6b 100644
--- a/app/views/admin/signature_sheets/index.html.erb
+++ b/app/views/admin/signature_sheets/index.html.erb
@@ -19,7 +19,7 @@
<%= signature_sheet.author.name %>
- <%= l(signature_sheet.created_at, format: :short) %>
+ <%= l(signature_sheet.created_at, format: :long) %>
|
<% end %>
diff --git a/app/views/admin/signature_sheets/show.html.erb b/app/views/admin/signature_sheets/show.html.erb
index 0c2536b34..126e363ba 100644
--- a/app/views/admin/signature_sheets/show.html.erb
+++ b/app/views/admin/signature_sheets/show.html.erb
@@ -2,7 +2,7 @@
<%= t("admin.signature_sheets.show.created_at") %>
-
<%= l(@signature_sheet.created_at, format: :short) %>
+
<%= l(@signature_sheet.created_at, format: :long) %>
•
<%= t("admin.signature_sheets.show.author") %>
<%= @signature_sheet.author.name %>
@@ -41,4 +41,4 @@
<%= t("admin.signature_sheets.show.loading") %>
-<% end %>
\ No newline at end of file
+<% end %>
diff --git a/spec/features/admin/signature_sheets_spec.rb b/spec/features/admin/signature_sheets_spec.rb
index bcde7bfc0..2417fb176 100644
--- a/spec/features/admin/signature_sheets_spec.rb
+++ b/spec/features/admin/signature_sheets_spec.rb
@@ -7,15 +7,28 @@ feature 'Signature sheets' do
login_as(admin.user)
end
- scenario "Index" do
- 3.times { create(:signature_sheet) }
+ context "Index" do
+ scenario 'Lists all signature_sheets' do
+ 3.times { create(:signature_sheet) }
- visit admin_signature_sheets_path
+ visit admin_signature_sheets_path
- expect(page).to have_css(".signature_sheet", count: 3)
+ expect(page).to have_css(".signature_sheet", count: 3)
- SignatureSheet.all.each do |signature_sheet|
- expect(page).to have_content signature_sheet.name
+ SignatureSheet.all.each do |signature_sheet|
+ expect(page).to have_content signature_sheet.name
+ end
+ end
+
+ scenario 'Orders signature_sheets by created_at DESC' do
+ signature_sheet1 = create(:signature_sheet)
+ signature_sheet2 = create(:signature_sheet)
+ signature_sheet3 = create(:signature_sheet)
+
+ visit admin_signature_sheets_path
+
+ expect(signature_sheet3.name).to appear_before(signature_sheet2.name)
+ expect(signature_sheet2.name).to appear_before(signature_sheet1.name)
end
end
@@ -78,7 +91,7 @@ feature 'Signature sheets' do
expect(page).to have_content "Citizen proposal #{proposal.id}"
expect(page).to have_content "12345678Z, 123A, 123B"
- expect(page).to have_content signature_sheet.created_at.strftime("%d %b %H:%M")
+ expect(page).to have_content signature_sheet.created_at.strftime("%B %d, %Y %H:%M")
expect(page).to have_content user.name
within("#document_count") do