From d9fdc2e0f263b3d09cd182ead1ea79414cb4b15b Mon Sep 17 00:00:00 2001 From: Bertocq Date: Thu, 3 May 2018 12:19:14 +0200 Subject: [PATCH] Show votes associated to verified signatures --- app/controllers/admin/signature_sheets_controller.rb | 1 + app/views/admin/signature_sheets/show.html.erb | 6 ++++++ config/locales/en/admin.yml | 4 ++++ config/locales/es/admin.yml | 4 ++++ spec/features/admin/signature_sheets_spec.rb | 12 +++++++++--- 5 files changed, 24 insertions(+), 3 deletions(-) diff --git a/app/controllers/admin/signature_sheets_controller.rb b/app/controllers/admin/signature_sheets_controller.rb index 5c266a491..1eb4ca111 100644 --- a/app/controllers/admin/signature_sheets_controller.rb +++ b/app/controllers/admin/signature_sheets_controller.rb @@ -21,6 +21,7 @@ class Admin::SignatureSheetsController < Admin::BaseController def show @signature_sheet = SignatureSheet.find(params[:id]) + @voted_signatures = Vote.where(signature: @signature_sheet.signatures.verified).count end private diff --git a/app/views/admin/signature_sheets/show.html.erb b/app/views/admin/signature_sheets/show.html.erb index 126e363ba..8d9410d48 100644 --- a/app/views/admin/signature_sheets/show.html.erb +++ b/app/views/admin/signature_sheets/show.html.erb @@ -24,6 +24,12 @@ <%= t("admin.signature_sheets.show.verified", count: @signature_sheet.signatures.verified.count ) %> +
+ + <%= t("admin.signature_sheets.show.voted", + count: @voted_signatures) %> + +
diff --git a/config/locales/en/admin.yml b/config/locales/en/admin.yml index c03001722..1856bfd1a 100644 --- a/config/locales/en/admin.yml +++ b/config/locales/en/admin.yml @@ -1437,6 +1437,10 @@ en: one: "There is %{count} invalid signature" other: "There are %{count} invalid signatures" unverified_error: (Not verified by Census) + voted: + zero: "There is no votes created from the verified signatures." + one: "There is %{count} vote created from the verified signatures." + other: "There is %{count} votes created from verified signatures." loading: "There are still signatures that are being verified by the Census, please refresh the page in a few moments" stats: show: diff --git a/config/locales/es/admin.yml b/config/locales/es/admin.yml index 0e6a91fc0..c7a4108a7 100644 --- a/config/locales/es/admin.yml +++ b/config/locales/es/admin.yml @@ -1436,6 +1436,10 @@ es: one: "Hay %{count} firma inválida" other: "Hay %{count} firmas inválidas" unverified_error: (No verificadas por el Padrón) + voted: + zero: "No hay votos asociados con las firmas verificadas." + one: "Hay %{count} voto asociado a las firmas verificadas." + other: "Hay %{count} votos asociados a las firmas verificadas." loading: "Aún hay firmas que se están verificando por el Padrón, por favor refresca la página en unos instantes" stats: show: diff --git a/spec/features/admin/signature_sheets_spec.rb b/spec/features/admin/signature_sheets_spec.rb index 63d6c2607..d35e79dd3 100644 --- a/spec/features/admin/signature_sheets_spec.rb +++ b/spec/features/admin/signature_sheets_spec.rb @@ -39,10 +39,13 @@ describe "Signature sheets" do select "Citizen proposal", from: "signature_sheet_signable_type" fill_in "signature_sheet_signable_id", with: proposal.id - fill_in "signature_sheet_document_numbers", with: "12345678Z, 99999999Z" + fill_in "signature_sheet_document_numbers", with: "12345678Z, 1234567L, 99999999Z" click_button "Create signature sheet" expect(page).to have_content "Signature sheet created successfully" + expect(page).to have_content "There is 1 valid signature" + expect(page).to have_content "There is 1 vote created from the verified signatures" + expect(page).to have_content "There are 2 invalid signatures" visit proposal_path(proposal) @@ -58,10 +61,13 @@ describe "Signature sheets" do select "Investment", from: "signature_sheet_signable_type" fill_in "signature_sheet_signable_id", with: investment.id - fill_in "signature_sheet_document_numbers", with: "12345678Z, 99999999Z" + fill_in "signature_sheet_document_numbers", with: "12345678Z, 1234567L, 99999999Z" click_button "Create signature sheet" expect(page).to have_content "Signature sheet created successfully" + expect(page).to have_content "There is 1 valid signature" + expect(page).to have_content "There is 1 vote created from the verified signatures" + expect(page).to have_content "There are 2 invalid signatures" visit budget_investment_path(budget, investment) @@ -107,4 +113,4 @@ describe "Signature sheets" do end end -end \ No newline at end of file +end