Changes following PR review
* Internationalisation for admin fields * Correct typos * Additional tests * Replace ternary with if-then statement
This commit is contained in:
@@ -26,6 +26,11 @@ class Admin::SignatureSheetsController < Admin::BaseController
|
|||||||
private
|
private
|
||||||
|
|
||||||
def signature_sheet_params
|
def signature_sheet_params
|
||||||
params.require(:signature_sheet).permit(:signable_type, :signable_id, :document_numbers, :title, :required_fields_to_verify)
|
params.require(:signature_sheet).permit(
|
||||||
|
:signable_type,
|
||||||
|
:signable_id,
|
||||||
|
:title,
|
||||||
|
:required_fields_to_verify
|
||||||
|
)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -13,7 +13,11 @@ class SignatureSheet < ApplicationRecord
|
|||||||
validate :signable_found
|
validate :signable_found
|
||||||
|
|
||||||
def name
|
def name
|
||||||
title ? "#{signable_name} #{signable_id}: #{title}" : "#{signable_name} #{signable_id}"
|
if title.present?
|
||||||
|
"#{signable_name} #{signable_id}: #{title}"
|
||||||
|
else
|
||||||
|
"#{signable_name} #{signable_id}"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def signable_name
|
def signable_name
|
||||||
|
|||||||
@@ -300,6 +300,7 @@ en:
|
|||||||
body: "Message"
|
body: "Message"
|
||||||
title: "Title"
|
title: "Title"
|
||||||
signature_sheet:
|
signature_sheet:
|
||||||
|
title: "Title"
|
||||||
signable_type: "Signable type"
|
signable_type: "Signable type"
|
||||||
signable_id: "Signable ID"
|
signable_id: "Signable ID"
|
||||||
document_numbers: "Documents numbers"
|
document_numbers: "Documents numbers"
|
||||||
|
|||||||
@@ -302,6 +302,7 @@ es:
|
|||||||
body: "Mensaje"
|
body: "Mensaje"
|
||||||
title: "Título"
|
title: "Título"
|
||||||
signature_sheet:
|
signature_sheet:
|
||||||
|
title: "Título"
|
||||||
signable_type: "Tipo de hoja de firmas"
|
signable_type: "Tipo de hoja de firmas"
|
||||||
signable_id: "ID Propuesta ciudadana/Proyecto de gasto"
|
signable_id: "ID Propuesta ciudadana/Proyecto de gasto"
|
||||||
document_numbers: "Números de documentos"
|
document_numbers: "Números de documentos"
|
||||||
|
|||||||
@@ -118,12 +118,10 @@ FactoryBot.define do
|
|||||||
association :signable, factory: :proposal
|
association :signable, factory: :proposal
|
||||||
association :author, factory: :user
|
association :author, factory: :user
|
||||||
required_fields_to_verify { "123A, 456B, 789C" }
|
required_fields_to_verify { "123A, 456B, 789C" }
|
||||||
document_numbers "123A, 456B, 789C"
|
|
||||||
|
|
||||||
trait :with_title do
|
trait :with_title do
|
||||||
title { Faker::Lorem.sentence }
|
title { Faker::Lorem.sentence }
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
factory :signature do
|
factory :signature do
|
||||||
|
|||||||
@@ -145,7 +145,7 @@ describe "Signature sheets" do
|
|||||||
visit admin_signature_sheet_path(signature_sheet)
|
visit admin_signature_sheet_path(signature_sheet)
|
||||||
|
|
||||||
expect(page).to have_content "Citizen proposal #{proposal.id}: #{signature_sheet.title}"
|
expect(page).to have_content "Citizen proposal #{proposal.id}: #{signature_sheet.title}"
|
||||||
expect(page).to have_content "12345678Z, 123A, 123B"
|
expect(page).to have_content "12345678Z; 123A; 123B"
|
||||||
expect(page).to have_content signature_sheet.created_at.strftime("%B %d, %Y %H:%M")
|
expect(page).to have_content signature_sheet.created_at.strftime("%B %d, %Y %H:%M")
|
||||||
expect(page).to have_content user.name
|
expect(page).to have_content user.name
|
||||||
|
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ describe SignatureSheet do
|
|||||||
end
|
end
|
||||||
|
|
||||||
describe "#name" do
|
describe "#name" do
|
||||||
context "when name is nil" do
|
context "when title is nil" do
|
||||||
it "returns name for proposal signature sheets" do
|
it "returns name for proposal signature sheets" do
|
||||||
proposal = create(:proposal)
|
proposal = create(:proposal)
|
||||||
signature_sheet.signable = proposal
|
signature_sheet.signable = proposal
|
||||||
@@ -54,7 +54,7 @@ describe SignatureSheet do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context "when name is not nil" do
|
context "when title is not nil" do
|
||||||
let(:signature_sheet) { build(:signature_sheet, :with_title) }
|
let(:signature_sheet) { build(:signature_sheet, :with_title) }
|
||||||
|
|
||||||
it "returns name for proposal signature sheets" do
|
it "returns name for proposal signature sheets" do
|
||||||
@@ -71,6 +71,24 @@ describe SignatureSheet do
|
|||||||
expect(signature_sheet.name).to eq("Investment #{budget_investment.id}: #{signature_sheet.title}")
|
expect(signature_sheet.name).to eq("Investment #{budget_investment.id}: #{signature_sheet.title}")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context "when title is an empty string" do
|
||||||
|
let(:signature_sheet) { build(:signature_sheet, title: "") }
|
||||||
|
|
||||||
|
it "returns name for proposal signature sheets" do
|
||||||
|
proposal = create(:proposal)
|
||||||
|
signature_sheet.signable = proposal
|
||||||
|
|
||||||
|
expect(signature_sheet.name).to eq("Citizen proposal #{proposal.id}")
|
||||||
|
end
|
||||||
|
|
||||||
|
it "returns name for budget investment signature sheets" do
|
||||||
|
budget_investment = create(:budget_investment)
|
||||||
|
signature_sheet.signable = budget_investment
|
||||||
|
|
||||||
|
expect(signature_sheet.name).to eq("Investment #{budget_investment.id}")
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "#verify_signatures" do
|
describe "#verify_signatures" do
|
||||||
|
|||||||
Reference in New Issue
Block a user