Add title to differentiate signature sheets
This commit is contained in:
committed by
Andrew Sims
parent
54c6b413ce
commit
1e4f539104
@@ -26,6 +26,6 @@ class Admin::SignatureSheetsController < Admin::BaseController
|
|||||||
private
|
private
|
||||||
|
|
||||||
def signature_sheet_params
|
def signature_sheet_params
|
||||||
params.require(:signature_sheet).permit(:signable_type, :signable_id, :required_fields_to_verify)
|
params.require(:signature_sheet).permit(:signable_type, :signable_id, :document_numbers, :title, :required_fields_to_verify)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ class SignatureSheet < ApplicationRecord
|
|||||||
validate :signable_found
|
validate :signable_found
|
||||||
|
|
||||||
def name
|
def name
|
||||||
"#{signable_name} #{signable_id}"
|
title ? "#{signable_name} #{signable_id}: #{title}" : "#{signable_name} #{signable_id}"
|
||||||
end
|
end
|
||||||
|
|
||||||
def signable_name
|
def signable_name
|
||||||
|
|||||||
@@ -6,6 +6,10 @@
|
|||||||
<%= render "shared/errors",
|
<%= render "shared/errors",
|
||||||
resource: @signature_sheet %>
|
resource: @signature_sheet %>
|
||||||
|
|
||||||
|
<div class="small-12 medium-6 large-4">
|
||||||
|
<%= f.text_field :title %>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="small-12 medium-6 large-4">
|
<div class="small-12 medium-6 large-4">
|
||||||
<%= f.select :signable_type, signable_options %>
|
<%= f.select :signable_type, signable_options %>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -0,0 +1,5 @@
|
|||||||
|
class AddNameFieldToSignatureSheets < ActiveRecord::Migration[5.0]
|
||||||
|
def change
|
||||||
|
add_column :signature_sheets, :title, :string
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -1318,6 +1318,7 @@ ActiveRecord::Schema.define(version: 20191108173350) do
|
|||||||
t.integer "author_id"
|
t.integer "author_id"
|
||||||
t.datetime "created_at"
|
t.datetime "created_at"
|
||||||
t.datetime "updated_at"
|
t.datetime "updated_at"
|
||||||
|
t.string "title"
|
||||||
end
|
end
|
||||||
|
|
||||||
create_table "signatures", force: :cascade do |t|
|
create_table "signatures", force: :cascade do |t|
|
||||||
|
|||||||
@@ -118,6 +118,12 @@ 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
|
||||||
|
title { Faker::Lorem.sentence }
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
factory :signature do
|
factory :signature do
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ describe "Signature sheets" do
|
|||||||
proposal = create(:proposal)
|
proposal = create(:proposal)
|
||||||
visit new_admin_signature_sheet_path
|
visit new_admin_signature_sheet_path
|
||||||
|
|
||||||
|
fill_in "signature_sheet_title", with: "definitive signature sheet"
|
||||||
select "Citizen proposal", from: "signature_sheet_signable_type"
|
select "Citizen proposal", from: "signature_sheet_signable_type"
|
||||||
fill_in "signature_sheet_signable_id", with: proposal.id
|
fill_in "signature_sheet_signable_id", with: proposal.id
|
||||||
fill_in "signature_sheet_required_fields_to_verify", with: "12345678Z; 1234567L; 99999999Z"
|
fill_in "signature_sheet_required_fields_to_verify", with: "12345678Z; 1234567L; 99999999Z"
|
||||||
@@ -58,6 +59,7 @@ describe "Signature sheets" do
|
|||||||
|
|
||||||
visit new_admin_signature_sheet_path
|
visit new_admin_signature_sheet_path
|
||||||
|
|
||||||
|
fill_in "signature_sheet_title", with: "definitive signature sheet"
|
||||||
select "Investment", from: "signature_sheet_signable_type"
|
select "Investment", from: "signature_sheet_signable_type"
|
||||||
fill_in "signature_sheet_signable_id", with: investment.id
|
fill_in "signature_sheet_signable_id", with: investment.id
|
||||||
fill_in "signature_sheet_required_fields_to_verify", with: "12345678Z; 1234567L; 99999999Z"
|
fill_in "signature_sheet_required_fields_to_verify", with: "12345678Z; 1234567L; 99999999Z"
|
||||||
@@ -134,6 +136,7 @@ describe "Signature sheets" do
|
|||||||
proposal = create(:proposal)
|
proposal = create(:proposal)
|
||||||
user = Administrator.first.user
|
user = Administrator.first.user
|
||||||
signature_sheet = create(:signature_sheet,
|
signature_sheet = create(:signature_sheet,
|
||||||
|
:with_title,
|
||||||
signable: proposal,
|
signable: proposal,
|
||||||
required_fields_to_verify: "12345678Z; 123A; 123B",
|
required_fields_to_verify: "12345678Z; 123A; 123B",
|
||||||
author: user)
|
author: user)
|
||||||
@@ -141,8 +144,8 @@ 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}"
|
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,18 +38,38 @@ describe SignatureSheet do
|
|||||||
end
|
end
|
||||||
|
|
||||||
describe "#name" do
|
describe "#name" do
|
||||||
it "returns name for proposal signature sheets" do
|
context "when name is nil" do
|
||||||
proposal = create(:proposal)
|
it "returns name for proposal signature sheets" do
|
||||||
signature_sheet.signable = proposal
|
proposal = create(:proposal)
|
||||||
|
signature_sheet.signable = proposal
|
||||||
|
|
||||||
expect(signature_sheet.name).to eq("Citizen proposal #{proposal.id}")
|
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
|
||||||
|
|
||||||
it "returns name for budget investment signature sheets" do
|
context "when name is not nil" do
|
||||||
budget_investment = create(:budget_investment)
|
let(:signature_sheet) { build(:signature_sheet, :with_title) }
|
||||||
signature_sheet.signable = budget_investment
|
|
||||||
|
|
||||||
expect(signature_sheet.name).to eq("Investment #{budget_investment.id}")
|
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}: #{signature_sheet.title}")
|
||||||
|
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}: #{signature_sheet.title}")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user