Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add UnsignedConsentDocumentForm #2023

Merged
merged 1 commit into from
Feb 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions app/forms/assessor_interface/unsigned_consent_document_form.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# frozen_string_literal: true

class AssessorInterface::UnsignedConsentDocumentForm
include ActiveModel::Model
include ActiveModel::Attributes

attr_accessor :assessment
validates :assessment, presence: true

attribute :generated, :boolean
validates :generated, presence: true

def save
return false if invalid?

assessment.update!(unsigned_consent_document_generated: true) if generated

true
end
end
4 changes: 4 additions & 0 deletions config/locales/assessor_interface.en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,10 @@ en:
attributes:
scotland_full_registration:
inclusion: Select whether the teacher has or is eligible for full registration
assessor_interface/unsigned_consent_document_form:
attributes:
generated:
blank: Confirm you have generated the non-signed TRA consent document
assessor_interface/verify_professional_standing_form:
attributes:
verify_professional_standing:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# frozen_string_literal: true

require "rails_helper"

RSpec.describe AssessorInterface::UnsignedConsentDocumentForm, type: :model do
let(:assessment) { create(:assessment) }

subject(:form) { described_class.new(assessment:, generated:) }

describe "validations" do
let(:generated) { "" }

it { is_expected.to validate_presence_of(:assessment) }
it { is_expected.to validate_presence_of(:generated) }
end

describe "#save" do
subject(:save) { form.save }

context "with a positive response" do
let(:generated) { "true" }

it "sets unsigned_consent_document_downloaded" do
expect { save }.to change(
assessment,
:unsigned_consent_document_generated,
).to(true)
end
end

context "with a negative response" do
let(:generated) { "false" }

it "doesn't set unsigned_consent_document_downloaded" do
expect { save }.to_not change(
assessment,
:unsigned_consent_document_generated,
)
end
end
end
end
Loading