Merge pull request #1312 from consul/signature-sheets-polish
Signature sheets polish
This commit is contained in:
@@ -22,14 +22,14 @@ class SignatureSheet < ActiveRecord::Base
|
||||
|
||||
def verify_signatures
|
||||
parsed_document_numbers.each do |document_number|
|
||||
signature = signatures.create(document_number: document_number)
|
||||
signature = self.signatures.where(document_number: document_number).first_or_create
|
||||
signature.verify
|
||||
end
|
||||
update(processed: true)
|
||||
end
|
||||
|
||||
def parsed_document_numbers
|
||||
document_numbers.split(/\W+/)
|
||||
document_numbers.split(/\r\n|\n|[,]/).collect {|d| d.gsub(/\s+/, '') }
|
||||
end
|
||||
|
||||
def signable_found
|
||||
|
||||
@@ -8,6 +8,11 @@
|
||||
<strong><%= @signature_sheet.author.name %></strong>
|
||||
</div>
|
||||
|
||||
<h3 id="document_count" class="block">
|
||||
<%= t("admin.signature_sheets.show.document_count") %>
|
||||
<%= @signature_sheet.signatures.count %>
|
||||
</h3>
|
||||
|
||||
<div class="callout margin-top">
|
||||
<p><strong><%= t("admin.signature_sheets.show.documents") %></strong></p>
|
||||
<%= simple_format @signature_sheet.document_numbers %>
|
||||
|
||||
@@ -6,7 +6,7 @@ end
|
||||
Delayed::Worker.destroy_failed_jobs = false
|
||||
Delayed::Worker.sleep_delay = 2
|
||||
Delayed::Worker.max_attempts = 3
|
||||
Delayed::Worker.max_run_time = 30.seconds
|
||||
Delayed::Worker.max_run_time = 30.minutes
|
||||
Delayed::Worker.read_ahead = 10
|
||||
Delayed::Worker.default_queue_name = 'default'
|
||||
Delayed::Worker.raise_signal_exceptions = :term
|
||||
|
||||
@@ -312,6 +312,7 @@ en:
|
||||
created_at: Created
|
||||
author: Author
|
||||
documents: Documents
|
||||
document_count: "Number of documents:"
|
||||
verified:
|
||||
one: "There is %{count} valid signature"
|
||||
other: "There are %{count} valid signatures"
|
||||
|
||||
@@ -310,6 +310,7 @@ es:
|
||||
created_at: Creado
|
||||
author: Autor
|
||||
documents: Documentos
|
||||
document_count: "Número de documentos:"
|
||||
verified:
|
||||
one: "Hay %{count} firma válida"
|
||||
other: "Hay %{count} firmas válidas"
|
||||
|
||||
@@ -59,6 +59,10 @@ feature 'Signature sheets' do
|
||||
expect(page).to have_content signature_sheet.created_at.strftime("%d %b %H:%M")
|
||||
expect(page).to have_content user.name
|
||||
|
||||
within("#document_count") do
|
||||
expect(page).to have_content 3
|
||||
end
|
||||
|
||||
within("#verified_signatures") do
|
||||
expect(page).to have_content 1
|
||||
end
|
||||
|
||||
@@ -76,6 +76,12 @@ describe SignatureSheet do
|
||||
|
||||
expect(signature_sheet.parsed_document_numbers).to eq(['123A', '456B', '789C', '123B'])
|
||||
end
|
||||
|
||||
it "strips spaces between number and letter" do
|
||||
signature_sheet.document_numbers = "123 A\n456 B \n 789C"
|
||||
|
||||
expect(signature_sheet.parsed_document_numbers).to eq(['123A', '456B', '789C'])
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
Reference in New Issue
Block a user